This file contains 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
#!/usr/bin/env ruby | |
# Usage: | |
# gitdb copy | |
# Copies the current development database into db/branchname-development.sqlite3 | |
# gitdb | |
# Copies the db/branchname-development.sqlite3 into the default db/development.sqlite3 | |
branch = `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'`.gsub('* ','').strip |
This file contains 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
# Usage: | |
# ruby bulk_domain_generator.rb word [word...] | |
suffixes = ['able','ac','acity','ade','age','aholic','al','algia','an','ance','ant','ar','ard','arian','arium','ary','ate','ation','ative','cide','cracy','crat','cule','cy','cycle','dom','dox','ectomy','ed','ee','eer','emia','en','ence','ency','ent','er','ern','escence','ese','esque','ess','est','etic','ette','ful','fy','hood','ial','ian','iasis','iatric','ible','ile','ily','ine','ing','ion','ious','ish','ism','ist','ite','itis','ity','ive','ization','ize','less','let','like','ling','log','ly','ment','ness','oid','ology','oma','onym','opia','opsy','or','ory','osis','ous','path','pathy','phile','phobia','phone','phyte','plegia','plegic','pnea','sect','ship','sion','some','th','tion','trophy','tude','ty','ular','uous','ure','ward','ware','wise','y'] | |
i = 0 | |
ARGV.each do |a| | |
suffixes.each do |b| | |
i += 1 | |
puts "#{a}#{b}.com" |
This file contains 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
# Want to give your users nice referral URLs, like http://www.service.com/?r=2ab3 ? | |
# | |
# A fast and easy 1-1 method is to use base-n encoded numbers. | |
# | |
# For instance, encode the user's id in base 36. In Ruby, this is easy: | |
# > 272927.to_s(36) | |
# => "5ulb" | |
# | |
# To get the base 10 id back again is just as easy: | |
# > "5ulb".to_i(36) |
This file contains 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 Foo | |
def self.included(base) | |
class << base | |
attr_accessor :bar | |
end | |
end | |
def set | |
self.class.bar = "hello there" | |
end |
This file contains 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 Foo | |
def bar | |
@bar ||= self.snakes | |
end | |
end | |
class Baz | |
def self.snakes | |
[:cobra] |
This file contains 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
class NSString < Mobi::Cocoa::Object | |
end | |
class UIAlertView < Mobi::Cocoa::Object | |
def self.alert(title, message, options={}) | |
alert = UIAlertView._alloc \ | |
._initWithTitle _S(title), | |
:message, _S(message), | |
:delegate, nil, | |
:cancelButtonTitle, options[:cancel_title] ? _S(options[:cancel_title]) || nil, |
This file contains 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
#define p1prime(p1,p2,p3,p4) (u0*u0*u0*p1 + (t0*u0*u0 + u0*t0*u0 + u0*u0*t0)*p2 + (t0*t0*u0 + u0*t0*t0 + t0*u0*t0)*p3 + t0*t0*t0*p4) | |
#define p2prime(p1,p2,p3,p4) (u0*u0*u1*p1 + (t0*u0*u1 + u0*t0*u1 + u0*u0*t1)*p2 + (t0*t0*u1 + u0*t0*t1 + t0*u0*t1)*p3 + t0*t0*t1*p4) | |
#define p3prime(p1,p2,p3,p4) (u0*u1*u1*p1 + (t0*u1*u1 + u0*t1*u1 + u0*u1*t1)*p2 + (t0*t1*u1 + u0*t1*t1 + t0*u1*t1)*p3 + t0*t1*t1*p4) | |
#define p4prime(p1,p2,p3,p4) (u1*u1*u1*p1 + (t1*u1*u1 + u1*t1*u1 + u1*u1*t1)*p2 + (t1*t1*u1 + u1*t1*t1 + t1*u1*t1)*p3 + t1*t1*t1*p4) |
This file contains 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
import XCTest | |
protocol Matchable : Equatable, Comparable { } | |
class Matcher<T : Matchable> { | |
let subjectWrapper: T[] | |
var subject: T { | |
get { | |
return subjectWrapper[0] |
This file contains 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
function execute_loop() { | |
var vmfunc, pathtab, path; | |
var pathstart, pathend; | |
if (resumefuncop) { | |
//qlog("### at resume time, storing value " + resumevalue + " at funcop " + resumefuncop.key); | |
store_operand_by_funcop(resumefuncop, resumevalue); | |
resumefuncop = null; | |
resumevalue = 0; | |
} |
This file contains 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 handles most storyboard style injection needs | |
extension UIViewController { | |
func injectable<T>() -> T? { | |
var controller: UIViewController? = self | |
if let nav = self as? UINavigationController { | |
controller = nav.viewControllers.first | |
} | |
return controller as? T | |
} |