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
| ;; factory factories, etc. | |
| (def dbf (doto (DocumentBuilderFactory/newInstance) | |
| (.setNamespaceAware true))) | |
| (def doc-builder (.newDocumentBuilder dbf)) | |
| (defn namespace-map | |
| "Returns an implementation of NamespaceContext ... actual usefulness TBD" | |
| [mapping] | |
| (let [prefixes (fn [uri] (map key (filter #(= uri (val %)) mapping)))] |
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
| (defn make-ghost | |
| [color] | |
| {:get-tick 0, :eatable nil, :color nil, :eaten nil, :specs color, :position nil, :due nil, :map nil, :direction nil}) | |
| (def ghost-specs ["#00FFDE" "#FF0000" "#FFB8DE" "#FFB847"]) | |
| (def game-state (atom {:state nil | |
| :audio [] | |
| :ghosts (mapv make-ghost ghost-specs) | |
| :eaten-count 0 |
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
| NSDictionary *metrics = @{@"padding": @25}; | |
| NSDictionary *views = NSDictionaryOfVariableBindings(imageView, thumbnailsView, container, titleLabel); | |
| void (^addConstraint)(NSString *) = ^(NSString *format) { | |
| [mainView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:format options:0 metrics:metrics views:views]]; | |
| }; | |
| addConstraint(@"|-padding-[thumbnailsView]-padding-|"); | |
| addConstraint(@"V:[thumbnailsView(==100)]-padding-|"); | |
| addConstraint(@"|-padding-[imageView][thumbnailsView]"); |
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 NSString (JPCSHA1) | |
| - (NSString *)jpc_SHA1String | |
| { | |
| unsigned char md[CC_SHA1_DIGEST_LENGTH]; | |
| NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; | |
| CC_SHA1([data bytes], [data length], md); | |
| NSMutableString *result = [NSMutableString string]; | |
| for (int ii = 0; ii < CC_SHA1_DIGEST_LENGTH; ii++) { | |
| [result appendFormat:@"%02x", md[ii]]; |
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
| import Leap, sys | |
| class SampleListener(Leap.Listener): | |
| def on_init(self, controller): | |
| print "Initialized" | |
| def on_connect(self, controller): | |
| self.last_fingers = 0 | |
| print "Connected" |
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
| - (void)showAlert | |
| { | |
| UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"wut" message:@"really?" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; | |
| alert.show; | |
| } | |
| - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath | |
| { |
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
| BOOL success = NO; | |
| int tries = 0; | |
| while (!success && tries < 2) | |
| { | |
| if ([__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:error]) | |
| { | |
| success = YES; | |
| } | |
| else | |
| { |
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 UIColor (strings) | |
| + (UIColor *)colorFromRGBHexString:(NSString *)colorString | |
| { | |
| if (colorString.length == 7) { | |
| const char *colorUTF8String = [colorString UTF8String]; | |
| int r, g, b; | |
| sscanf(colorUTF8String, "#%2x%2x%2x", &r, &g, &b); | |
| return [UIColor colorWithRed:(r / 255.0) green:(g / 255.0) blue:(b / 255.0) alpha:1.0]; | |
| } |
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
| #define UIColor255(r, g, b, a) [UIColor colorWithRed:(r / 255.0) green:(g / 255.0) blue:(b / 255.0) alpha:a] |