A hopefully accurate list of iOS compatibility per device
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
// Can currently do this | |
func titleForSection1(section: Int) -> String? { | |
switch section { | |
case 0: return "Foo" | |
case 1: return "Bar" | |
default: return nil | |
} | |
} | |
// But I want to do this to remove the redundant returns |
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 | |
# Load Rails | |
ENV['RAILS_ENV'] = ARGV[0] || 'production' | |
DIR = File.dirname(__FILE__) | |
require DIR + '/../config/environment' | |
# ... do stuff that requires using your rails models |
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
# I rarely use make, probably a better way to do some/all of this? | |
SDK=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk | |
SOURCES=main.swift | |
EXECUTABLE=main | |
all: | |
swiftc -sdk $(SDK) $(SOURCES) -o $(EXECUTABLE) | |
clean: |
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 <Foundation/Foundation.h> | |
// Experimental improvement to NSDictionaryOfVariableBindings where keys are simplified to remove underscores and "self." prefixes | |
// so you can use the simple version within the VFL string | |
// | |
// Example: | |
// | |
// [NSLayoutConstraint constraintsWithVisualFormat:@"|-[_foo]-[self.bar]-[baz]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_foo, self.bar, baz)]; | |
// -> this doesn't work, gives an error about "self." | |
// |
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
// static var to store shared date formatter | |
static NSDateFormatter *_formatter = nil; | |
@implementation NSDate (Extras) | |
// Simple comparison, create a string from today and date, see if they're the same | |
- (BOOL)isToday | |
{ | |
// Lazy load and cache formatter, date formatters are slow to init | |
if (!_formatter) |
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
// [image writeToFile:[NSURL fileURLWithPath:@"/some/path/image.png"]]; | |
- (void)writeToFile:(NSURL *)fileURL | |
{ | |
NSBitmapImageRep *bitmapRep = nil; | |
for (NSImageRep *imageRep in [self representations]) | |
{ | |
if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) | |
{ | |
bitmapRep = (NSBitmapImageRep *)imageRep; |
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 *)imageWithMask:(UIImage *)maskImage andIsWhite:(BOOL)isWhite | |
{ | |
CGRect imageRect = CGRectMake(0, 0, maskImage.size.width, maskImage.size.height); | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
CGContextRef ctx = CGBitmapContextCreate(NULL, maskImage.size.width, maskImage.size.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast); | |
CGContextClipToMask(ctx, imageRect, maskImage.CGImage); | |
if (isWhite) { | |
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); | |
} else { |
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
console.log('100', 'something'); | |
console.log(100, 'something'); | |
console.log(100, 'something', 'something else'); | |
console.log(100 + ' something'); | |
console.log('something', 100, 'something'); |
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
tell application "System Events" | |
set x to application bindings of spaces preferences of expose preferences | |
set x to {|com.twitter.twitter-mac|:3} & x -- 3 is any space you don't want twitter on | |
set application bindings of spaces preferences of expose preferences to x | |
set x to {|com.twitter.twitter-mac|:4} & x -- 4 is the space you want twitter to be on | |
set application bindings of spaces preferences of expose preferences to x | |
end tell |
NewerOlder