Skip to content

Instantly share code, notes, and snippets.

require "test/unit"
class TestFizzBuzz < Test::Unit::TestCase
def fizzbuzz(x)
"#{'Fizz' if x % 3 == 0}#{'Buzz' if x % 5 == 0}"
end
def test_equal
assert_equal fizzbuzz(3), "Fizz"
assert_equal fizzbuzz(50), "Buzz"
[2012-04-10 09:02:35] autoreconf
Can't exec "aclocal": No such file or directory at /Users/millsb/.rvm/usr/share/autoconf/Autom4te/FileUtils.pm line 325.
autoreconf: failed to run aclocal: No such file or directory
@remear
remear / viewWillDisappear.m
Created March 26, 2012 16:33
How viewWillDisappear
- (void)viewWillDisappear:(BOOL)animated {
NSArray *viewControllers = self.navigationController.viewControllers;
if (viewControllers.count > 1 && [viewControllers objectAtIndex:viewControllers.count-2] == self) {
// View is disappearing because a new view controller was pushed onto the stack
NSLog(@"New view controller was pushed");
} else if ([viewControllers indexOfObject:self] == NSNotFound) {
// View is disappearing because it was popped from the stack
NSLog(@"View controller was popped");
}
}
from tkinter import *
from tkinter import ttk
def calculate(*args):
try:
value = float(feet.get())
meters.set((0.3048 * value * 10000.0 + 0.5)/10000.0)
except ValueError:
pass
@remear
remear / eunic
Created February 9, 2012 23:10 — forked from pjammer/eunic
i put this into /usr/local/bin/eunic and you can your server using eunic -s && eunic -N
#!/bin/bash
set -u
set -e
#change this below to your actual path. If you another environemnt like staging, fucking change N to -e staging instead.
APP_PATH=/youpath/to/app/root
PID=$APP_PATH/tmp/pids/unicorn.pid
OLD_PID=$APP_PATH/tmp/pids/unicorn.pid.oldbin
UNICORN_COMMAND="unicorn_rails -c $APP_PATH/config/unicorn.rb -D"
while getopts ":nsNr" opt; do
@remear
remear / gist:1724911
Created February 2, 2012 18:09 — forked from akitaonrails/gist:1724673
Fixing Apachebench on OS X Lion
# If you're getting this error trying to use ApacheBench on OS X Lion:
# Benchmarking mwmanning.com (be patient)...apr_socket_recv: Connection reset by peer (54)
#
# You need to download the latest beta version of Apache and rebuild ab.
# Here's how (assuming you have homebrew installed).
# Install Homebrew (https://github.com/mxcl/homebrew) and then the Perl Regex support
brew install pcre
# Download the latest from http://httpd.apache.org/download.cgi, then decompress and compile it
@remear
remear / gist:1672746
Created January 24, 2012 21:13 — forked from seanlilmateus/gist:1536136
macruby core animation Fireworks, have a nice macruby new year
#!/usr/local/bin/macruby
framework 'Cocoa'
framework 'QuartzCore'
class FireworkDelegate
attr_accessor :window
def initWithURL(url)
case url
when String
@firework_photo_url = NSURL.URLWithString(url)
Removing /Users/millsb/.rvm/src/ruby-1.9.2-head...
it seems that /Users/millsb/.rvm/rubies/ruby-1.9.2-head is already non existent.
Removing ruby-1.9.2-head aliases...
Removing ruby-1.9.2-head wrappers...
Removing ruby-1.9.2-head environments...
Removing ruby-1.9.2-head binaries...
Installing Ruby from source to: /Users/millsb/.rvm/rubies/ruby-1.9.2-head, this may take a while depending on your cpu(s)...
ruby-1.9.2-head - #fetching
HEAD is now at 8b75c2f * doc/ChangeLog-1.9.3, test/gdbm/test_gdbm.rb: fixed mingw typo.
Installing Ruby from source to: /Users/millsb/.rvm/rubies/ruby-1.9.2-head, this may take a while depending on your cpu(s)...
ruby-1.9.2-head - #fetching
HEAD is now at 8b75c2f * doc/ChangeLog-1.9.3, test/gdbm/test_gdbm.rb: fixed mingw typo.
From git://github.com/ruby/ruby
* branch ruby_1_9_2 -> FETCH_HEAD
Already up-to-date.
Copying from repo to src path...
Applying patch '/Users/millsb/.rvm/patches/ruby/fix-irb-completion.diff' (located at //Users/millsb/.rvm/patches/ruby/fix-irb-completion.diff)
ERROR: Error running 'patch -F 25 -p1 -N -f <"//Users/millsb/.rvm/patches/ruby/fix-irb-completion.diff"', please read /Users/millsb/.rvm/log/ruby-1.9.2-head/patch.apply.fix-irb-completion.diff.log
+ [[ -n '' ]]
+ export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ PS4='+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ /scripts/cli : __rvm_parse_args() 746 > [[ -z '' ]]
+ /scripts/cli : __rvm_parse_args() 746 > [[ -n '' ]]
+ /scripts/cli : __rvm_parse_args() 748 > [[ 0 -eq 1 ]]
+ /scripts/cli : __rvm_parse_args() 748 > [[ -n '' ]]
+ /scripts/cli : __rvm_parse_args() 19 > [[ -n install ]]
+ /scripts/cli : __rvm_parse_args() 21 > rvm_token=install
+ /scripts/cli : __rvm_parse_args() 23 > (( 8 > 0 ))