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 | |
## Nodejs custom version installer | |
## | |
## Ronaldo Barbachano April 2013 | |
## Based on the openshift/nodejscustom-version-openshift repo | |
## | |
## Supply with path to existing openshift repo, or move script into | |
## repo root. | |
## | |
## Probably less headaches if this is run immediately after |
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
int multiplier = 7; | |
int (^myBlock)(int) = ^(int num) { | |
return num * multiplier; | |
}; | |
printf("%d", myBlock(3)); | |
// prints "21" |
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 DLog(__FORMAT__, ...) \ | |
NSLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) | |
#define HexValueFromString(string) { \ | |
unsigned int rgbHex; \ | |
[[NSScanner scannerWithString:@""] scanHexInt:&rgbHex]; \ | |
return rgbHex; \ | |
} | |
#define UIColorFromRGB(rgbValue, alphaValue) \ |
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
//Get a UIImage from the UIView | |
UIGraphicsBeginImageContext(myView.bounds.size); | |
[myView.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
//Blur the UIImage | |
CIImage *imageToBlur = [CIImage imageWithCGImage:viewImage.CGImage]; | |
CIFilter *gaussianBlurFilter = [CIFilter filterWithName: @"CIGaussianBlur"]; | |
[gaussianBlurFilter setValue:imageToBlur forKey: @"inputImage"]; |
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
CGAffineTransform t = CGAffineTransformMakeScale(1.0f / parentRect.size.width, 1.0f / parentRect.size.height); | |
CGRect unitRect = CGRectApplyAffineTransform(rect, t); |
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
/* The API controller | |
Exports 3 methods: | |
* post - Creates a new thread | |
* list - Returns a list of threads | |
* show - Displays a thread and its posts | |
*/ | |
var Thread = require('../models/thread.js'); | |
var Post = require('../models/post.js'); |
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 <CoreText/CoreText.h> | |
... | |
// preload | |
dispatch_queue_t queue = dispatch_queue_create("com.company.worker", NULL); | |
dispatch_async(queue, ^(void) { | |
NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; | |
[attributes setObject:@"Helvetica" forKey:(id)kCTFontFamilyNameAttribute]; | |
[attributes setObject:[NSNumber numberWithFloat:36.0f] forKey:(id)kCTFontSizeAttribute]; |
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 SingletonWithBlock(block) static dispatch_once_t pred = 0; \ | |
__strong static id _sharedObject = nil; \ | |
dispatch_once(&pred, ^{ \ | |
_sharedObject = block(); \ | |
}); \ | |
return _sharedObject; \ | |
@implementation SingletonClass | |
+ (id)sharedInstance |
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
# | |
# c.f. StackOverflow question/answer here: http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4 | |
# | |
# Version 2.3 | |
# | |
# Latest Change: | |
# - Apple's handling of "project files" is broken; added a workaround for Xcode 4.5 | |
# - Added automatic FAIL BUILD if any of the internal commands fail | |
# | |
# Purpose: |
NewerOlder