Skip to content

Instantly share code, notes, and snippets.

@hamstarr
hamstarr / btct
Last active December 29, 2015 23:18
Dirty wee Bitcoin cli ticker
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
require 'open-uri'
require 'json'
def fetch_ticker
content = open("https://mtgox.com/api/1/BTCUSD/ticker").read
result = JSON.parse(content)
@hamstarr
hamstarr / tunnel.sh
Created October 17, 2012 12:31
tunnel.sh
#!/bin/sh
# tunnel.sh
# Configure
LOCAL_HOST=127.0.0.1;
USERNAME="your_username";
# set your remote address and SSH port.
TUNNEL_PORT="2022"
REMOTE_HOST="my.homedomainorip.com -p $TUNNEL_PORT";
@hamstarr
hamstarr / to_haml.rb
Created October 1, 2012 21:37
Convert Rails Views to HAML
class ToHaml
def initialize(path)
@path ||= path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
`html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}`
end
end
@hamstarr
hamstarr / gist:1285508
Created October 13, 2011 20:59 — forked from willmcneilly/gist:1284697
Hackety hack
/**
* Implementation of moduleName_preprocess_hook().
*
* Replace Drupal core's jquery.js with the new one from jQuery Update module.
*/
function jquery_update_preprocess_page(&$variables) {
// Only do this for pages that have JavaScript on them.
if (!empty($variables['scripts'])) {
// Perform the logic if either jQuery Update's jquery.js is newer than
@hamstarr
hamstarr / rumble.js
Created August 11, 2011 22:43
rumble js
// This jQuery plugin will cause the targeted
// elements to rumble when they are moused over.
(function($) {
// Default config options
$.fn.rumble = function(conf){
var config = $.extend({}, $.fn.rumble.defaults, conf);
// Loop over each of the elements in the jQuery
// stack so that we can set up the properties
// for the individual elements.
return this.each(function(){