After being tired of refactoring .erb files to .haml I headed for a way to modify the rails generator that will create .haml view files rather than .erb view files.
After a while, I found what exactly I needed. ‘haml-rails’ is the name of the solution. This is how you do it.
Add the following line to your Gemfile:
Then run the bundler (bundle install).
Now append the following lines in your application.rb file (at the end of Application class):
config.generators do |g|
That’s it. Your new scaffolds will generate .haml files (and obviously haml syntaxes) for you.
This is much easier than Haml-scaffold.
After dual booting with Ubuntu and Mac OS, I could not write on Mac OS partition. However, I must have to find a way to do that as I will move certain things to ext3 partitions to be seamlessly usable by Ubuntu.
While reading online, somewhere I have read that I will need to disable journaling in Mac OS partition to mount it on Ubuntu with writing permission. I wanted to do the same but I saw the Enable/Disable Journaling button is not enabled in Disk Utility. So, after searching I found a command to do that from command line. It is simple.
# diskutil disableJournal /Volumes/Macintosh HD
That’s it. It disabled journaling on that partition. Later on Ubuntu I mounted the drive and I could write on it.
Mounting the partition on Ubuntu
sudo mount -t hfsplus /dev/sda2 /media/mac
You might already know that PHP’s in_array() function matches the string needle case sensitive way. However, today I was needed something that matches in case insensitive way. Before doing it myself, I googled it and I found a ready made solution. It is quite simple. Here it is:
function in_arrayi($needle, $haystack)
foreach ($haystack as $value)
if (strtolower($value) == strtolower($needle))
Please note that this case-insensitive version is, at least, 5 times slower than in_array().
Just few mins ago, from a tweet of Tareq Hasan, I came to learn about Animated Table Sort plugin for jQuery. Seeing the demo I was stunned and decided to implement on a project I was working right then!
After implementing, I see it can sort in one way. Either ascending or descending. If we set the parameter to
it sorts the table in descending order, otherwise ascending order. But, I wanted in both way. I mean, after clicking on the header, it should toggle between order. Suppose, on first click, it sorted ascending order. However, the second click should sort in descending order.
Continue reading →