jump to navigation

Railsolver – now with wildcard host resolution September 12, 2008

Posted by John Dewey in Monkey Patch, Plugins & Gems, Rails, Ruby.
add a comment

I was watching the Subdomains Railscast. Ryan listed a few ways to point subdomains at your development system, and I thought Railsolver should support wildcards.

Updates are on github, along with an updated README and bugs :). I also added some Railsolver props on the Railscast page.


This plugin will “hijack” Ruby host(s) resolver aka(resolv-replace.rb), allowing programmatic host file resolution (including wildcard host resolution).™

Advertisements

Railsolver – programmatic Rails host resolution September 9, 2008

Posted by John Dewey in Plugins & Gems, Rails, Ruby.
add a comment

Ever want to to programmatically control your applications name resolution? Railsolver takes a stab at doing just that.


This plugin will “hijack” Ruby host(s) resolver aka(resolv-replace.rb),
allowing programmatic host file entries.

Hosts can be added globally or overridden per environment inside a YAML configuration file. You can also embed ERB.

See the README for usage.

controlling memcached with Phusion’s daemon_controller September 6, 2008

Posted by John Dewey in Code, Deployment, Memcached, Plugins & Gems, Rails, Ruby.
add a comment

I am working on an application that utilizes memcached, and want to develop against a locally running instance. Previously, we pointed our development environment to a sandboxed memcached cluster, which can be slow depending on time of day, location, and network. I typically mock external resources, however, I like a living memcache.

This post describes a way to start memcached automatically with script/server, and is a continuation of the daemon_controller memcached configuration post.

As the Phusion guys pointed out. Pulling code — and not worrying about configuration is AWESOME! This is especially true in the development environment.

phusion-daemon-controller.png

Adding this to development.rb will automatically start and stop memcached via ‘script/console’ and ‘script/server’. SAs maintain the daemons in the other environments via SMF, nor am I interested in maintaining those environments (did that … done that).

daemon_controller memcached configuration September 4, 2008

Posted by John Dewey in Configuration, Deployment, Memcached, Plugins & Gems, Rails, Ruby.
2 comments

The Phusion guys created a sweeet library (daemon_controller) to control servers or daemons. I created a daemon_memcache class which controls memcached.

Memcached can be controlled programatically by:

DaemonMemcache.instance.start
DaemonMemcache.instance.running?
DaemonMemcache.instance.stop

Will show you how to utilize this class to start/stop Memcached via ‘script/server’ in a follow-up post.

mrocstat – Mongrel pROCess title information stats August 18, 2008

Posted by John Dewey in Command Line, Mongrel, Plugins & Gems, Ruby, WebServers.
add a comment

I wrote a little tool which reports Mongrel’s process title information when using the mongrel_proctitle plugin. There is a gem which reports similar information, however, I like bundling utility scripts as SVN externals with my applications.

You can find the script on github.

memcache ruby 1.8.5 problems August 14, 2008

Posted by John Dewey in Memcached, Rails, Rake, Ruby, Solaris.
1 comment so far

We have some boxes at Joyent and for one reason or another, they are still on 1.8.5. We memcached an expensive Solr query, but ran into intermittent 500 errors.

Look at the odd stacktrace, with references to rake. Anyways, long story short – an upgrade to 1.8.6 fixed the problem. Yeah Yeah Yeah, I know — bad us — we should have upgraded long ago.

ActionView::TemplateError (wrong number of arguments (1 for 2))
on line #15 of topics/_search_result.html.erb:

View the pastie

Reloading classes in RSpec August 11, 2008

Posted by John Dewey in Code, Example, RSpec, Ruby.
1 comment so far

I had a class where methods could change a class variable’s structure on load. However, RSpec doesn’t reload a class, so testing
these methods is difficult.

One can reload a class inside RSpec by adding a before task:

describe SimplyTabby, "remove_system_information class method" do
  before(:each) do
    Object.send(:remove_const, 'Clazz')
    load 'clazz.rb'
  end

  it "should ..."
	...
  end
end

Rails Cron — Craken July 18, 2008

Posted by John Dewey in Capistrano, Code, Command Line, Configuration, Rails, Rake, Ruby.
Tags:
1 comment so far

My good buddy Doug Mciness wrote a rake task to manage and install cronjobs. We have it hooked into our Capistrano deployments, which allows for uber simple cron management. I added a few modifications such as, erb’ed raketab templates, and global/system specific crontabs.

It’s up on GitHubhttp://github.com/latimes/craken/tree/master

In the process of determining if these rakefiles should be yaml instead, would probably be the “more railsy rails way” of doing it.

Giles Bowkett gets props for the groovy name, and improved SEO of this post!

Run Rake Tasks with Delayed Job February 25, 2008

Posted by John Dewey in Code, Delayed::Job, Example, Rails, Rake.
1 comment so far

We needed to execute a Rake Task in the background, when a particular event occurred in Rails.  We decided to give Delayed::Job aka DJ a shot.  This “decorator” will execute a Rake task, while optionally passing ENV variables to the task.

Execute a Rake task from another task February 18, 2008

Posted by John Dewey in Example, Rake, Ruby.
3 comments

Executing a Rake task from inside another Rake task is a nice addition to your toolshed.  Passing parameters to the Rake task is even cooler.  ‘Rake::Task[“TaskName”].execute’ and ‘Rake::Task[“TaskName”].invoke‘ to the rescue.  A Rakefile that demonstrates the execution of a task with parameter passing.