TODO and Custom Annotations in Rails Applications
While writing software it's common to leave comments for your future self. For instance, if you have written some code but realize that it should be refactored to be more efficient, you may place something along the lines of "TODO: change active record fi...
Written by Sean Behan on 06/17/2012
Load All ActiveRecord::Base Model Classes in Rails Application
Here is a simple rake task which will instantiate all of your Active Record models, provided that they are located in the RAILS_ROOT/app/models directory. Interestingly, all plugin models are instantiated by default when you run the task, for instance, if...
Written by Sean Behan on 06/17/2012
How Beautiful is Ruby?
Working with Ruby and in particular Rails, it's easy to take the beauty inherent in the language for granted. I mean look at this code. If you read it aloud to yourself, it reads like an english sentence that any non programmer can understand.
Forum.cate...
Written by Sean Behan on 06/17/2012
Deploying to Dreamhost
Remember to include the host declaration in the database.yml file when you deploy to Dreamhost. Dreamhost does not use "localhost" which is typically the default setting when using the mysql adapter and developing locally or even on a small site.
At lea...
Written by Sean Behan on 06/17/2012
How to Import/Export Your Wordpress Blogroll... er, Your Links
It's not immediately apparent how to import/export the links in your Wordpress blogroll. One would expect that the import/export tool, used to backup/restore Wordpress posts and pages would handle this functionality as well. But the import/export tool has...
Written by Sean Behan on 06/17/2012
How to Check if the Current Logged In User can Edit a Course in MOODLE Using the Has_capability Function
After an hour of fruitless searching through the docs and forums, I finally found an answer to my simple question, of course buried in the depths of the shark infested, murky water that is the Moodle code base .
How do I check if a user is a course creat...
Written by Sean Behan on 06/17/2012
Moodle's Most Important Function Gets No Attention
Arguably the most important function in the Moodle API, is the create_course function. One would think... after all Moodle is an LMS. Courses are the bread and butter for course management platforms, right? Taking a look at the function in the course/lib....
Written by Sean Behan on 06/17/2012
Recursively Zip Up a Directory while Excluding Certain Files Based on File Extension Type
In the example below, I'm going to zip up a directory that includes images in both PNG and PSD file formats. However, I want to exclude the PSDs because they are huge!
zip -r my-compressed-dir-without-psd.zip directory-to-zip -x '*.psd'
Written by Sean Behan on 06/17/2012
Uncompress A Bz2 File Using Tar Command
Uncompress a bz2 file using tar command
tar --use-compress-program bzip2 -xvf your-file-to-uncompress.tar.bz2
@source http://www.kde.gr.jp/help/doc/kdebase/doc/khelpcenter/faq/HTML/bzip2.html...
Written by Sean Behan on 06/17/2012
Convert Array to Object in PHP
function array2obj($data) {
return is_array($data) ? (object) array_map(__FUNCTION__,$data) : $data;
}
Source: http://www.serversidemagazine.com/php/how-to-convert-array-notation-to-object-notation...
Written by Sean Behan on 06/17/2012