Skip to content

Instantly share code, notes, and snippets.

@squarism
squarism / em_skel.rb
Created January 7, 2012 00:02
eventmachine_skeleton
# Gemfile
source "http://rubygems.org"
gem 'eventmachine'
gem 'em-net-http'
gem 'em-http-request', "=1.0.0.beta.4"
gem 'em-mysql', "=0.4.2"
# server.rb
@squarism
squarism / pentatonics.txt
Created January 25, 2012 19:56
Zedshaw riffs on pentatonics
@zedshaw
I was up 'till 3:30am last night because I had figured out something incredibly cool about music on the
guitar. If you take the intervals in major pentatonics you get:
C D E G A C = ww(m3)wm3 so Whole Whole (minor3) Whole Minor3.
So a minor pentatonic is the same intervals, just shuffled over:
ACDEGA = m3 w (w) m3 w
Same interval setup, which makes sense. Now, if you do the same thing with a 5 note dominant arpeggio
you get:
@squarism
squarism / wtf_computers.md
Last active May 23, 2016 22:20
WTF Computers

All my wtf momements, Ruby or otherwise.

# having a wat moment here in ruby
0 <=> 1
# => -1  (left is less, or another way to think of it, 
# the argument 1 is less than 0)

"0" <=> "1"
# => -1
@squarism
squarism / .irbrc
Created February 7, 2012 21:09
new irbrc
# *****************************************
# .irbrc
#
# Includes lots of nice stuff to make
# your irb and script/console ruby shell
# more pretty and productive
#
# *****************************************
@squarism
squarism / backbone_noob.js
Created February 20, 2012 19:30
backbone noob
(function($) {
// i hate globals too but this is all that works
window.Album = new (Backbone.Model.extend({
defaults: {
foo: "bar"
}
}));
})(jQuery);
@squarism
squarism / nodejitsu_auth.txt
Created July 13, 2012 20:44
Nodejitsu AuthN awesomeness
box ~ > npm install jitsu -g
/usr/local/bin/jitsu -> /usr/local/lib/node_modules/jitsu/bin/jitsu
box ~ > jitsu
info: Welcome to Nodejitsu
info: It worked if it ends with Nodejitsu ok
info: Executing command
help: ___ __
help: / / / /_ / /
help: __/ / / __/ /__/
@squarism
squarism / serialize_mongoid_form.rb
Created July 27, 2012 17:07
serialize rails form to mongoid or json
require 'pp'
# this is what the rails POST form params look like
have = {
"concert"=>"yanni",
"description"=>"an epic soundscape about oceans and stuff",
"set_list"=>{
"0"=>{
"set_list"=>"opener",
"energy"=>"high",
@squarism
squarism / watch_queue
Created August 4, 2012 04:47
Netflix Watch Queue
# all are on instant streaming
# from Eric Macks http://ericmackattacks.wordpress.com/2011/01/06/100-good-movies-available-to-watch-instantly-on-netflix-january-edition/
The Battleship Potemkin (1925, Sergei M. Eisenstein)
The Gold Rush (1925, Charles Chaplin)
The General (1926, Clyde Bruckman/Buster Keaton)
Man with the Movie Camera (1929, Dziga Vertov)
The Rules of the Game (1939, Jean Renoir)
Stagecoach (1939, John Ford)
The Pride of the Yankees (1942, Sam Wood)
@squarism
squarism / nginx.sh
Created August 20, 2012 03:33
Ubuntu 12.04 Nginx init.d script
#!/bin/bash
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@squarism
squarism / deploy.rb
Created August 21, 2012 01:37
Capistrano with zsh + nginx + passenger + rbenv
# Here's what you can do with this capistrano setup:
# > cap staging deploy:setup
# > cap staging deploy
# (create your database by hand)
# > cap staging deploy:migrate
# this is specific to my app because my fixtures are my seeds :(
# > cap staging fixtures
# same commands above with production: