# 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
Sunday, February 28, 2010
Git diff changes 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
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
Flash
To find JAVA_PLUGIN_PATH
To find FLASH_PLUGIN_PATH
And BROWSER_PLUGIN_PATH is
NOTE: symlinks must be updated after every java upgrade
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
Wednesday, February 10, 2010
Factory Girl has many associations gotcha
Suppose Post has many Items
When setting up data for tests using factory girl
Don't do this!
Factory will create an item with another post_id and this will not be automatically changed to @post.id. Instead do this.
class Post < ActiveRecord::Base
has_many :items
end
class Item < ActiveRecord::Base
belongs_to :post
end
When setting up data for tests using factory girl
Factory.define :item do
u.post {|p| p.association(:post)}
end
Don't do this!
@post.items << Factory(:item)
Factory will create an item with another post_id and this will not be automatically changed to @post.id. Instead do this.
Factory(:item, :post => @post)
Friday, February 5, 2010
Running Shoulda & Factory Girl in Rails 3
Rails 3 uses Bundler gem to handle gem dependencies. Encountered some problems with Shoulda and Factory Girl.
Shoulda and Factory Girl macros are not loaded so I had to require the gems in test/test_helper.rb
# Gemfile
group :test do
gem "shoulda"
gem "factory_girl"
end
Shoulda and Factory Girl macros are not loaded so I had to require the gems in test/test_helper.rb
# test/test_helper.rb
require 'shoulda'
require 'factory_girl'
Factory.definition_file_paths = [ File.join(Rails.root, 'test', 'factories') ]
Factory.find_definitions
Problem installing sqlite3-ruby gem
Never learnt my lessons. Encountered this so many times.
The solution is to make sure the following library's installed!
sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for fdatasync() in -lrt... yes
checking for sqlite3.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
The solution is to make sure the following library's installed!
sudo apt-get install libsqlite3-dev
Thursday, February 4, 2010
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2010
(102)
-
▼
February
(12)
- Git diff changes staged
- Rails, RedCloth, textilize gotcha
- Using Fn triggered blue numpad keys for navigation...
- Bringing jobs into background in terminal
- Open files at line number in Vim
- Command line calculator
- Installing Flash & Java on Firefox & Chromium brow...
- Factory Girl has many associations gotcha
- Undo last Git commit with last commited files for ...
- Running Shoulda & Factory Girl in Rails 3
- Problem installing sqlite3-ruby gem
- Review git commits in terminal
-
▼
February
(12)