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 Element<T> { | |
let value: T | |
var next: Element<T>? = nil | |
init(value: T, next: Element<T>?) | |
{ | |
self.value = value | |
self.next = next | |
} | |
} |
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
#!/bin/bash | |
for file in $*; do | |
if [ -d $file ] | |
then | |
echo "it's a directory" | |
else | |
count=`wc -l < $file` | |
if [ $count -gt 400 ] | |
then |
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
-(BOOL)appIsPresentInLoginItems | |
{ | |
NSString *bundleID = @"blah"; | |
NSArray *jobDicts = (__bridge NSArray *)SMCopyAllJobDictionaries( kSMDomainUserLaunchd ); | |
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { | |
return [[evaluatedObject valueForKey:@"Label"] isEqualToString:bundleID] && [[evaluatedObject valueForKey:@"OnDemand"] boolValue]; | |
}]; | |
return [[jobDicts filteredArrayUsingPredicate:predicate] count] >= 1; |
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 UIColorFromRGB(rgbValue) [UIColor \ | |
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ | |
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ | |
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] | |
cell.textColor = UIColorFromRGB(0x333333); |
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
if [[ $# == 0 ]]; then | |
echo "ERROR: Please supply target name" | |
echo "Required usage: xdist <target-name>" | |
echo "Optional usage: xdist <target-name> <destination-directory> (defaults to Desktop)" | |
exit 1 | |
elif [[ $# == 1 ]]; then | |
target="$1" | |
dest=~/Desktop | |
elif [[ $# == 2 ]]; then | |
target="$1" |
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
List.metaClass.addIfNotNull = { | |
if (it != null) add(it) | |
} | |
def list = [] | |
list.addIfNotNull(null) | |
assert 0 == list.size() | |
list.addIfNotNull("foo") |
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
(defn fib [x] | |
(if (= x 0) 0 | |
(if (= x 1) 1 | |
(+ (fib (- x 1)) (fib (- x 2))))) | |
) |