Skip to content

Instantly share code, notes, and snippets.

@bkerley
bkerley / ecc.rb
Created June 29, 2011 21:42
ruby ECDSA fun time
# derived from http://h2np.net/tips/wiki/index.php?RubyOpenSSLDigitalSignatureSample
require 'openssl'
require 'base64'
include OpenSSL
group_name = 'secp521r1'
message = '10000 fartbux sent to bryce from a can of beans'
key = PKey::EC.new(group_name)
key = key.generate_key
@bkerley
bkerley / grep_safe.rb
Created November 22, 2010 03:56 — forked from capotej/grep_safe.rb
# turns hey => "[h]ey"
def grep_safe(path)
"[#{path.chars.first}]#{path.chars.to_a.slice(1, path.chars.count).join}"
end
@bkerley
bkerley / .netrc
Created November 18, 2010 13:24
Run this in your shell
machine github.com
login bkerley
password yourpassword
o =
save: ->
if @blank
Telecaster.db.create "INSERT INTO files (name, content) VALUES (?, ?)",
[@name, @content],
(t, r) =>
@id = r.insertId
@blank = false
else
Telecaster.db.update "UPDATE files SET name=?, content=? WHERE id=?",
# wrote it, didn't try it
module TWSS
class Body
def initialize(text)
@text = text
end
def sentences
@text.split(/\?|\.|\;/).map{ |s| Sentence.new(s) }
class Module
def attr_delegate(*methods)
options = methods.pop
paired_attributes = methods.map do |method|
[method, "#{method.to_s}=".to_sym]
end.flatten
paired_attributes.push options
delegate *paired_attributes
end
end
/*
* make pages quit slouching
* javascript:(function(){var s=document.createElement("script");s.charset="UTF-8";s.src="http://gist.github.com/raw/426126/c4214040e3a46679637092818c0a5f7d533516a1/no_slouch.js";document.body.appendChild(s)})();
*/
var a = document.all;
var al = a.length;
for (var i = 0; i < al; i++) {
var t = a[i].style.webkitTransform;
a[i].style.webkitTransform = t.replace(/rotate\(.+?\)/,"");
}

BRYCE'S LESSCONF ROADTRIP

Budget: approx. 20gb

Sound system: TBD, hopefully National has something good tomorrow morning

Note: The greatest care will be taken to isolate conflicting music to prevent unpleasant segues.

  • The Beach Boys, "Pet Sounds"
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class Oembed
def self.call(env)
if env["PATH_INFO"] =~ /^\/oEmbed/
content = OEmbed.transform(env['rack.input'].read(4096)) do |r, url|
r.rich? { |h| "<div class='embed'>#{h['html']}</div>" }
r.photo? { |p| "<img src='#{p["url"]}' alt='#{p["title"]}' />" }
r.video? { |v| "<div class='video'>#{v['html']}</div><!-- #{v.inspect} -->" }

THE CANONICAL LIST OF HIPSTER-APPROVED JOBS

  1. Professional blogger or "web producer"
  2. Barista
  3. Bicycle messenger
  4. Baker
  5. Freelance photographer
  6. Unemployed