Skip to content

Instantly share code, notes, and snippets.

View rubysolo's full-sized avatar

Solomon White rubysolo

View GitHub Profile
# An experiment in higher-order (?) messages in Ruby.
class Message
attr_reader :name
attr_reader :arguments
def initialize(name, *arguments)
@name = name
@arguments = arguments
end
# prerequisites: Ruby 1.9.3, Rails 3.2.something recent
###
### Setup rails app w/haml and opal
###
# create app
rails new opal_test
# add to Gemfile below rails
/*
Newtonian collision checking (draft)
based on the paper: http://www.vobarian.com/collisions/2dcollisions2.pdf
ziggy.jonsson.nyc@gmail.com
*/
if (typeof d3.z != "object") d3.z = {};
(function() {
// Inspired by http://dmitry.baranovskiy.com/work/github/
d3.chart.impact = function() {
var width = 1,
height = 1,
duration = 0,
domain = null,
values = Object,
key = d3_chart_impactKey,
value = d3_chart_impactValue,
sort = null,
mike@rbci:~$ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
1 class Report < ActiveRecord::Base¬
2 attr_accessible :user_id, :evidence, :location, :time, :perpetrator_id, :new_perpetrator, :bounty, :active¬
3 attr_accessor :new_perpetrator¬
4 ¬
5 before_validation :create_new_perpetrator¬
6 ¬
7 belongs_to :perpetrator¬
8 belongs_to :user¬
9 ¬
10 scope :active, where(active: true)¬
@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>