Category: Programming

How To Cache Highly Dynamic Data in Rails with Memcache – Part 1

There are a number of ways increase Ruby on Rails performance through caching. Caching works because things don’t change….or don’t change frequently. In Cullect, almost everything is dynamic, even Cullect’s HTML presentation format has 3 different states depending on access privileges and there are 8 other presentation formats available. The standard page, action, and fragment […]

How To: Build a Wiki with Ruby on Rails – Part 1

Here’s how to build a very simple Ruby on Rails-based wiki engine 1. 1. Create the Rails App rails wiki and cd wiki to get inside the app. Remember: create your database (i.e. wiki_development) and update config/database.ymlappropriately 2. Generate the Scaffolding There are 3 nouns in this wiki system: People, Pages, Revisions. Let’s create the […]

Ruby on Rails Snippet for Changing Relative Paths to Absolute

If you have a bunch of text containing relative path hyperlinks, and you’d like to change to them to absolute paths, you might find this snippet helpful. content = “some text with a <a href=’/path/to/relative_link/’>relative link</a>” link = “http://somedomain.com/” content.gsub(/=(‘|”)//, ‘=1*/’).gsub(/*//, link.match(/(http|https)://[w.]+//)[0]) The asterisk ‘*’ is a hackey placeholder for the actual link swapped in […]

Parsing Arbitrary XML Namespaces in Ruby with Hpricot

(This post inspired by a Ruby.MN conversation) I’ve burned through at least 3 different XML parsing libraries in building Cullect. I started the built-in REXML (pro: built-in, con: heavy and slow) then moved to FeedTools (pro: easily parses the most common feed formats, con: no longer in active development). I have a lot of love […]

Optimization Tips: Ruby on Rails and MySQL

Stop. I’ve uncovered these tips after (at least) the 3rd refactoring effort of some fairly simple, straight-forward Rails code. Rails is great for getting ideas prototyped super fast. These tips will slow down development and make apps less portable. Continue reading only if you’re running a live app in production and not happy with how […]

Restarting Rails with ‘Address Already in Use’

iTerm crashed on my this morning taking down my development Rails process. Now, I’m busy tailing cullect.com‘s production.log and listening to some podcasts so I didn’t want to restart1 A little Googling found John Nunemaker’s year-old, “Oops I did it again” post. His tips worked. An I’m rewriting the following for Future Reference2: $ ps […]