Mac OS X : rename terminal tabs

If you want to manually rename your tabs without using a bash built-in, just hit Shift+Command+i :

 

git: checkout a specific revision of a file

Sometimes, you need to patch a specific file but you can’t pull the whole branch when deploying. To checkout a specific version revision of a file,  git syntax is : git checkout -m 4a3171c — filename For example, to get the last revision number of your master branch, look at your git fetch ouput : … 

 

From iPhone 4 to Nexus 4

I recently switched from my iphone 4 to a brand new Nexus 4. This is a short note about my thoughts with this new device and OS. Background: I’ve always used Linux/Unix systems. As for my smartphone, I started with an iPhone as any Android device I tried wasn’t responsive and attractive enough. I don’t use … 

 

Objective-C: Display frame size with NSLog

Width and height values are CGFloat values. To display them, you need to use the %f formatter from NSLog. But displaying these variables can be quite verbose, see below: NSLog(“frame: %fx%f”, myview.frame.size.width, myview.frame.size.height); Output will show : frame: 320.000000×480.000000 There are two other way to display frame size with NSStringFromCGRect() or [NSValue valueWithCGRect:] : NSLog(“frame: … 

 

Apache: password proctect your staging instances but allow your office IP

A common (good) practice is to protect your staging/dev instances with a password. It can be annoying with old browsers that don’t store passwords. To allow your office IP to connect without entering a password, just add the following lines to your virtualhost config: AuthName “Protected” AuthUserFile /path/to/.htpasswd AuthType Basic Satisfy Any <Limit GET POST> … 

 

Bash: assign a multi-line string to a variable

Sometimes you need multi-lined strings for readability in your scripts. I needed it for scripts that execute SQL queries. Example of a simplified script: #!/bin/bash read -d ” QUERY <<EOF UPDATE table_name SET field1 = ‘value’, field2 = ‘value’ WHERE id = 1; EOF mysql table_name -e “$QUERY”

 

EXIF and the command line on Mac OS X

I use imagesnap for a project to capture pictures from my laptop iSight camera. The problem is that imagesnap doesn’t write EXIF data to the captured files. Phil Harvey wrote command-line application called ExifTool to manipulate files’s meta information. Pictures from imagesnap are written with the following filename format: 2012-06-06_12-12-00.jpg I wrote a small shell script to extract time information … 

 

Finding outdated gems in your project (using a Gemfile)

There is a gem for that! Thanks to Patrick Lenz who wrote bundle_outdated (gem install bundle_outdated). In your project directory, execute bundle-outdated: $ bundle-outdated Finding outdated gems.. Newer versions found for: sass-rails (3.2.5 > 3.2.3) coffee-rails (3.2.2 > 3.2.1) uglifier (1.2.4 > 1.0.3) Lock bundle to these versions by putting the following in your Gemfile: gem … 

 

Right click, open with Sublime Text 2

If you like to use Finder to browse your projects, you might like adding a right-click action to open a file or a folder directly in Sublime Text 2 (or whatever you prefer). It is easily doable by creating a new service with Automator. Open Automator and create a new service: Select objects that receive … 

 

Installing Ruby 1.9.3 on Mac OS X Lion with RVM

Note: the default ruby version on Mac OS X Lion (10.7.3) is 1.8.7 Install RVM An easy way to install and switch between ruby version is to use RVM (Ruby Version Manager). RVM make installing multiple ruby interpreters / runtimes easy and consistent. Download and install latest RVM version $ curl -L https://get.rvm.io | bash -s stable …