Skip to content

Instantly share code, notes, and snippets.

View piersadrian's full-sized avatar

Piers Mainwaring piersadrian

View GitHub Profile
@piersadrian
piersadrian / gitsync.sh
Created December 14, 2011 21:54
Automating Git with Gitsync
#!/bin/bash
# Gitsync sychronizes Git's origin repository to the local copy by
# first fetching all changes, presenting a simple diff of the changes,
# then asking for confirmation before merging the changes into the
# local branch and pushing changes.
#
# Thanks to Aaron Crane (http://aaroncrane.co.uk/2009/03/git_branch_prompt/)
#
# Author: Piers Mainwaring.
# License: Public Domain (no rights reserved)
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
@piersadrian
piersadrian / cookie_jar_fix.gemspec
Created November 5, 2012 18:08 — forked from jodosha/cookie_jar_fix.gemspec
Support cookie jar options for all cookie stores
@piersadrian
piersadrian / unicorn.rb
Created November 19, 2012 04:37 — forked from jamiew/unicorn.rb
Unicorn config for use with bundler and capistrano - fixes issues with environment pollution.rb
# My pimped out unicorn config, with incremental killof
# and all the latest capistrano & bundler-proofing
# @jamiew :: http://github.com/jamiew
application = "000000book.com"
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production'
app_path = "/srv/#{application}"
bundle_path = "#{app_path}/shared/bundle"
timeout 30
@piersadrian
piersadrian / es.sh
Created November 26, 2012 22:23
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.0.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@piersadrian
piersadrian / changes.md
Created December 11, 2012 02:20 — forked from funny-falcon/changes.md
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

UIButton *fetchButton = ^(NSString *labelText, CGFloat scalar, UIButtonType type, CGPoint origin) {
UIButton *button = [UIButton buttonWithType:type];
UILabel *label = [[UILabel alloc] init];
[label setText:labelText];
CGSize buttonFrameSize = CGSizeMake([label.text sizeWithFont:label.font].width * scalar * 0.66f,
[label.text sizeWithFont:label.font].height * scalar);
[self.tabBarController.view setFrame: CGRectMake([[UIScreen mainScreen] applicationFrame].origin.x,
[[UIScreen mainScreen] applicationFrame].origin.y,
[[UIScreen mainScreen] applicationFrame].size.width,
[[UIScreen mainScreen] applicationFrame].size.height - self.tabBarController.tabBar.frame.size.height)];
before_filter :validate_request_format
# ...
def send_response data
respond_with(data) do |format|
format.js { render json: data, callback: params[:callback] } # JSONP
format.json { render }
format.xml { render }
end
array = response['equipmentItems'];
parentElement = $('select')[0];
for (var i = 0; i < array.count; i++) {
currentObj = array[i];
newElement = document.createElement('option');
newElement.value = currentObj.someAttribute;
newElement.innerText = "Some Label";