Skip to content

Instantly share code, notes, and snippets.

View emmasteimann's full-sized avatar

Goose Goosington (Emma Steimann) emmasteimann

  • PNF-404
View GitHub Profile
@emmasteimann
emmasteimann / NSString+KBAdditions.h
Created May 23, 2012 14:22 — forked from kevboh/NSString+KBAdditions.h
Making UILabel's adjustsFontSizeToFitWidth and minimumFontSize play nice with multi-lined labels
@interface NSString (KBAdditions)
- (CGFloat)fontSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size minimumFontSize:(CGFloat)minimumFontSize;
@end
@emmasteimann
emmasteimann / zsh.md
Created July 2, 2012 17:24 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu

Install via apt-get

sudo apt-get update && sudo apt-get install zsh

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget –no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O – | sh

and then you change your shell to zsh

# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@emmasteimann
emmasteimann / gist:3050625
Created July 5, 2012 02:15
Open all SQLite files in directory in Base
for i in * ; do file $i; done| grep SQLite | awk '{print "open -a base " $1}' | sed 's/://g' | sh
@emmasteimann
emmasteimann / tetris.clj
Created July 6, 2012 19:58 — forked from alexander-yakushev/tetris.clj
Tetris implementation in Clojure
(ns tetris.core
(:import (java.awt Color Dimension BorderLayout)
(javax.swing JPanel JFrame JOptionPane JButton JLabel)
(java.awt.event KeyListener))
(:use clojure.contrib.import-static deflayout.core
clojure.contrib.swing-utils)
(:gen-class))
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_DOWN VK_UP VK_SPACE)
@emmasteimann
emmasteimann / gist:3081602
Created July 10, 2012 06:35
Find all files with string and copy to another directory
find . -type f -exec grep -q "Emma" '{}' ';' -exec cp '{}' ../emma ';'
@emmasteimann
emmasteimann / gist:3382794
Created August 17, 2012 21:18 — forked from insane-dreamer/gist:523774
access current_user in an Observer
class ApplicationController < ActionController::Base
before_filter :set_current_user
private
def set_current_user
UserActionObserver.current_user = current_user
end
end
class UserActionObserver < ActiveRecord::Observer
# assuming these all have created_by_id and updated_by_id
@emmasteimann
emmasteimann / fibonacci.rb
Created November 1, 2012 01:15
Nth fibonacci (incomplete)
# Given: 8
# Possible solutions -
# a + b = given
# 7 - 1 = 6
# 6 - 2 = 4 # <- subtraction should be less than either
# 5 - 3 = 2
# 4 - 4 = 0 # <- but not equal to 0
#
# Given: 13
# Possible solutions -
@emmasteimann
emmasteimann / heroku.rake
Created November 6, 2012 18:15 — forked from mscottford/heroku.rake
Rake task to restart one heroku web instance every 10 minutes
# Add `gem 'heroku-api', :git => 'https://github.com/heroku/heroku.rb.git'` to your Gemfile
# Set the APP_NAME environment variable to the name of the Heroku app you wish to control.
# Set the HEROKU_API_KEY environment variable to the API key found on the Heroku 'My Account' page.
# You can now create a scheduler instance that runs `bundle exec rake heroku:web:restart` to automate
# restarting workers. The task will select a different web instance every 10 minutes, based on the number of instances that are running.
namespace :heroku
namespace :web do
task :restart do
@emmasteimann
emmasteimann / bot.js
Created November 19, 2012 20:09 — forked from callumacrae/bot.js
Node.js IRC bot
var net = require('net'),
irc = {}, config;
config = {
user: {
nick: '',
user: '',
real: '',
pass: ''
},