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 / NSString+Extras.m
Created December 19, 2012 13:37
Secure API Request From iOS to Rails
#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
@interface NSString (Extras)
+ (NSString *)authSignatureWithToken:(NSString *)token;
@end
@implementation NSString (Extras)
@keighl
keighl / application.rb
Created December 19, 2012 16:42
Faster Rails asset precompilation via Capistrano .. just do it locally!
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@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 / foooont.sh
Last active December 9, 2021 14:00
Rename a font to have the same Family/Fullname/Postscript name. This prevents IE from choking in @font-face
# FontForge command
fontforge -script 2ttf.pe ProprietaryFontCondensedBold.otf
# 2ttf.pe
# FontForge Script
# http://fontforge.org/scripting.html
#
# * Opens the font file
# * Sets the family/fullname/postscript name be the same as the filename (without ext)
@keighl
keighl / CBGameController.m
Last active September 1, 2018 17:24
SDWebImage in a UITableViewCell - cancel any download operation before reusing the cell. Otherwise, you might see previous images loading in before the correct one is finished downloading.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"MoveViewCell";
CBMoveView *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell)
cell = [[CBMoveView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.move = (CBMove *)[self.moves objectAtIndex:indexPath.row];