Skip to content

Instantly share code, notes, and snippets.

View jqr's full-sized avatar

Elijah Miller jqr

View GitHub Profile
@jqr
jqr / sublime.json
Created November 14, 2013 02:02
Sublime settings
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Theme - Aqua/Color Schemes/Tomorrow Aqua.tmTheme",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
package main
import (
"fmt"
"net"
"bufio"
"time"
)
const apiKey string = "your api key"
{
"git_binary": "/usr/local/bin/git"
}
@jqr
jqr / cassandra.whirr
Created November 30, 2012 19:05
cassandra whirr config
whirr.identity = ...
whirr.credential = ...
whirr.provider = aws-ec2
whirr.private-key-file=${sys:user.home}/.ssh/ff
whirr.public-key-file=${whirr.private-key-file}.pub
whirr.cluster-name=cassandra
whirr.instance-templates=10 cassandra
@jqr
jqr / tiny_id.rb
Created April 12, 2012 18:42
Encode/decode numbers as tiny strings
class TinyId
# All characters that URL encode to 1 character in size, minus the
# period which requires special Rails routing:
# (0..255).map(&:chr).select { |c| ERB::Util::u(c).size == 1 } - ['.']
RAILS_URL = %w(- 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z)
# All BSON encodable string characters
BSON_STRING = (1..127).map(&:chr)
def initialize(alphabet)
@jqr
jqr / reader.rb
Created February 24, 2012 01:53
Locking log rotation for processing
require 'fileutils'
class Reader
def self.read(filename, processing_filename)
return [] unless File.exists?(filename)
FileUtils.move(filename, processing_filename)
lines = []
File.open(processing_filename, 'r') do |f|
f.flock(File::LOCK_EX)
while !f.eof?
@jqr
jqr / README.md
Created February 7, 2012 03:23
ZeroMQ push/pull example

For fun, try running client before the server.

@jqr
jqr / invitation.rb
Created February 6, 2012 18:04
Instrumental Invitation
class Invitation < ActiveRecord::Base
belongs_to :project
belongs_to :invited_by, class_name: 'User'
belongs_to :invited, class_name: 'User'
before_create :set_token
before_create :auto_accept
after_create :send_email
def set_token
@jqr
jqr / case_input.rb
Created December 22, 2011 14:40
Example of using a case statement with params in Sinatra
require 'sinatra'
get '/' do
case params[:input]
when 'hello'
'ahoy'
when 'goodbye'
'seeya'
else
'eh?'
$ strobe login
Please enter your Strobe username and password.
Email: elijah.miller@gmail.com
Password:
Unfortunately, a fatal error has occurred. Please report this error to Strobe Support at http://support.strobeapp.com/home so that we can fix it. Thanks!
/usr/local/strobe/bundle/ruby/1.9.1/gems/activesupport-3.0.10/lib/active_support/json/backends/yajl.rb:12:in `parse': input must be a string or IO (Yajl::ParseError)
from /usr/local/strobe/bundle/ruby/1.9.1/gems/activesupport-3.0.10/lib/active_support/json/backends/yajl.rb:12:in `decode'
from /usr/local/strobe/bundle/ruby/1.9.1/gems/activesupport-3.0.10/lib/active_support/json/decoding.rb:14:in `decode'
from /usr/local/strobe/lib/strobe/connection.rb:70:in `body'
from /usr/local/strobe/lib/strobe/connection.rb:83:in `validate!'