View this code at http://livecoding.io/5814072
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)¬ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |