Skip to content

Instantly share code, notes, and snippets.

@istro
istro / foobar
Created January 29, 2013 19:32
for(var i = 1; i < number_of_banners; i++ ){
var banner = creativeList[i];
if(Math.abs((client.height+client.width)-(banner.height+banner.width)) < Math.abs((client.height+client.width)-(chosen_banner.height+chosen_banner.width)) && Math.abs(banner.ratio-client.optimal_ratio) < 0.3 ){
chosen_banner = banner;
}
}
gemf_a=`md5 Gemfile`
mig_a=`ls -l ./db/migrate | wc -l`
git pull tapjoy master
gemf_b=`md5 Gemfile`
mig_b=`ls -l ./db/migrate | wc -l`
if [ $mig_a -eq $mig_b ]; then
echo '...your db seems up to date'
fi
@istro
istro / gist:4173321
Created November 30, 2012 02:06
blah
if (condition1) {
alert(1);
}else if (condition2) {
alert(2);
reset();
}else if (condition3) {
alert(3);
reset();
}else{
return true;
@istro
istro / pre-commit
Created November 13, 2012 18:49 — forked from hc5duke/pre-commit
pre-commit hook
#!/usr/bin/env ruby
# copy or symlink this file to .git/hooks/
# automatically strip spaces from the end of lines and add newlines to the end of files as necessary
filetypes = %w(
builder
conf
css
erb
haml
@istro
istro / mountain-lion-brew-setup.markdown
Created September 11, 2012 20:00 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@istro
istro / gist:3310936
Created August 10, 2012 04:02
started tdd-ing schulze voting method... didn't get far, but had fun, stopped during refactoring so it's all broken
require 'rspec'
describe "Schulze" do
before :each do
@ballots = [['q','f','b'],['f','b','q'],['q','f','b']]
@ballots2 = [['f','q','b'],['f','b','q'],['q','f','b']]
@schulze = Schulze.new @ballots
@schulze_twin = Schulze.new @ballots2
end
@istro
istro / list.rb
Created June 28, 2012 04:07
Todo CLI with rspec
module Todo
class List
def initialize(file_path)
@file_path = file_path
@tasks = parse_tasks(File.read(@file_path))
end
def parse_tasks(text)
# we use #collect here so that we will return an array of tasks
text.split("\n").collect do |line|
@istro
istro / in_words.rb
Created June 15, 2012 01:25
in_words in progress
module InWords
def in_words
places=1
num = self
while(num/10 != 0)
places num+= 1
num = num/10
end
if self>1000
@istro
istro / trianglemagic
Created June 14, 2012 03:01
Method to find the type of triangle by the length of three sides
# The problem:
# Write a triangle method that accepts three numbers as arguments. The method should return a print
# whether the three lengths form an equilateral, isosceles, or scalene triangle.
#
# We were just learning to define methods, and having learned if/else statements and touched on
# ternary statements, so we just wanted to make it as concise as we could with our limited knowledge :)
#
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/