Skip to content

Instantly share code, notes, and snippets.

View rubysolo's full-sized avatar

Solomon White rubysolo

View GitHub Profile
@rubysolo
rubysolo / tasks_controller_refactoring.rb
Created November 12, 2012 21:28 — forked from blowmage/tasks_controller_refactoring.rb
Variation of RubyTapas episode "021 Domain Model Events" without using callbacks
class TasksController < ApplicationController
def update
if @task.update_attributes(params[:task])
tracker = TaskTracker.new(@task.previous_changes)
TaskPusher.new(tracker, socket_id).push_changes
TaskMailSender.new(tracker, current_user).deliver_email
# success response
else
# failure respond
end
@rubysolo
rubysolo / README.txt
Created October 24, 2012 16:08 — forked from i-scorpion/README.txt
Twitter bootstrap fixed table header using jQuery
Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<table class="table-fixed-header">
<thead class="header">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
# encoding: binary
# Removes any bytes from a string that are not valid UTF-8
class Cleaner
attr_reader :bytes, :buffer, :outstanding
def self.clean(str)
new.tap { |c| c << str }.to_s
end
@rubysolo
rubysolo / preso.md
Created August 10, 2012 02:19 — forked from jamesward/preso.md
Den of Clojure

Heroku @ Den of Clojure


About James Ward

Java Developer since: 1997 >

@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
@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
@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.
#