Articles
Cleaning up Code: Removing Unnecessary Rails Helpers
Sunday, 03/14/2010
Since my recent switch to Eclipse, I've been compelled to cleanup my codebase. I'm into a Rails project, and I've been using the ruby script/generate commands, which also create "helper" files in the \app\helpers directory.
Since I have only a few helpers in place at the moment, I consolidated them into "application_controller.rb" and removed the remaining helpers, which cut my codebase by about 40% (from 86 files to 50).
Tending to my garden, so to speak
"rake doc:app" and "rake doc:plugins"
generates html readable documentation
for the code base.
Helpful Rdoc Link -
http://rdoc.sourceforge.net/doc/index.html
Rdoc Example -
http://rdoc.sourceforge.net/doc/classes/Anagram.html
Ruby Notes
Sunday, 03/14/2010
Ruby
Require vs. Include
Include vs Require
You must first Require a file/codebase. Requires takes a string as an argument. For example:
require "code.rb"
You must then "include" a module or class. Instead of a string, inlude takes a constant for an argument. For example:
include ClassName
I was looking into the differences between Classes and Modules. A Class can be made into a new instance of an object, but a Module cannot. A Module can contain the same things as a Class, but is used typically to extend of modify the behavior the Class that includes a "Module". Including a Module
is often referred to a "mix-in".
I found this link particularly helpful - http://rubylearning.com/satishtalim/modules_mixins.html.
Now, I can consolidate my custom code into Classes and Modules more appropriately.
My own workflow
Thursday, 03/11/2010
As the content of a website, or any body of documentation grows,
so does the need to provide order and context. I've wanted to
automate screenshots of the whole site to streamline my development workflow.
I'll tried working with PageGlimpse, and of course... there's a
ruby wrapper for it. I signed up for a free developer's
key, and went off to write something. Super simple to use, but I don't
have much use for a thumbnail sized screenshot. I wanted full-size .pngs.
Picking up where I left off, but with fresh eyes. I found
the PageSaver API, which is a $250 addition to the Firefox plugin.
I'm sure its useful, but I can't drop $250 on this (at this time).
I also found the FireShot Pro API, but haven't been able to
get it to work for localhost development.
For now, I've created a bookmark folder in Firefox and bookmarked every page
in the site. Then, I can open all pages at once (right-click the tab). Then, I can "Capture All Tabs" with
Fireshot. A workaround - but certainly workable.
FireShot also has the ability to specify filenaming conventions and the directory to output to.
Possible next steps are to visualize the sitemap as well. (Heirarchy/Tree)
to a real IDE
Wednesday, 03/10/2010
I switched to Eclipse when I was playing with Android (because it has the necessary SDK). I loved the code handling - no extra, unnecessary
tags like I remember and caused me to leave WYSIWYG editors in the past. Nevertheless, code-completion,
refactoring suggestions, code-coloring, and formatting, have helped my coding and productively considerably.
Gone are the days of unnecessary keystrokes starting servers and performing other non-valuable work required in development. From the "Servers"
tab in Eclipse, I set the servers once, and can start them all at once, to specified ports, that I have bookmarked for testing.
Thanks to
this posting,
I'm up and running a "real" IDE (Integrated Development Environment).
I've been using a mixture of notepad++, dreamweaver, word, the command-line, and filezilla; making my
way through and making extensive use of notepad++ to edit all code before it goes live.
I upgraded from Rails 2.0.2 to 2.3.5 and the mysql driver was
causing issues with Eclipse's Server configuration, giving the error,
"The bundled mysql.rb driver has been removed from Rails 2.2", and I'm
using InstantRails 2.0.
Cisco WRT160N Wireless Router
Monday, 02/01/2010
In Northern California, Comcast is a major media provider.
While configuring my new Cisco Linksys WRT160N
Wireless router, out of the box, it would not connect to Comcast to secure an IP.
After some research online, I found it necessary to specify a MAC address clone. It wouldn't pick up a Comcast IP otherwise.
Once, logged into the router, under "Setup > MAC Address Clone", make sure the "Enabled" radio button is selected, and click "Clone My PC's MAC". Shortly after, the router should be able to obtain an IP address from Comcast.