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
/** | |
* An even more common approach to look for vendor specific implementations in | |
* the browsers javascript object model. | |
* lookUpImplementation(vendors,subject,functionName,replacement) is reusable | |
* for other tasks too :-) | |
*/ | |
var vendors = ['webkit','moz','o','ms']; | |
window.requestAnimationFrame = lookUpImplementation( | |
vendors, window, 'requestAnimationFrame' | |
,function(step) { |
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
/** | |
* Draws a smiley inside the given rectangle. The mood value (0...1) is used | |
* to make the smiley happy or sad. | |
* | |
* @param rect Rectangle to draw the smiley into | |
* @param mood Happy (= 1) or sad (= 0) or anything in between | |
*/ | |
-(void)drawSmileyInRect:(CGRect)rect withMood:(float)mood { | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
CGContextSaveGState(ctx); |
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
NSString* localizedProperty(NSString* propertyName, id fromObject); |
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
// NSArray *colors = @[[UIColor redColor], [UIColor greenColor], [UIColor blueColor]]; | |
// CGFloat locations[] = {0,.5,1}; | |
// DrawVerticalGradient(rect, colors, locations, ctx); | |
void DrawVerticalGradient(CGRect rect, NSArray* colors, const CGFloat steps[], CGContextRef ctx) { | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
NSMutableArray *cgColors = [NSMutableArray arrayWithCapacity:colors.count]; | |
for (UIColor *color in colors) { | |
[cgColors addObject:(__bridge id)(color.CGColor)]; | |
} |
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
CGContextRef CreateBitmapContext(CGSize size) { | |
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); | |
CGContextRef ctx = CGBitmapContextCreate(nil, size.width, size.height, 8, size.width * (CGColorSpaceGetNumberOfComponents(space) + 1), space, kCGImageAlphaPremultipliedLast); | |
CGColorSpaceRelease(space); | |
return ctx; | |
} | |
UIImage* CreateUIImageFromBitmapContext(CGContextRef ctx) { | |
CGImageRef cgImage = CGBitmapContextCreateImage(ctx); |
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
@interface NSArray (ExtractValuesAsArray) | |
/** Creates a new NSArray with the specific value of the items of another array. Ensure that the items of the array are KVC compliant since a key path is used to gather the values. | |
*/ | |
+(NSArray*)arrayWithValuesOfArrayItems:(NSArray*)array keyPath:(NSString*)keyPath; | |
@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
-(BOOL)isCoordinate:(CLLocationCoordinate2D)coordinate insideRegion:(MKCoordinateRegion)region { | |
CLLocationCoordinate2D center = region.center; | |
CLLocationCoordinate2D northWestCorner, southEastCorner; | |
northWestCorner.latitude = center.latitude - (region.span.latitudeDelta / 2.0); | |
northWestCorner.longitude = center.longitude - (region.span.longitudeDelta / 2.0); | |
southEastCorner.latitude = center.latitude + (region.span.latitudeDelta / 2.0); | |
southEastCorner.longitude = center.longitude + (region.span.longitudeDelta / 2.0); | |
return(coordinate.latitude >= northWestCorner.latitude && |
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/sh | |
SABNZBD_CONFIG=/root/.sabnzbd/sabnzbd.ini | |
SABNZBD_HOST=--HOST_ADDRESS-- | |
SABNZBD_PORT=9200 | |
SABNZBD_APIKEY=--YOUR_API_KEY-- | |
CP_PID=/var/run/couchpotato.pid | |
CP_CONFIG=/usr/local/couchpotato.config.ini | |
CP_DATADIR=/root/.couchpotato |
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
/** File: Template Preprocessor | |
* Creates precompiled handlebar templates and makes them available as a simple | |
* common js module. | |
*/ | |
var Handlebars = require('handlebars') | |
, _ = require('underscore') | |
, path = require('path') | |
, fs = require('fs') | |
, templatesSource = path.join(__dirname, 'src', 'templates') | |
, templatesDestination = path.join(__dirname, 'src', 'templates', 'precompiledTemplates.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
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "Supply a name for the repo/site to publish" | |
exit 1; | |
fi | |
URLROOT=gitpages.mydomain.com | |
ROOT=/home/www/gitpages.mydomain.com | |
REPOS=$ROOT/repositories |
OlderNewer