Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
(defn map-months
[coll]
(if (seq coll)
[(:created_at (first coll) (recur (rest coll)))]
[]))
; Can only recur from tail position
--type-add=ruby=.haml,.bldr
--type-add=js=.coffee
require 'rubygems'
require 'em-proxy'
Proxy.start(:host => '0.0.0.0', :port => 8082, :debug => true) do |conn|
conn.server :one, :host => '127.0.0.1', :port => 8080
conn.server :two, :host => '127.0.0.1', :port => 8081
conn.on_data do |data|
data
end
#!/usr/bin/env ruby
output = `ruby -r bench_press ./benchmark.rb`
results = File.open(File.expand_path(File.dirname(__FILE__)) + "/results.txt", "a") do |f|
f.puts "\n"
f.puts "=" * 80
f.puts "Spec run time: #{Time.now}"
f.puts "Git SHA: #{`cat ../.git/\`cat ../.git/HEAD | awk '{print $2}'\``.chomp}"
f.puts output
@ajsharp
ajsharp / losangeles.craigslist.org.js
Created August 25, 2011 21:39
Craigslist live filtering
// Adds a live filter box to the results screen on craigslist
// that filters the results that are currently on the page by
// the search term. Like Cmd-F, but better.
// NOTE: Requires dotjs.
// Cmd-F live search
var searchBox = $('<input type="text" id="result-search" />')
$("h4.ban:first").before(searchBox)
class Credential
include Mongoid::Document
end
class Credential::Password < Credential
field :password
field :email
end
class User
#!/usr/bin/env ruby
# Usage: land-feature
current_branch = `git branch | grep '\*' | awk '{print $2}'`.chomp
unless current_branch.include?("feature")
puts "You are not current on a feature branch."
exit(1)
end
#!/usr/bin/env ruby
# Usage: cut-release [major|minor|tiny]
current_version = File.read("VERSION").chomp
next_version = current_version.succ
release_type = ARGV[1] || "tiny"
system("git flow release start #{next_version} && rake version:bump:#{release_type}")
/Users/ajsharp/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/Users/ajsharp/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method RSpec::Core::RakeTask#ruby called at /Users/ajsharp/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `ruby'
rake aborted!
stack level too deep
/Users/ajsharp/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:116
require 'rake/dsl_definition'
require 'rake'
include Rake::DSL
desc 'Run all the tests'
task :default => :spec
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new do |t|