Tag Archives: ruby

In praise of github

A few years ago I became sold on distributed source control.  Being able to do offline work, try out new ideas cheaply, and throw them away, all were great things.  I started with mercurial, but over the summer started using git.  A couple of things pushed me over the edge.

  • git appeared more modular, at the end of the day this wasn’t really true.  The lack of a libgit was actually very disappointing (especially after I had sworn there was one), as I’ve got a number of interesting ideas stalled behind that one.
  • the git-svn pluggin, which provides really good 2 way integration between svn and git trees.  I’ve stopped making anon svn clones, I now do a git-svn clone.  If I want to fix something locally, I can now version that fix.
  • github – free social hosting of git trees

Github helps you over the hump in publicly hosting git trees.  Honestly, the hump isn’t very high, but the documentation out there could be a bit more straight forward.  I’d been chugging along using github for all my random open source projects, some that are active, some which are stalled.  But the source code is out there for others to take a look at.  Github provides nice instructions for people to clone the work, and run with it.  It’s definitely a prettier interface.

Github really started to shine for me this past weekend though.  I was looking for ical generation code for ruby to replace an email tool that I wrote in perl for our MHVLUG monthly meeting emails.  There exists 2 ruby ical projects, vpim and icalendar, neither of which support timezones in the ical generation, and both with pretty inactive mailing lists.  Once it became clear that the problem was not solved, I decided to dig in and see if I could come up with something workable.

But once you go social, github really shines

There had been a post on the icalendar devel list a few months back that said he had fixed a couple of timezone issues and provided a github url.  I cloned that project, and realized that while it got closer to what I needed, it still didn’t quite do what I needed.  So I clicked the fork button.

I was now given my own fork of the icalendar source.  But more importantly, it also showed me all the other forks on github, which there were 5 others.  I made my fixes, pushed them back public, and then proceeded to start to accumulate up some of the other changes out there.  There is even a fork queue which shows all the outstanding changes in other forks out there, as well as odds on whether or not the patches will apply.

While you could figure all this out on your own with the command line, that kind of discovery and view is really a help and a timesaver.

And it’s even better if you are doing ruby

Github is written in ruby, though I’m not sure on the framework behind it.  As an added bonus to people hosting ruby code on the site, the team created a gem build service into github.  You add a specially formatted gem spec file to your github tree, and you’ll get a gem built on each checkin.  My 2 ruby libraries that are there now are configured to build gems, easy for all to install.

If you haven’t checked out git, or github, you should.  While I found the learning curve on git to be higher than I really wanted to deal with, the community is very active, and the number of things that support git now is quite high.  Rails generators even support git now, automatically source managing via git or svn if you ask them to.  Github popped out of no where in 2008, and I can’t wait to see where they are going to go in 2009.

Publishing my first gem: thermostat 0.0.2

When not working on OpenSim, I’ve been doing a bunch of random side projects in Ruby. One of the more recent ones has been a more advanced control and monitoring tool for my thermostat.

Along the way I created a module for the thermostat control. Last night I finally figured out how to package this work up as a gem file, which makes this easily installable to the world. Right now, the code is really raw, and I haven’t put in any documentation yet. But, for those interested, it’s available.

> gem search -r thermostat

*** REMOTE GEMS ***
Bulk updating Gem source index for: http://gems.rubyforge.org

thermostat (0.0.2)
    Ruby modules to control Prolipix IP Thermostats

Enjoy.

Graphing with Gruff

The house monitoring project has made a little bit of progress, as I’ve now got data being collected into a rails app using backgroundrb, and can get that data back out into very pretty graphs with gruff.  (I also looked a little bit a sparklines, but that’s specifically for graphs without labels.)
 

We’re running above target temp as it’s the weekend, so the wood stove is on.  As is the furnace fan to spread the heat through the house.  I’m overloading the values for heat on an fan on to be either the bottom of the graph or a specific small value.  I need to sort out a better way to put that into the graph, which may require some hacking on gruff itself.

Early working thermostat code

I definitely don’t have this anywhere near I like it, but I did manage to just dump out a bunch of info from my thermostat and turn off the fan with this script:

#!/usr/bin/ruby

require 'thermostat'
require 'pdp_constants'
include Proliphix

t = Thermostat.new("192.168.1.30","admin","XXXXXXXX")
t.set_senors(ThermHvacMode, ThermHvacState, ThermFanState, ThermFanMode, ThermAverageTemp, ThermHeat1Usage)
t.fetch_data

# dump out what we have
puts t

# turn off the fan
t.set_data(ThermFanMode, 1)

I need some nicer symbolic constants for state setting, and pull together a rails site just to keep track of thermostat data over the course of the day.  All this code is going on my newly registered rubyforge project.