For web development purposes, I often need to use the “print screen” function on my windows keyboard to copy the contents of my screen to memory and then paste it into photoshop. Right now, I’m using OS X at work and use a mac keyboard but I also have parallels installed so that I can run windows along side by OS X install (parallels is awesome by the way and I will probably write an entire post about it).

My problem is since I use the max keyboard, there is no “print screen” function key built in - this is not a problem - just hit F13 on the mac keyboard and it acts just like the windows “print screen” key.

Below is an image containing reference to the print screen key on a mac keyboard and the same print screen key on a PC keyboard - both used for printing in parallels and stand alone windows respectively.

Print Screen key on mac and windows keyboard

If you’re on OS X and need to get a screen capture sent to memory, just do a:

apple command” + “shift” + “Control” + “the number 3

and you’ll have that photo sent to ram. You could also do the above key combination without the “Control” key to have the screen capture sent to your desktop.Here is a handy primer on OS X keyboard shortcuts that goes into greater detail on how to do things on a mac.

Stop/Prevent SSH Timeouts

June 5th, 2008

Time running outI use ssh quite a bit and am extremely annoyed when my shell session times out after a certain period of inactivity, say 20 minutes - what a hassle! Then you have to log back in, open up your files again, try to remember what you were working on, etc. To make a long story short, ssh timeouts cause a lot of headache and so I’ve taken the time to find out how to stop it from happening. The ssh timeout problem doesn’t come from the ssh deamon you are working with but rather…

the problem is actually not usually due to SSH, but rather to an intervening network device, often a NAT gateway or firewall. These devices keep track of TCP flows and time them out after a period of inactivity, for reasons of security or resource consumption. OpenSSH does not have an idle-timeout feature. SSH1, Tectia, and VShell do, but the feature is off by default.

So the problem is not your SSH client but it’s some crappy router or network device in between your computer and the server you work on that kicks you off. Sounds a bit unfair doesn’t it? Damn straight, let’s fix it. To keep your SSH client from timing out, you will need to open up the

/etc/ssh/sshd_config

file and insert the following two lines (in some linux distributions they are already there so in that case you just need to uncomment the lines and change the int values):

ClientAliveInterval 30
ClientAliveCountMax 4

you will need to restart your ssh deamon by doing something like this:

/etc/init.d/sshd restart

Once that is done, any future shell sessions you start shouldn’t timeout anymore!

If you’re like me then you’re using the unix vi editor like an oxygen tank on mars. But seriously, I’ve always liked the search and replace feature from other graphical based text editors so it’s only fair that we learn how to use vi’s search and replace function. It’s extremely useful and easy once you get the hang of it.

:%s/old_string/new_string/g

Will replace all occurrences of “old_string” with “new_string” in your file. The “%” tells us to execute the search command over the entire file.  The “g” tells us to search AND replace everywhere in the file.  You could also replace a string across a range of lines, for example:

:32,56s/old_string/new_string/g

Will replace “old_string” with “new_string” from line 32 through line 56, pretty handy :)

5 Useful Wordpress Plugins

December 1st, 2007

I’ve setup a number of wordpress web logs in the past and have found several plugins to be very useful:

  1. All-In-One-SEO-Pack: This handy pluggin helps you to place title and meta descriptions, among other things, into your blog pages to make them a little more SEO friendly. You may be surprised by the ranking increases your site can have with just a few minor tweaks to the title tag of your home page.
  2. Popularity Contest: A very feature packed analytics type plugin allowing you to show which posts on your blog are the most popular. This can help serve up content that people would be interested in reading but would otherwise never find on your site because they we’re originally looking.
  3. Sociable: Allows your users to easily submit your content to social networks, helping to spread your message.
  4. Wp-Cache: Makes your wordpress pages load faster via page caching. This can be good if you’re pages get popular on social media sites that have a HUGE amount of traffic, i.e. digg
  5. FeedBurner FeedSmith: Redirects your RSS feeds to FeedBurners feed service (now owned by Google). If your blog has interesting content and has real readers, you will want to use feedburner as Google may now be using your subscriber data as a signal of quality, helping your search engine results.