Stage for Sinatra

I’ve been getting into hacking together quick web ideas via Sinatra, which is a great little Ruby web framework for getting things going QUICKLY.  I love how easy it is to get started (not many lines) and it supports HAML pretty much automatically.  It also lets you run a quick webserver just by running “ruby <yourfile.rb>”.

This is a great mechanism for development, because it allows really speedy iterations (or bugfixing).  However, some of these ideas are things I want to share or run more than just in a development mode, although not quite turn them into a full bore application.

Enter Phusion Passenger, the “mod_rails” plugin for Apache.  Passenger works for all Rack based applications, including Sinatra, making it pretty easy to setup a Sinatra app at a slightly more permanent location.

On l3ib.org, we have run lighttpd since the server was born, purely chosen out of its ease of syntax.  Over the years, things have been grafted on and some things are straight up hard to do on lighttpd, such as deploy Rails applications.  Luckily, our server provides a second public IP address, which Apache runs on.

Tonight, I created a staging area, called stage.minuslab.net, where I can dump these testing Sinatra apps as suburls.  I won’t link to the one app I put in there just yet as it is resource intensive and I don’t know yet how to throttle it to the outside world, but that will be coming a later haxpact entry.

I also wrote a quick script to manage adding each application as it is ready to be “deployed” - it adds the sub-uri to the stage.minuslab.net Apache configuration file, sets up the proper symlinks, writes the config.ru that is required, and restarts Apache all in one shot.  The script is buggy and internal only so I won’t share that either tonight, but it’s making developing small ideas with Sinatra even easier.

Rainbow 2.0

As my first haxpact entry, I decided to finish up the remaining pieces of rainbow, a toy program I developed that I find useful when doing anything with color (HTML stuff usually).  It’s a Ruby/GTK program that displays hex color codes found in plain text.  Here’s a current screenshot:

It has just been released as Rainbow 2.0.  Go check it out!

Rainbow never had an official 1.0 release, as it was waiting on a bug to be fixed in the Ruby/GTK bindings in order to let drag and drop work.  That bug is long since fixed, but I wanted to improve the visual nature of the program to show colors more proportional to the number of times they occured in the file.  Let’s start back at program inception and show the progression.

rainbow early concept

The rounded corners were adapted from a Python GTK theme color previewer that someone posted on Planet GNOME once (I forget who or where!), and the grid layout is using some seriously sketchy math on my part to lay it out.  This is however a working concept, parsing colors from text input and putting them into the grid.

rainbow 1.0

That grid concept grew more and I eventually surrounded it with some options such as sorting by hue or count, and showing text labels of the hex colors. This was supposed to be released as 1.0, but never quite made it due to waiting for that Ruby/GTK bug to be fixed (as well as general apathy).

I then tried to modernize it by throwing out the grid concept and making the swatches proportional to the number of occurances read in the input, but I really didn’t know how to do that. I stumbled across the “bin packing problem” and tried to adapt it to rainbow, with disastrous results:

binfit

The problem with the bin packing solution is that you need to know the dimensions of the items you are trying to pack, in this case, the colors, and that’s not what I care about here.  I just care about the area the colors take up.

Then I remembered a Windows application that displayed file usage as some sort of divided squares. After some googling, I found it: TreeMap. I adapted some code from the open source Java implementation linked there and used it to form what is rainbow 2.0.  Give it a try!

l3ib.org haxpact begins tonight!

A number of l3ib.org members have agreed to spend every day of the next month haxing on something interesting and blagging about it: HAXPACT.  Today is the first day of haxpact, and those of you subscribed to Planet l3ib should see some activity by midnight tonight.  The goal of haxpact is to generate interest and momentum on projects that most of us are too lazy to keep up with.

First off, credit where credit is due, haxpact is copying the idea of Gabor Papp and friends from the livecoding world.

Second, rules for participants:

  • Every day, from 8 Mar to 7 Apr, you must create something and blag about it
  • You may use previously unpublished hax from before this month, as long as you blag about it
  • Anything considered creation counts: code, web pages, graphics, visualization, music
  • Stuck?  Learn something new like processing, fluxus, CFDG: all visual things with quick learning curves

I plan on making a progress report similar to django advent or RPI’s RCOS Dashboard (my alma mater!).

Participating l3ibs include myself, andrewy, Fitzsimmons, and jvd. If anyone unaffiliated with l3ib.org wishes to participate, send me an email and I’ll add you to the accumulator. You should drop by #l3ib on freenode too.

Happy haxing!

lal 1.1 released

Thanks to some poking and prodding by MTecknology, there’s a new lal release.  It mostly just adds command line options, a man page, and a fix of a warning.  You expected more changes from such a tiny program?  Grab it, check it out, report any problems.