Skip to content

Instantly share code, notes, and snippets.

View jeremywrowe's full-sized avatar
❤️
Coding

Jeremy W. Rowe jeremywrowe

❤️
Coding
View GitHub Profile
@jeremywrowe
jeremywrowe / autotest.rake
Created December 19, 2010 18:11
autotest ruby script runner for rails (script/autotest), with matching autotest.rake file (lib/tasks/autotest.rake)
$here = File.expand_path(File.dirname(__FILE__))
$rails_root = "#{$here}/../.."
$logs = "#{$rails_root}/logs/"
$script = "#{$rails_root}/script/autotest"
namespace :autotest do
desc "start autotest background task"
task :start do
@jeremywrowe
jeremywrowe / gist:771776
Created January 9, 2011 16:00
grabbing object info from a bucket s3
require "aws/s3"
AWS::S3::Base.establish_connection!(
:access_key_id => 'KEY_GOES_HERE',
:secret_access_key => 'KEY_SECRET_GOES_HERE'
)
object = AWS::S3::S3Object.find 'OBJECT_NAME_GOES_HERE','BUCKET_NAME_GOES_HERE'
puts object.etag # MD5 SUM
@jeremywrowe
jeremywrowe / flot
Created January 24, 2011 04:36
flot + ruby
<h1 style="text-align:center;"> Page Statistics </h1>
<div style="clear:both">
<div style="float:left" id="stats">
loading...
</div>
<div style="float:left; height:300px; width:10%" id="stats_legend">
loading...
</div>
</div>
@jeremywrowe
jeremywrowe / superbowl.rb
Created February 4, 2011 02:06
number generator for super bowl :)
@amount = 9
@amount = ARGV[0].to_i if ARGV[0]
@randomize = rand(1000)
x_array = []
y_array = []
@amount.times do |i|
x_array << i+1
y_array << i+1
@jeremywrowe
jeremywrowe / commit_summary.rb
Created February 4, 2011 04:37
summarize git commits.. (relies on git extra's being installed)
#!/usr/bin/ruby
require 'fileutils'
include FileUtils
$here = File.expand_path(File.dirname("."))
git_dirs = Dir.glob("#{$here}/*/.git").reject{|x| x == "." || x == ".." }
@total = {}
def translate(user)
case user
@jeremywrowe
jeremywrowe / git_and_svn_update.rb
Created February 4, 2011 12:38
update all of your git and svn projects from a root directory
#!/usr/bin/ruby
require 'fileutils'
include FileUtils
here = File.expand_path(File.dirname(__FILE__))
git_dirs = Dir.glob("#{here}/*/.git")
svn_dirs = Dir.glob("#{here}/*/.svn")
def git_pull(path)
cd path
@jeremywrowe
jeremywrowe / commands.rb
Created September 2, 2011 03:26
arduino remote outlet button meta programming awesomeness
module Commands
class << self
%w{one one two two three three}.each_with_index do |button, index|
current = 4 + index
method_prefix = (current % 2 == 0 ? "off" : "on")
define_method "outlet_#{button}_#{method_prefix}" do |tty|
current
end
end
end
@jeremywrowe
jeremywrowe / github_create_download.rb
Created August 19, 2012 06:16
An example of creating a download with the github v3 api
require 'rubygems'
require "net/https"
require "uri"
require "json"
login = ENV['BF_GITHUB_USER']
pass = ENV['BF_GITHUB_PASS']
repos = ENV['BF_GITHUB_REPO']
file_to_upload = 'http/git.ref'
@jeremywrowe
jeremywrowe / gist:3506869
Created August 29, 2012 04:33
highcharts - show label for first and last data points in a series
plotOptions: {
line : {
dataLabels : {
enabled : true,
formatter: function() {
var first = this.series.data[0],
last = this.series.data[this.series.data.length - 1];
if ((this.point.category === first.category && this.point.y === first.y) ||
(this.point.category === last.category && this.point.y === last.y)) {
return this.point.y;
@jeremywrowe
jeremywrowe / gist:3843438
Created October 6, 2012 01:51
Can this be done better?
module Frank
class Sinatra
def self.inherited(subclass)
(@@subclasses ||= []) << subclass
@@subclasses.uniq!
end
def self.for_namespace(filter)
@@subclasses.select{|c| c.to_s.include? filter.to_s }