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
UIImage *TintImageWithTintColor(UIImage *image, UIColor *tintColor) { | |
// Huge props to http://stackoverflow.com/questions/3514066/how-to-tint-a-transparent-png-image-in-iphone | |
UIGraphicsBeginImageContext(image.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextTranslateCTM(context, 0, image.size.height); | |
CGContextScaleCTM(context, 1.0, -1.0); | |
CGRect rect = (CGRect){ CGPointZero, image.size }; |
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
- (void)configureLogging { | |
[DDLog addLogger:[DDTTYLogger sharedInstance]]; | |
[DDTTYLogger sharedInstance].colorsEnabled = YES; | |
[DDTTYLogger sharedInstance].logFormatter = [[GCLog alloc] init]; | |
[[DDTTYLogger sharedInstance] setForegroundColor:[UIColor colorWithCrayola:@"Cornflower"] | |
backgroundColor:nil forFlag:LOG_FLAG_INFO]; | |
[[DDTTYLogger sharedInstance] setForegroundColor:[UIColor colorWithCrayola:@"Screamin' Green"] | |
backgroundColor:nil forFlag:LOG_FLAG_API]; | |
[[DDTTYLogger sharedInstance] setForegroundColor:[UIColor colorWithCrayola:@"Canary"] | |
backgroundColor:nil forFlag:LOG_FLAG_UI]; |
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
CGRect CGRectAdjustSize(CGRect rect, CGSize size) { | |
rect.size = size; | |
return rect; | |
} | |
CGRect CGRectAdjustOrigin(CGRect rect, CGPoint origin) { | |
rect.origin = origin; | |
return rect; | |
} |
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
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'debugger' | |
class Fixnum | |
def to_surrogate_pair | |
if self >= 0x10000 && self <= 0x10FFFF | |
high = ((self - 0x10000) / 0x400).floor + 0xD800 | |
low = ((self - 0x10000) % 0x400) + 0xDC00 |
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
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'ostruct' | |
# Read in the file, convert to UTF-8 if needed, and parse with Nokogiri. | |
glob = ARGV[0] | |
exit if glob.nil? |
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
#!/usr/bin/env ruby | |
# Convert a text crossword into JSON. | |
require 'active_resource' | |
ActiveResource::Base | |
filename = ARGV[0] | |
data = File.open(filename, 'r') { |f| f.read } |
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
// | |
// UIScrollView+PullToRefresh.h | |
// Created by Ben Kreeger (@kreeger), 2013/01/23. | |
// | |
#import <UIKit/UIKit.h> | |
/** Adds pull to refresh for a UIScrollView (or a UITableView). Abstracts away differences in frameworks between iOS 6 | |
* and iOS 5 (in the case of the latter, `ODRefreshControl` is used. | |
*/ |
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
#!/usr/bin/env ruby | |
# Uses the Microsoft Translator API to draft a translated version of an Objective-C strings file. | |
# USAGE: translate-strings <FILEPATH> <NEW_LANG_CODE> | |
# NOTE: must have a config.yml file next to this script with `client_id` and `client_secret` | |
# defined as keys (and their respective values). | |
require 'uri' | |
require 'httparty' | |
require 'nokogiri' |
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
<snippet> | |
<content><![CDATA[do | |
$0 | |
end]]></content> | |
<tabTrigger>do</tabTrigger> | |
<scope>source.ruby</scope> | |
<description>Insert do … end</description> | |
</snippet> |