You do Ruby. You are on *nix. You have a task you need to schedule using cron from your scripts. Later you schedule another task. After some time, and probably from another script, you want to unschedule/cancel the first task … How do you do it?

Fetch CronEdit

    sudo gem install cronedit

….and just do it:

    Crontab.Add  'agent1', '5,35 0-23/2 * * * echo agent1'
    ...
    Crontab.Add  'agent2', {:minute=>5, :command=>'echo 42'}
    ...
    Crontab.Remove 'agent1'

You can CRUD your tasks independently (based on the IDs you give them). The schedule can be in Hash notation, or the standard cron text definition.

UPDATE: The new version of library allows you to do some more tricks. First of all, you can manipulate groups of definitions (bulk/group operations). Besides modifications of the actual crontab, you can do now all operations upon files or in memory. And you can combine these ‘devices’ as needed. Let me show you a small example:

    fc = FileCrontab.new '/jobs/mail-delivery.cron'
    Crontab.Merge fc
    ...
    Crontab.Subtract fc

The previous snippet loads a group of cron definitions from file and merges them with the current system crontab. On the last line the same group of definitions is removed from the system crontab.

See documentation for more details and examples.
UPDATE: A related article discusses the library in context of scheduling of Ruby Agents using Cron.

In Ruby there are few schedulers out there, for example the most advanced: openwferu scheduler. They are great for many task, yet…. they are Ruby proprietary schedulers and the host ruby script needs to be running. If you need native cron scheduling, for whatever reason, go for CronEdit.


Do you want to have photo albums (on your site)? I did. I wanted a comfortable but not “over-web20-ized” user experience, and above all, simple and pragmatic content management/control.

Believe or not, nothing I came across was just the right thing. Too heavy, too weak, too ajaxy, unacceptable license, etc. At the end of the day I found out I had not had to look too far. Ondrej Jaura (a good friend of mine) created a simple command-line album generator - Rhotoalbum. Bonus: it is written in ruby :)
You treat your images as ordinary files in directories (which stand for albums) and run a generation command. That’s all you need to do. You add new images or change something? Just run the same script - anytime. It creates necessary thumbnails, and simple style-able index pages. For slideshow purposes it (optionally) integrates with nice TripTracker.

My way of appreciation of my Ondrej’s great work was … to contribute the project and help out in making it better. This resulted into a release of a new stable version 0.3 these days.

Well, I started this post saying I wanted some place for our photos to show them to friends occasionally. Here is are our Rhoto photo gallery. Another showcase for Rhotoalbum is Ondrej’s photo gallery.


It goes like this: Firewatir, the Firefox port of WATIR, depends on JSSh. And JSSh does not install & run nicely on Linux. Clear ?
Annoyed by this situation, I looked what’s the problem with this JSSh. To make the story short, success - downlaod the working JSSh for Linux here.
Update 2007-04-11: modified to work also with FF 1.5.3+

Oh, by the way, JSSh stands for JavaScript Shell and it allows you remotely manipulate Firefox remotely. Firewatir gives you a higher-level toolkit for “Web Application Testing in Ruby” (of course not Web scraping ;>>> ). Talking about it let me show how to install the whole thing:

(0. I would recommand to create a dedicated Firefox profile run Firefox in a dedicated profile firefox -ProfileManager)

1. Downlaod and install JSSh extension to Firefox and restart it.

2. Start Firefox:
firefox -P testyard -jssh

The JSSh should be up, listening on port 9997 (note: consider security issues). You should be able to communicate with Firefox via telnet. For example:

>telnet localhost 9997
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome to the Mozilla JavaScript Shell!
> 1+1
2
> help()
....
> exit()

3. Dowload firewatir (you have to do it from its homepage, it is not on rubyforge yet). Use the mswin32 version, although you are on Linux. Install:
sudo gem install firewatir-1.0.1-mswin32.gem

3. Get to the real ruby test. For example:

  1. require ‘rubygems’
  2. require ‘firewatir’
  3. include FireWatir
  4.  
  5. ff=Firefox.new
  6. ff.goto("http://www.google.com/ncr")
  7. ff.text_field(:name,"q").set("ruby")
  8. ff.button(:value,"Google Search").click
  9. puts ff.element_by_xpath("//a[@class=’l']").text
  10. ff.close

PS: For those interested in what did I fix: I took one of the latest builds from Dave, repackaged it so that it installs “properly” - as an extension of “21st century” - and added the config GUI shipped originally with the JSSh. It was tested with FF 2.0.0.1 on Ubuntu (Eft), Kubuntu, Gentoo. Update: tested also on FF 1.5(.0.7)