Sunday, February 28, 2010

Git diff changes staged


# On branch master
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# modified: app/views/matriculations/new.html.erb

To see changes,

git diff --cached (pre-1.6)
git diff --staged

Rails, RedCloth, textilize gotcha


# This doesn't work! It returns html in pure strings and not the html elements!

textilize @blog.content

# Need this extra step.

sanitize(textilize @blog.content)


**UPDATED**

The problem lies that Rails 3 ERB uses h() helper by default

<\%= xxx %>
<\%= h(xxx) %>
To get past this use context_tag() or raw()

xxx = content_tag(:p, "blah")
<\%= xxx %>

xxx = "<\p>blah<\/p>"
<\%= raw xxx %>

Saturday, February 27, 2010

Using Fn triggered blue numpad keys for navigation on your laptop

Laptop keys are usually cramped and accessing the usual arrow and page keys are a hassle. I find it useful to use the "numpad" triggered by Fn key.


Fn + 7 = Home
Fn + 1 = End
Fn + 9 = Pg Up
Fn + 3 = Pg Down
Fn + 8 = Up
Fn + 2 = Down
Fn + 4 = Left
Fn + 6 = Right

Sunday, February 21, 2010

Bringing jobs into background in terminal


# Suspend job
CTRL + z

# View jobs
jobs

# Bring job into background
%1 &

# Bring job into foreground
%1

Open files at line number in Vim


:e PATH_TO_FILE:LINE_NO

Eg.
:e app/models/user.rb:10

Sunday, February 14, 2010

Friday, February 12, 2010

Installing Flash & Java on Firefox & Chromium browsers

1. Install Flash & Java
2. Symlink executables to browser plugin folder

Java

sudo ln -s  JAVA_PLUGIN_PATH BROWSER_PLUGIN_PATH

Flash

sudo ln -s FLASH_PLUGIN_PATH BROWSER_PLUGIN_PATH

To find JAVA_PLUGIN_PATH

locate libnpjp2.so
/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386/libnpjp2.so

To find FLASH_PLUGIN_PATH

locate libflashplayer.so
/usr/lib/flashplugin-installer/libflashplayer.so

And BROWSER_PLUGIN_PATH is

# Firefox 
/usr/lib/mozilla/plugin/

# Chromium 
/usr/lib/chromium/plugin/

#Google-Chrome 
/opt/google/chrome/plugin/

NOTE: symlinks must be updated after every java upgrade