FOLLOW ME Twitter Facebook Вконтакте LinkedIn RSS Feed
Browsing articles in "Tips and Tricks"

How to extend the WordPress cookie timeout

Dec 30, 2013
Category: Tips and Tricks

First of all: I really like WordPress. I’ve been using it since 2004 or so. At the moment I’m registered on a several WordPress-based web-sites where I write comments and interact with other people from time to time. The thing I really don’t understand in the WordPress architecture is why WordPress has hard-coded cookie timeout for only 14 days? It makes me angry all the time I see that a WP-based web-site forgot who I am.

Hopefully, if you’re a web-site administrator, this is an easy-to-fix problem. All you need is to slightly change your current theme’s function.php file. What you should do:
1. Go to the Admin Panel and then Appearance -> Editor
2. Click on Theme Functions (functions.php)
3. Paste this code to the end of the file, but before ?> ending tag.

/*******************************
 * COOKIE TIMEOUT EXTENDER     *
 *******************************/
function custom_auth_cookie_expiration($date) {
  return 365 * 24 * 60 * 60; // one year in seconds
}

add_filter('auth_cookie_expiration', 'custom_auth_cookie_expiration');

365 here is a number of days. You can change it as you wish.



How to restore unreadable USB flash drive under Mac OS X

Sep 1, 2013
Category: Tips and Tricks

USB Flash Drive recovery Today I found that I can’t access to my 8Gb USB flash drive. I can find it in Finder, but the System gets stuck while accessing to it. What to do? If you want to recover data from a USB flash it’s better to stop reading this post now and continue googling “USB flash data recovery” or something. Here’s a step-by-step instruction how to make your USB flash drive work again under Mac OS X.

1. Open Terminal and go to /dev

$ cd /dev

2. Now it’s time to find your flash drive in /dev. Typically it’s /dev/diskN where N could be 0, 1, 2, 3, etc

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *121.3 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            120.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *8.1 GB     disk3
   1:                        EFI                         209.7 MB   disk3s1
   2:       Microsoft Basic Data KB                      7.9 GB     disk3s2

OK! It’s disk number 3, i.e. /dev/disk3 Remember the name of partition (it’s KB in my case). Your flash drive is mounted as /Volumes/NAME Continue reading »


Running java on Debian via SSH

Jan 13, 2013

A few days ago I had a problem: run YouTrack on my VDS. YouTrack is a bug tracker written in Java. First time I run it as

java -jar youtrack.jar 8080 &

And this worked fine, until I closed my ssh session with the server. When you close a ssh session your terminal send the HUP (hangup) signal to warn all depending processes of logout. To avoid the HUP signal to be sent, run your java programs using hohup:

nohup java -jar youtrack.jar 8080 &

How to setup a private git repository on Debian using Gitosis

Apr 19, 2012
Category: Tips and Tricks

In this post I’m going to give you step by step instructions of how to setup your own git repository. I’ve got a VDS (Virtual Dedicated Server) running on Debian 6.0.4, but all steps are valid for Ubuntu too.

First of all we should setup all necessary tools including git:

apt-get install git python-setuptools python-dev

After that, get gitosis sources. Official repository git://eagain.net/gitosis.git stopped working, so use github repository instead:

git clone https://github.com/tv42/gitosis.git
cd gitosis
python setup.py install

Check that you’ve got sudocommand installed and if it’s not install it.

apt-get install sudo

I didn’t have sudo installed on my VDS so that’s why I care about it.
Ok, then create and add a gitosis user:

sudo adduser --system --shell /bin/sh --gecos 'gitosis user' 
             --group --disabled-password --home /home/git git

Now it’s time to set up a security connection between your local machine and the server. If you already have a private key and you know what is that, just skip the next step. Otherwise, you should generate keys on your local machine.

ssh-keygen -t rsa

If you’re a Windows user, you should find some way to generate security keys. For instance, use PuTTY gen.

Next step is to copy your public key to the server. Continue reading »


How to make an iPhone ringtone from an mp3 file?

Apr 14, 2012
Category: Tips and Tricks

Ok, everybody. This post is for those of you who don’t want to buy iPhone ringtones in AppStore. The cheapest way to get a ringtone is to make it by ourselves. Here is a step-by-step instruction how to make and install an iPhone ringtone from an mp3-file.

  1. First of all you should have an mp3-file which is the best ringtone ever. Keep in mind that your ringtone’s length should be 30 seconds or less. It’s important. If you need to cut some part of the mp3-file, you can use simple Web 2.0 utility on CutMP3.net
  2. Open iTunes and drag-n-drop the mp3 file from Explorer/Finder/etc to the iTunes Library. It will appear in the Music list.
  3. Now let’s go to the iTunes Preferences -> General and click on Import Settings button. This will open a dialog.
  4. In the dialog set Import Using as AAC Encoder and click OK and click OK again on the Preferences dialog.
  5. We’re very close to the finish now. Go to Music and select the mp3-file you added on step 2. In the context menu select Create AAC Version
  6. Select just created file and select Get info from context menu. You will see a dialog. Look at Summary tab and you will find where the converted file is located.
  7. Go to the file and change its extension from m4a to m4r.
  8. Drag-n-drop the m4r file to iTunes as we already did on step 2 and you’ll notice that you have it in Tones section.
  9. Connect your iPhone to iTunes and drag-n-drop the ringtone from the Tones section to the iPhone section. That’s all!

Google Chrome redirecting Google Search to wrong country

Mar 30, 2012
Category: Tips and Tricks

I’ve been using Google Chrome since 2009 and one thing I like and use the most is a googling just inside URL-bar. Some month ago Google started to detect my location automatically and redirect me to appropriate  google domain. For instance, I live in Germany and I’d like to use google.com but Google Chrome redirects me to google.de every f*cking time I search something in URL-bar. If you have the same problem as I had the workaround is  simple. Go to Google Chrome Options -> Basics and click “Manage search engines”. Add a new one with any name and keyword, but the URL should be
https://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=%s

Make just created search engine default and that’s it! Enjoy.