Thursday, November 12, 2009
MySecrets
I developed MySecrets to manages my personal secrets/passwords. I had a lot of fun doing BDD with cucumber. Pickle works very nicely with Machinist to reduce step definition code. I used authlogic for authentication and formtastic to reduce the boiler plate code in my views.
I had some trouble integrating cucumber, pickle, machinist, and authlogic. A user has 0 to many secrets and secrets are protected by authlogic. So cucumber features that needed to add secrets and validate them were a little tricky.
This scenario creates a user, login in, creates a secret, shows the secret, and finally validates the secret.
The show pages are handled with a polymorphic_path.
The actual user creation and login steps are handled here.
The secret is validated with:
All of the coded can be found at http://github.com/perry3819/mysecrets
I had some trouble integrating cucumber, pickle, machinist, and authlogic. A user has 0 to many secrets and secrets are protected by authlogic. So cucumber features that needed to add secrets and validate them were a little tricky.
This scenario creates a user, login in, creates a secret, shows the secret, and finally validates the secret.
The show pages are handled with a polymorphic_path.
The actual user creation and login steps are handled here.
The secret is validated with:
All of the coded can be found at http://github.com/perry3819/mysecrets
Monday, October 26, 2009
Interval Rails Caching
Feedpoint (source) is a blog aggregator written with Ruby on Rails deployed on a linux server. It retrieves RSS content from blogs and displays them sorted by date at http://feedpoint.hertler.org. Retrieving the RSS content is an expensive step and caching is needed to speed up HTTP requests. Google searching for a way to expire page caching on a timed interval did not yield promising results so I developed a very easy custom strategy through the use of Linux cron jobs.
The Rails code for the page caching is in home_controller.rb.
caches_page and expire_page are ActionController methods. caches_page caches the the :index and :planet_redpoint actions and expire_page expires them.
With this setup, http://feedpoint.hertler.org/home/ will load the :index into page cache and http://feedpoint.hertler.org/home/expire_cache will expire the cache. At this point, monkeys could be trained to navigate to the expire_cache URL every ten minutes or a cron job could be set up. This post will focus on setting up the cron job.
The cron job was configured by entering crontab -e from a terminal and then adding the following line:
This job uses cURL to call the expire_page action every ten minutes. Good cron tutorials are all over the web and beyond the scope of this post.
One added benefit of this approach is that if a blogger is anxious for a recently posted blog to show up on the world famous http://feedpoint.hertler.org site, it can manually be refreshed right away!
The Rails code for the page caching is in home_controller.rb.
caches_page and expire_page are ActionController methods. caches_page caches the the :index and :planet_redpoint actions and expire_page expires them.
With this setup, http://feedpoint.hertler.org/home/ will load the :index into page cache and http://feedpoint.hertler.org/home/expire_cache will expire the cache. At this point, monkeys could be trained to navigate to the expire_cache URL every ten minutes or a cron job could be set up. This post will focus on setting up the cron job.
The cron job was configured by entering crontab -e from a terminal and then adding the following line:
This job uses cURL to call the expire_page action every ten minutes. Good cron tutorials are all over the web and beyond the scope of this post.
One added benefit of this approach is that if a blogger is anxious for a recently posted blog to show up on the world famous http://feedpoint.hertler.org site, it can manually be refreshed right away!
Monday, August 10, 2009
Install mysql gem on OS X 10.5
I had a little trouble installing the mysql gem on OS X 10.5 this morning so I thought I would post the solution.
1) Download the mysql binaries from apple http://support.apple.com/kb/TA25017?viewlocale=en_US
2) Unpack the binaries.
3) sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config (be sure to give an absolute path to the config file)
4) done
1) Download the mysql binaries from apple http://support.apple.com/kb/TA25017?viewlocale=en_US
2) Unpack the binaries.
3) sudo gem install mysql -- --with-mysql-config=
4) done
Feedpoint - Rails Blog Aggregator
I finished up the 0.1 release of feedpoint.


Feedpoint is a blog aggregator. Companies may find it useful for showcasing blogs of its employees.
So far, the whole application is written with Ruby on Rails. Additional front-end frameworks are planned including JavaFX and Silverlight.
Privileged users may add new feeds through a web interface.

The main screen displays all of the posts sorted by date.

Labels: Rails
Monday, July 6, 2009
FirstMem - a tool for verbatim text memorization
I have recently spent some time learning Ruby and Rails. When I learn a new language I typically write an easy application so that the focus is not on solving a particularly difficult problem, but on learning the new technology. To learn Ruby on Rails, I wrote http://firstmem.hertler.org. The code is hosted at http://code.google.com/p/firstmem/
As I was writing the code I was constantly shocked at how little code it took to perform complex tasks and how easy the Rails framework is to learn. It almost felt like cheating!
Subscribe to Posts [Atom]



