Skip to content

Instantly share code, notes, and snippets.

#! /usr/local/bin/ruby
# First stab at a svn log watcher for user ohnojoe.
# SvnRecord also allows you to easily extend the script to match on certain file names/package names
# that you want to watch.
SVN_CMD = 'svn log -l 30 -v https://my.svn.server.com/Project/branches/'
FILE_MATCH = '\/branches\/.*'
USERS_WATCHED = %w{ ohnojoe }
require 'rubygems'
require 'mechanize'
require 'ap'
require 'logger'
ISHARES_URL = "http://us.ishares.com/product_info/fund/overview/"
RESOURCE = ".htm"
@tickers = ['IVV', 'IGE', 'IWV', 'IWB', 'IWR', 'IYR', 'IYT', 'IYM', 'IYE', 'SLV']
@small_cap_tickers = ['JKJ', 'JKK', 'JKL', 'IWO', 'IWM', 'IWN', 'IWC', 'IJT', 'IJR', 'IJS']
def parse_command( command_ary )
o = ""
command_ary.each do |l|
o = o + l.slice(60..-1).chomp
end
o.gsub!('><', ">\n<")
o_ary = o.split("\n")
@gnarl
gnarl / phonegap example
Created June 24, 2011 14:31
onDeviceReady
function onDeviceReady()
{
console.log('********************************* onDeviceReady');
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
}
function onBodyLoad()
{
console.log('********************************* onBodyLoad');
@gnarl
gnarl / snmp_test.rb
Created June 30, 2011 16:59
When Integer is not a Duck
require 'rubygems'
require 'snmp'
include SNMP
def snmp_get( oid )
varbind = VarBind.new(oid)
response = @manager.get([varbind])
response.each_varbind do |vb|
@gnarl
gnarl / manimal.js
Created July 29, 2011 20:15
JavaScript Prototypes
var man = (function() {
var m_that = {};
var photo_prototype = function(spec, my) {
var that = {};
var my = my || {};
that.obj_name = "photo_proto";
var get_name = function () {
@gnarl
gnarl / unzip.rb
Created August 22, 2011 19:55
Unzip nested zip files to directories named after the zip filename.
require 'fileutils'
def unzip_dir(dir)
FileUtils.cd(dir)
top = Dir['*.zip']
top.each do |x|
if x.match(/.*\.zip\Z/)
begin
#puts "unzipping " + x
@gnarl
gnarl / javascriptCompositionMixin.js
Created September 27, 2011 17:11
Mixin public functions of an Object to current Object.
var mixinObjectFunctions = function(obj) {
for( var propName in obj) {
if(solContext.hasOwnProperty(propName)) {
if(typeof obj[propName] === 'function') {
that[propName] = obj[propName];
console.log("that." + propName + " : " + typeof that[propName]);
}
}
}
};
@gnarl
gnarl / itunes_service
Created November 11, 2011 03:52
My Sun Eyed Girl
# itunes_service.rb
require 'sinatra'
require 'json'
require './applay'
get '/music/play' do
ItunesAppScript.new.play
end
@gnarl
gnarl / palindrome_test.rb
Created February 29, 2012 18:07
ruby unit test example
require 'test/unit'
require 'palindrome'
require 'awesome_print'
class PalindromeTest < Test::Unit::TestCase
SAS_P = "sas"
def setup
end