Skip to content

Instantly share code, notes, and snippets.

View jaikoo's full-sized avatar
🗻
Working

Jonathan Conway jaikoo

🗻
Working
View GitHub Profile
@jaikoo
jaikoo / gist:112203
Created May 15, 2009 13:04
some really old and hacky padding code
def calculate_padding(current_size, target_size)
return nil if current_size <= target_size
diff = current_size - target_size
return nil if diff < 0
while diff%4 != 0
target_size = target_size -1
diff = current_size - target_size
end
p = (diff/2).to_i
return [ target_size, p, p ]
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <[email protected]>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
app/models/widget.rb | 2 ++
config.ru | 1 +
#!/bin/bash
# Kill all my running EC2 instances at Amazon AWS - all regions
. ~/.ec2/env
cat <<EOF | while read EC2_URL
https://eu-west-1.ec2.amazonaws.com
https://ec2.us-east-1.amazonaws.com
https://ec2.us-west-1.amazonaws.com
https://ec2.ap-southeast-1.amazonaws.com
EOF
do
@jaikoo
jaikoo / generate_markets.rb
Created August 25, 2011 12:30 — forked from mbleigh/generate_markets.rb
The model and generation code to pull the 100 biggest US cities out as geographical models for a Rails app.
# Data culled from Wikipedia. Could be cleaner, but this is nice and simple.
major_cities = [["New York", "New York"], ["Los Angeles", "California"], ["Chicago", "Illinois"], ["Houston", "Texas"], ["Philadelphia", "Pennsylvania"], ["Phoenix", "Arizona"], ["San Antonio", "Texas"], ["San Diego", "California"], ["Dallas", "Texas"], ["San Jose", "California"], ["Jacksonville", "Florida"], ["Indianapolis", "Indiana"], ["San Francisco", "California"], ["Austin", "Texas"], ["Columbus", "Ohio"], ["Fort Worth", "Texas"], ["Charlotte", "North Carolina"], ["Detroit", "Michigan"], ["El Paso", "Texas"], ["Memphis", "Tennessee"], ["Baltimore", "Maryland"], ["Boston", "Massachusetts"], ["Seattle", "Washington"], ["Washington", "District of Columbia"], ["Nashville", "Tennessee"], ["Denver", "Colorado"], ["Louisville", "Kentucky"], ["Milwaukee", "Wisconsin"], ["Portland", "Oregon"], ["Las Vegas", "Nevada"], ["Oklahoma City", "Oklahoma"], ["Albuquerque", "New Mexico"], ["Tucson", "Arizona"], ["Fresno", "California"], ["Sacrame
@jaikoo
jaikoo / computed_property_model.coffee
Created January 28, 2012 11:43
Basic Ember.js Model
App.UserSignUpModel = Em.Object.extend
name: null
email: null
isValidEmail: () ->
validEmailRegex = new RegExp ”^[0-9a-zA-Z]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$”
validEmailRegex.test(@get('email'))
.property('email')
@jaikoo
jaikoo / 0-readme.md
Created January 31, 2012 17:47 — forked from burke/0-readme.md
ruby-1.9.3-p0 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

@jaikoo
jaikoo / gist:1780144
Created February 9, 2012 13:58
Jenkins - Build - Execute Shell
#!/bin/bash
read -d '' database_yml <<"EOF"
login: &login
adapter: mysql2
host: localhost
username: root
encoding: utf8
collation: utf8_general_ci
test: &test
@jaikoo
jaikoo / es.sh
Created May 1, 2012 09:25 — forked from aaronshaf/es.sh
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get update
sudo apt-get install unzip curl python-software-properties -y
#sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.3.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz