Skip to content

Instantly share code, notes, and snippets.

@keighl
keighl / nginx.conf
Created March 1, 2012 16:04
NGINX Configuration / Passenger + Rails
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/USER/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.11;
passenger_ruby /home/USER/.rvm/wrappers/ruby-1.9.2-p290/ruby;
@keighl
keighl / chef_solo_bootstrap.sh
Created June 5, 2012 16:06 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y upgrade
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
@keighl
keighl / gist:3289664
Created August 7, 2012 21:46
CABasicAnimation - tilt into background (a la National Geographic Park Guides)
- (void)dropItBack:(id)sender
{
// Position
CABasicAnimation *posAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
posAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.center.x, self.center.y - 50.f)];
// Opacity
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.5f];
@keighl
keighl / install.sh
Last active December 10, 2015 02:48
Ubuntu 12.04 setup script
# Assumes the current user is your 'deploy' user, and has sudo priveledges.
sudo apt-get -y upgrade;
sudo apt-get -y update;
sudo apt-get -y install git-core;
sudo apt-get -y install python-software-properties;
sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev curl zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libpcre3-dev nodejs openjdk-6-jre libmysqlclient-dev;
# NGINX
sudo add-apt-repository ppa:nginx/stable;
@keighl
keighl / VenuesController.m
Created January 2, 2013 22:21
Alternating UITableViewCell Background Colors
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"VenueCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
@keighl
keighl / hotttness.coffee
Created March 28, 2013 20:32
jQuery plugin boilerplate
"use strict";
methods =
init: (options) ->
$(this).each ->
$self = $(@)
data = $self.data 'hotttness'
settings =
@keighl
keighl / photo_processor.rb
Created October 7, 2013 12:06
Example image manipulation worker from S3 using rmagick and aws-sdk-ruby
require 'RMagick'
class PhotoProcessor
def self.process(entry_id)
entry = Entry.find entry_id
raise "The photo for this entry has already been processed" if entry.image_processed?
class Document: NSDocument {
@IBOutlet var fontSizeField: NSTextField?
dynamic var currentFontSize: CGFloat = 0
override func windowControllerDidLoadNib(aController: NSWindowController) {
super.windowControllerDidLoadNib(aController)
fontSizeField.bind("value",
toObject: self,
withKeyPath: "currentFontSize",
class Document: NSDocument {
@IBAction func fontSizeChanged(sender: NSControl) {
var newSize = CGFloat(sender.floatValue)
if var font = textView?.typingAttributes[NSFontAttributeName] as? NSFont {
font = NSFontManager.sharedFontManager().convertFont(font, toSize: newSize)
applyNewAttributes([NSFontAttributeName: font])
}
}
func applyNewAttributes(attributes: [String: AnyObject]) {
func textViewDidChangeTypingAttributes(notification: NSNotification) {
if let font = textView?.typingAttributes[NSFontAttributeName] as? NSFont {
if let faces = NSFontManager.sharedFontManager().availableMembersOfFontFamily(font.familyName) {
// faces is an array of arrays like this:
// [[Helvetica, Regular, 5, 0], [Helvetica-Light, Light, 3, 0], [Helvetica-Oblique, Oblique, 5, 1], [Helvetica-LightOblique, Light Oblique, 3, 1], [Helvetica-Bold, Bold, 9, 2], [Helvetica-BoldOblique, Bold Oblique, 9, 3]]
fontFacesLabels = faces.map({face in (face[1] as! String)})
}
}
}