This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ExtendNumericRounding | |
def roundup(nearest=10) | |
self % nearest == 0 ? self : self + nearest - (self % nearest) | |
end | |
def rounddown(nearest=10) | |
self % nearest == 0 ? self : self - (self % nearest) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in `git branch -r`; do j=`echo $i|sed 's/\//_/'`; git checkout -b $j --track $i; done | |
# git checkout -b origin_master --track origin/master | |
# git checkout -b origin_topic_branch --track origin/topic_branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation InstaMenuAppDelegate | |
@synthesize menuController; | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | |
if (!menuController) | |
menuController = [SCMenuController new]; | |
} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open xcode projects named after the folder you're in | |
alias xcode='open `pwd | sed -e "s/^\/.*\///g"`.xcodeproj' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
TESTS = 1_000_000 | |
Benchmark.bm do |results| | |
results.report do | |
TESTS.times do | |
"Br1ghtBox"[/[A-Za-z0-9]+/] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What I usually do | |
a = [] | |
5.times { a << "thing" } | |
a # => ["thing", "thing", "thing", "thing", "thing"] | |
# The "ruby" way to do it | |
Array.new(5) { "thing" } # => ["thing", "thing", "thing", "thing", "thing"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "module_include" | |
require "time_extend" | |
Time.now.foobar # => "foobar" | |
# >> "Include called at ./time_extend.rb:7" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This gives you the following prompt: | |
# Julius:my-project(910-form)[1] caius$ | |
# Julius == hostname | |
# my-project == current folder | |
# (910-form) == git branchname (shows nothing when not in git repo) | |
# [1] == git stash count (shows nothing when not in git repo or there aren't any stashes) | |
# caius == current user | |
# $ == non-root shell | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I'd expect every line here to raise a NameError, but the 2nd expression doesn't. | |
a # ~> -:1: undefined local variable or method `a' for main:Object (NameError) | |
b = b # => nil | |
c = d # ~> -:1: undefined local variable or method `d' for main:Object (NameError) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Julius:local(masterbrew) caius$ brew install glib | |
==> Downloading http://ftp.acc.umu.se/pub/gnome/sources/glib/2.20/glib-2.20.5.tar.bz2 | |
File already downloaded and cached | |
==> ./configure --disable-debug --prefix=/usr/local/Cellar/glib/2.20.5 --disable-dependency-tracking --disable-rebuilds | |
==> make | |
Exit code: 512 | |
cd . && /bin/sh ./config.status glibconfig.h | |
config.status: executing glibconfig.h commands | |
config.status: glibconfig.h is unchanged | |
echo timestamp > stamp-gc-h |