Fix SSH Login Delay on Ubuntu Karmic

I was annoyed by the delay that takes place after you enter your username and password on SSH session before command prompt is displayed. It takes about 5-7 seconds. I searched around and it was  based on DNS and reverse lookup of local addresses. It feels like a bug in Ubuntu, though. However, the actual problem is in /etc/nsswitch.conf and the line below:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

First time I tried to leave only ‘files dns’ parameters but this caused another issue – I couldn’t ping a single domain from the command line. So I tested several ways to do this and the best solution is to remove only ‘mdns4′ from the above line. Line should look like this:

hosts:          files mdns4_minimal [NOTFOUND=return] dns

This way you will have local and reverse dns working, you will be able to ping domain hosted on the server and outside of it and most importantly you will not wait after login to see the shell. This issue is currently in the bug list for Ubuntu and it’s still not fixed in current releases. It exists for several years now. My Ubuntu version is Karmic.

How To Cook Geeky Pancakes

To exist as a geek you need energy. And to get good amount of energy you must eat food. There are several other methods you can use to energize yourself but they will not be reviewed in this post : )

After long hours sitting behind this monitor or playing on other devices, sometimes you just can’t resist to cook yourself a breakfast. Of course, it happens in days when it is so late that you are actually going to sleep  when you are supposed to get up. But suddenly you decide that you are hungry. Exactly for these days I am presenting you a recipe for pancakes, which I am sure you will love like I do.

Geeky PancakesFor 14 pancakes you need the following ingredients:

  • 250 grams flour
  • 0.5 liters of milk
  • 3 big eggs or 4 small eggs
  • 2 pinches of salt
  • 1 tablespoon powdered sugar
  • 1 small pack of powdered vanilla
  • 1 tablespoon vegetable oil
  • 20 grams of melted butter

To start find a deep dish and place the flour into it. Make a well from the flour and pour the into it. Eggs should be broken down as for an omelet (or one by one). Pour half of the milk slowly, beating 2-3 minutes to obtain a smooth mixture.

Add the salt, oil, melted butter, powdered sugar and vanilla. Pour second half of the milk and mix it well. Mixture should stand for half an hour at room temperature before frying the pancakes.

You can make pancakes with only water – then they become very light, but not so tasty. If you make them with milk, become thicker and thicker.

Fat is added to the dough so pancakes can’t stick when frying. Fry them over on low heat and then sprinkle with powdered sugar or decorate with sour cream and oranges.

In the mix I personally add 1 spoon of rum to strengthen the good smell of the pancakes, then use honey or jam to eat them.

For sure you have to cook those yourself  and comment on this post.

How to convert videos for Android with FFMPEG H264 codec

We had to convert any video in a CMS to Android playable h264 videos so they can play on all versions above 2.0.

After a lot of testing we found the correct parameters and settings, which are:

$ ffmpeg -i infile.mp4 -threads 4 -vcodec libx264 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -b 700k -r 600 -acodec libfaac -ar 48000 -ab 128k -pass 1 outfile.mp4

To have higher quality and optimal bitrate we do it using 2 pass encoding

$ ffmpeg -i infile.mp4 -threads 4 -vcodec libx264 -flags +loop+mv4 -cmp 256 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10 -qmax 51 -qdiff 4 -b 700k -r 600 -acodec libfaac -ar 48000 -ab 128k -pass 2 outfile.mp4

After encoding is complete we use MP4Box to change the format to ISMA MP4, which in basic words adds 2 meta data tracks to the video that are used by several streaming solutions so you can stream that video and also fast forward on the fly.

$ MP4Box -isma outfile.mp4

If you had similar issue please share it with us all. Or test this and comment below if it helped you.

Upgrade Samsung Galaxy Ace to Android Gingerbread

If you don’t know I am using Samsung Galaxy Ace as my main phone at the moment. I decided to buy Android phone just because I couldn’t really switch all of my devices to Apple products and believe me I tried. I like everything to be consistent, if my phone is from Apple, I want every device I have to be from that company.

