Skip to content

Instantly share code, notes, and snippets.

# usage: ruby timecard.rb path branch name-of-graph-file-not-including-extension
# e.g.: ruby timecard.rb . master timecard #=> produces timecard.png
require 'rubygems'
# This requires the 'cyberfox-gchart' gem (0.5.4), as the standard
# gchart gem is woefully broken for this kind of graph. Broken to the
# point that it's an inherent design choice that doesn't work well for
# this kind of chart. I'm sure that the cyberfox-gchart gem won't
#!/opt/local/bin/ruby
# supa primitive script to access today's journal entry text file
now = Time.now
month = now.month.to_s
month = "0" + month if month.to_i < 10
day = now.mday.to_s
day = "0" + day if day.to_i < 10
date = month + day + now.year.to_s[2,3]
require 'rubygems'
require 'fastercsv'
require 'active_support'
require File.dirname(__FILE__) + "/gruff/lib/gruff" # had some glitches with rubygems gruff
# cargo cult: http://blog.nikosd.com/2008/10/beautiful-bar-charts-with-ruby-and.html
g = Gruff::Bar.new('700x400') # Define a custom size
g.sort = false # Do NOT sort data based on values
g.theme_keynote # Declare a theme from the presets available
`ls input_dir/filenames*`.each_with_index do |image, index|
image.chomp!
image.gsub!(/ /, "\\\\ ")
filename = "output_dir/picture_#{index}.jpg"
system "convert -density 72 -size 400x300 #{image} #{filename} ; amazon -b my_bucket_name #{filename}"
end
$(document).ready(function() {
$("#button").click(function() {
alert("foo");
$("#button").unbind().click(function() {
alert("bar");
return false;
});
return false;
});
});
@gilesbowkett
gilesbowkett / wtf.js
Created October 18, 2010 05:13
wtf_null.js
var sys = require('sys'),
assert = require('assert'),
underscore = require('../vendor/underscore/underscore')._;
Array.prototype.drop = function() {
var recalculatedArray = _.compact(this);
for (var i = recalculatedArray.length; i < 7; i++) {
recalculatedArray[i] = null;
}
return recalculatedArray;
@gilesbowkett
gilesbowkett / compiled.js
Created November 25, 2010 22:19
this is output from sibilant, a lisp which compiles to node.js
var fs = require("fs"),
sys = require("sys"),
buffer = (new Buffer(10000));
fs.open("./jsfiles.list", "r", (function(err, fd) {
// err:required fd:required
return fs.read(fd, buffer, null, "utf8", (function(error, string, count) {
// error:required string:required count:required
return sys.puts(buffer.toString());
}));
}));
sibilant foo.lisp bar
Error: ENOENT, No such file or directory '/dir_name/foo'
at Object.openSync (fs:153:18)
at Object.readFileSync (fs:94:15)
at Object.translateFile (/usr/local/lib/node/.npm/sibilant/0.0.9/package/lib/cli.js:116:48)
@gilesbowkett
gilesbowkett / array_elements_diff.rb
Created December 5, 2010 18:32
I have no idea what this field is for
# my first serious ruby question in like forever:
class Array
def token_diff(other)
memo = 0
self.each_with_index do |element, index|
memo += 1 if other[index] != element
end
return memo
end
<macbook of doom:giles> [01-02 13:49] ~
↪ node
> 284.88 + 96.80 + 459
840.6800000000001