Archive for July, 2009
Nginx and memcached module
Memcache is traditionally used as a module inside server side scripts, such as PHP, ASP, ColdFusion and others. And it’s doing a terrific job, as long as it’s implemented correctly.
But if we look under the hood of the actual Memcache application, and I’m not talking about the PHP or ASP extension, but rather the executable that’s running as a daemon under linux, for example, it is a rather simple database like application running in memory. Now there are two basic actions that need to be performed to use it, one is writing info into memcache, the other is reading it. In a typical scenario, there are many reads for one write, that’s the whole point, isn’t it. But what if we can isolate the reading from the server side scripts, and let a small high speed module do that for us.
Auto Create Thumnails The Easy Way
Ever wondered it there is an easy way to resize your images or quickly create thumbnails from your favorite pictures?
Search no more, the awesome little utility ImageMagick does it for you.
Install it using your package manager, most of them should have it in their repository.
sudo apt-get install imagemagick
Once installed, this command will create tumbnails for all JPG’s in the current directory, 200 pixel wide/high on the longest side. Eg. if your image is in landscape layout, it’ll be 200 pixel wide, in portrait format it’ll be 200 pixel high.
for file in *.jpg ; do convert -resize 200 “$file” t”$file”; done
That’s it. Simply change 200 to the size of your liking, or change the extension if your images are in gif, png or any other image format.
Exchange SSH keys and avoid logins and passwords
Working in a Linux environment, changes are you’re often using ssh, copying or rsyncing files between servers and workstations. I find it very annoying to always have to type in my login credentials. To avoid that, we can exchange ssh keys so that all the authentication is done utilizing those keys.
We can achieve that by following these two simple steps:
1. Generate a new key
$ ssh-keygen
2. Copy the generated ssh key to the target server(s)
$ cat ~/.ssh/id_rsa.pub | ssh user@target_machine cat – “>>” ~/.ssh/authorized_keys
That’s all there is to exchange ssh keys.