Skip to content

Instantly share code, notes, and snippets.

View nkpart's full-sized avatar

Nick Partridge nkpart

  • Brisbane, Australia
View GitHub Profile
class Array
def to_proc
x = self.dup
proc { |y| x[0].send(x[1], y) }
end
end
[".", "what"].select(&[File, :exists?]) # <= [","]
Error in license
OmniTrans RT returning exit value 1
Job done with return value 1
Test FAILED !
Finished: 12/12/2008 2:25:58 PM
TS_FullRun failed
townsville failed
Testrun d:\CONSTE~1\ failed miserably

Thoughts

  • After restarting a project about 8 times over the last month, I think that a Window-based application is the logical template to use for every project. And then learn how to create every other template from there. Using the other templates makes it harder to learn how to build the different controller-types into a different app.

Keyboard things

  • esc is the new ctrl-[alt/shift/wat]-space. It completes on methods, snippets; pretty much everything.
def number_to_ordinal num
int = num.to_i
if (10...20) === int
"#{int}th"
else
"#{int}#{%w{ th st nd rd th th th th th th }[int % 10]}"
end
end
alias sql="echo Okay idjit, it goes like this:
echo CREATE TABLE tablename \(id INTEGER, name VARCHAR\)
echo SELECT row FROM tablename WHERE condition
echo INSERT INTO tablename \(column1, column2\) VALUES \(value1, value2\)
echo UPDATE tablename SET column1 = value1 WHERE condition
"
/*
Copyright (C) 2008 Apple Inc. All Rights Reserved.
*/
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
id strict_cast(Class cls, NSObject *object) {
if ([object isKindOfClass:cls]) {
return object;
} else {
[NSException raise:@"Cast failed" format:@"Could not cast %@ to %s", object, class_getName(cls)];
}
return nil;
}
//// Usage
def assign_nesting_resources
@hammock_nesting_scopes.map {|scope|
scope.kick
}.confirm {|kicked_scopes|
kicked_scopes.all? { |results| results.length == 1 }
}.map { |kicked_scopes|
kicked_scopes.map {|results|
results.first
}.each {|result|
assign_entity result
alias foo=blah -> "blah"
alias foo='blah' -> "blah"
alias foo="blah" -> "blah"
alias foo="a 'blah'" -> "a 'blah'"
alias foo='a "blah"' -> "a \"blah\""
alias foo='uh
oh' -> "uh\noh"
NEWTYPE(Name, NSString, name);
### later!
Name *nick = [Name name:@"Nick"];
[nick name]; // @"Nick"
[nick description]; // @"<Name name:@"Nick">"