Skip to content

Instantly share code, notes, and snippets.

View rubysolo's full-sized avatar

Solomon White rubysolo

View GitHub Profile
@rubysolo
rubysolo / graphite.md
Created August 9, 2012 17:38 — forked from caged/graphite.md
Installing Graphite on OS X Lion

This is a general overview (from memory) of the steps I used to install graphite (http://graphite.wikidot.com) on OS X Lion. I think the steps are in order but YMMV. Please fork and fix if you find an error.

Install Python 2.7.2

brew install python

Check your env

$ python --version
@rubysolo
rubysolo / gist:3219684
Created July 31, 2012 19:16 — forked from swannodette/gist:3217582
sudoku_compact.clj
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [grid x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in grid [x y])))
(defn init [grid [pos value]]
@rubysolo
rubysolo / .rspec
Created July 25, 2012 14:26 — forked from coreyhaines/.rspec
Loading just active record
--colour
-I app
require 'debugger'
class Node
def to_s
"new hotness"
end
end
class Module
def method_added(method_id)
@rubysolo
rubysolo / offline-backup.coffee
Created June 20, 2012 15:45
use localStorage to store form datas
class OfflineBackup
constructor: ->
@pendingRequests = JSON.parse(localStorage.getItem('offline-backups') || '[]')
$('form.offline-backup').on 'submit', @submitForm
window.addEventListener 'online', @submitPendingRequests
submitForm: (e) ->
unless navigator.onLine
method = $(this).find('input[name=_method]').val() || $(this).attr('method') || 'get'
@rubysolo
rubysolo / README.markdown
Created June 2, 2012 21:00 — forked from rn0/README.markdown
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is an extension to Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
class Module
def method_added(method_id)
if method_id == :application
puts "-" * 80
puts "HAX0RED!"
puts caller.join("\n")
puts "=" * 80
end
end
end
@rubysolo
rubysolo / gist:2495740
Last active October 3, 2015 17:38 — forked from sbellware/gist:728575
Syntactic Sugar to Mimic Assert-Arrange-Act in RSpec 2 Without Test Spies
# sample class to mock and test against
class Thing
def foo
bar
end
def bar
end
end
@rubysolo
rubysolo / gist:2430067
Created April 20, 2012 16:16 — forked from marcel/gist:2100703
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@rubysolo
rubysolo / non-match.rb
Created April 3, 2012 20:53
negative lookahead match
irb(main):003:0> r = %r{href="(?!(/|#|mailto))}
=> /href="(?!(\/|#|mailto))/
irb(main):004:0> r =~ 'href="http://foo.com"'
=> 0
irb(main):005:0> r =~ 'href="/root"'
=> nil
irb(main):006:0> r =~ 'href="#anchor"'
=> nil
irb(main):007:0> r =~ 'href="mailto:[email protected]"'
=> nil