Galaxy Ace is basically a copy of iPhone with 2 changeable back plates – one in black rubber, and the other shiny white. It looks very slick and it is easy to hold. I have to say I like its medium size, I am not a fan of big phones. But, you can’t run Flash on it, because the processor is not supported by Adobe, no matter it is fast enough 800Mhz. I had network issues though…

I was waiting for latest firmware from Samsung because my galaxy ace had strange issues with the networks. For example, USB tethering worked only with mobile networks and not with wi-fi. Other issue that was bugging me was that PPTP VPNs can’t replace the default gateway and it was useless this way.

So the day came, I started my Kies software and wow new firmware was released for my region. I was patient enough till that day and immediately run backup of the phone. Upgrade was  easy for me and it was quick probably 5 minutes with the download.

Absolutely first impression was that icons in the top status section are new – white on black. Other than this, visually it is almost the same. Later, I found that issues with USB tethering and the ones listed above were fixed and now I am a happy Android powered geek.

How to take screenshot on Android Froyo or Gingerbread

You don’t need an additional application to take screenshots on Samsung Galaxy phones, at least I tested it on them including Galaxy S1 and Galaxy Ace.

To take a screenshot hold back button and press the middle button. Screenshot will be saved in your gallery.

I found this one night while I was playing with the phone in my bed, then next 30 minutes I was trying to figure out how I did this ;)

How to fix PPTP VPN on DLink DIR-615 hardware revision D1

If you have problems connecting to PPTP via this router, probably you have firmware version 4.11. I found it has problems with GRE routing over wi-fi. To fix it, download firmware version 4.10 from dlink support website and install it on the router. Then you don’t have to add any port forwarding just start pptp vpn connection on your computer and it should be fine.

This above is my lovely working router  after the update.

How to fix shrinked videos in flash players.

I recently have to deal with flv files that play shrinked in jw player. The reason for this was that injector used originally didn’t set the correct width and height in FLV meta tags. Actually width was 0(zero). Flash players use met tags to receive info about the video inside, they can’t read the actual size of the video.

To fix this you have to see the video size with ffmpeg and then run:

$ fvltool2 -U -width:S1 -height:S2 file.flv

where S1 is the width from ffmpeg output and S2 is the height. This way you will renew the meta tags for the flv and it will be with correct dimensions.

How To Transfer Files From One Linux Server To Other

Let’s say you have server1 and server2.

If you have ssh access on both servers, you can do the following:

$ scp -r user@server2:/home/user2/file.txt /tmp

This will transfer /home/user2/file.txt from server2 to your /tmp folder on server1. This will also recursively download any directories if you want.

If you have ssh access to server1 and apache on server2:

$ wget “http://server2.com/file.txt”

This will download file.txt to server1 current directory

If you have ssh access on server1 and ftp on server2 do this:

$ wget -r “ftp://user:password@server2.com/dirname”

This will recursively download dirname from server2 ftp service to server1 current dir. Replace user and password with your access info to ftp on server2.

Freeware PDF Editor

I was trying to find a program that can change some text in a pdf file for free because it was something really simple. And I can tell you almost all I checked were rubish. However, under linux there is a program called ‘pdfedit’. It does the job really good.

When you load the pdf file you can’t edit it untill delinearize it. After this you can simply change texts, etc..

Here is a screenshot of it and from where to delinearize the pdf. Happy editing..

PDFEdit - Freeware PDF Editor

How to install cron without shell editor

Let’s say you don’t have an editor setup to work with crontab on a chroot server and you want to install a cron job.

What you have to do is the following:

$ contab -l

This will print currently installed cron jobs

$ crontab -l > cron.txt

Put contents of the crontab in a file. You can edit this file using and ftp/scp program or by other simple editor available on the server.

When you are ready install the cron…

$ crontab < cron.txt

If no errors are printed, cron job is installed successfully.