Skip to content

Instantly share code, notes, and snippets.

@localshred
localshred / app.js
Created November 10, 2010 06:48
Experimentations in sinatra-style node.js
var util = require('util'),
http = require('http'),
router = require('./router');
console.log('creating server');
var app = http.createServer();
console.log('registering app');
router.registerApp(app);
require 'rubygems'
require 'bundler/setup'
require 'my_private_gem/deploy'
# Configure loudmouth
MyPrivateGem::Deploy.configure(:application1)
$ cap sand hostname /code/src/application1
/Users/bj/.rvm/gems/ruby-1.9.2-p0@application1/gems/capistrano-2.5.19/lib/capistrano/configuration/loading.rb:18:in `instance': Please require this file from within a Capistrano recipe (LoadError)
from /Users/bj/.rvm/gems/ruby-1.9.2-p0@application1/gems/my_private_gem-0.1.2/lib/my_private_gem/deploy.rb:15:in `configure'
from ./config/deploy.rb:6:in `load'
from /Users/bj/.rvm/gems/ruby-1.9.2-p0@application1/gems/capistrano-2.5.19/lib/capistrano/configuration/loading.rb:93:in `instance_eval'
from /Users/bj/.rvm/gems/ruby-1.9.2-p0@application1/gems/capistrano-2.5.19/lib/capistrano/configuration/loading.rb:93:in `load'
from /Users/bj/.rvm/gems/ruby-1.9.2-p0@a
@localshred
localshred / RelativeDateUtil.as
Created March 24, 2011 20:09
Relative dates in flex
package Assets.Applications.Includes
{
import com.adobe.utils.DateUtil;
public class RelativeDateUtil extends DateUtil
{
public static var SECONDS_IN_MINUTE:Number = 60;
public static var MINUTES_IN_HOUR:Number = 60;
public static var HOURS_IN_DAY:Number = 24;
@localshred
localshred / averages.txt
Created June 16, 2011 18:30
Team Averages
ragnar
------
Days Working ->
total: 800
average: 160
Days Alive ->
total: 56799
average: 11359
@localshred
localshred / output.txt
Created June 30, 2011 23:22
Checks the number of iterations necessary to determine max # of inputs on a line with a fixed length
Determining how many ip elements can sit on a line with a max length of 1000
lower | mid/test | upper | len | over/under
--------------------------------------------------------------
1 | 50 | 100 | 840 | under
50 | 75 | 100 | 1240 | over
50 | 62 | 75 | 1032 | over
50 | 56 | 62 | 936 | under
56 | 59 | 62 | 984 | under
59 | 60 | 62 | 1000 | under
@localshred
localshred / bit_magic.rb
Created July 14, 2011 21:42
Generate a byte string of bits to show pass fail for a project
projects = ['f','p','p','f','p','p','f','p','p','f']
bytes = []
projects.each_slice(4) do |chunk|
byte = 0
chunk.each{ |v| byte = (byte << 2) | (v == 'p' ? 1 : 2) }
byte = byte << ((4 - chunk.size) * 2) if chunk.size < 4
bytes << byte
puts '%s %s %s' % [chunk, byte.chr, byte.chr.unpack("B*")]
end
byte_str = bytes.map{|b| b.chr }.join
@localshred
localshred / sivers.md
Created October 1, 2011 06:25
My own notes from Derek Sivers 6 part video series on business
@localshred
localshred / .gitconfig
Created October 6, 2011 16:10
My ~/.gitconfig file
[core]
editor = vi
[color]
status = auto
interactive = auto
grep = auto
branch = auto
diff = auto
[alias]
st = status
@localshred
localshred / app.rb
Created November 22, 2011 20:41
Container objects that act like hashes with pre-definable keys.
# Just a sample, obviously very rudimentary but you get the idea
require 'sinatra'
require 'json'
require 'lib/container/base'
class User < Container::Base
attr_accessor :guid
attr_accessor :name
attr_accessor :email