Skip to content

Instantly share code, notes, and snippets.

View benschwarz's full-sized avatar
🏁
Making the web fast

Ben Schwarz benschwarz

🏁
Making the web fast
View GitHub Profile
desc "Reset and run test suite"
task :ci => ["environment:force:test", "gems:install", :environment] do
Rake::Task["db:reset"].invoke
Rake::Task["db:bootstrap"].invoke
Rake::Task["spec"].invoke
end
# For protecting production
namespace :environment do
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.gem 'postie', :lib => 'postie'
config.middleware.use 'Postie::Application'
end
postcodes = FasterCSV.read(data_source_for("postcodes.csv"))
postcodes.each do |(post_code, name, state_name, _, _, _, _, _, _, category)|
if category.squish == "Delivery Area"
post_code = sprintf("%04d", post_code.to_i)
state = State.find_or_create_by_name(state_name)
Locality.create(:post_code => post_code, :name => name, :state => state)
end
end
module Locality::Search
def self.included(base)
base.class_eval do
class << self
def search(criteria)
logger.debug("search")
results = find_all_by_name(criteria)
if results.empty?
require 'postie'
use Postie::Application
# Usage
require 'hookr'
class A
include Hookr
def b
puts "bee"
end
# The only working install (on mac) I can get to run of libmemcached and e.weaver's memcached gem
wget http://blog.evanweaver.com/files/libmemcached-0.25.14.tar.gz
tar -xzvf libmemcached-0.25.14.tar.gz
cd libmemcached-0.25.14
./configure && make && make install
wget http://blog.evanweaver.com/files/memcached-0.13.gem
sudo gem install memcached-0.13.gem
// Found on my desktop from early 07'
// JSON ActiveResource - REST Implementation
/*
Example of use.
new Model('User');
var myUser = User.find(12);
myUser.name = 'Benjamin';
myUser.save;
# Download images from ffffound and add to random desktop images.
# Install:
# Add to cron
# Create "FFFFound" directory in ~/Pictures/
# Happiness ensues
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
# Rails app generator
# Remove unnecessary Rails files
run 'rm README'
run 'rm public/index.html'
run 'rm public/favicon.ico'
run 'rm public/images/rails.png'
# Copy database.yml
run 'cp config/database.yml config/database.yml.example'