This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
#import <UIKit/UIKit.h> | |
#import <ImageIO/ImageIO.h> | |
#import <MobileCoreServices/MobileCoreServices.h> | |
static UIImage *frameImage(CGSize size, CGFloat radians) { | |
UIGraphicsBeginImageContextWithOptions(size, YES, 1); { | |
[[UIColor whiteColor] setFill]; | |
UIRectFill(CGRectInfinite); | |
CGContextRef gc = UIGraphicsGetCurrentContext(); | |
CGContextTranslateCTM(gc, size.width / 2, size.height / 2); |
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
based on rage-quit support for bash
Put the files below inside ~/.oh-my-zsh/custom/plugins/fuck
Also chmod a+x
the flip
command.
// See http://nshipster.com/key-value-observing/ | |
// Put this code a common utilities header, and use it to have the compiler help check correctness of key paths. | |
// Uses macro stringification to create an Obj-C string literal, plus validation code that the compiler optimizes out. | |
@interface NSObject (KeyPathFakeCategoryForCompilerWarnings) | |
+ (instancetype)__fake_method_for_compiler_warnings__; | |
- (instancetype)__fake_method_for_compiler_warnings__; | |
@end | |
/*! Returns a string for the given keypath, but causes a compiler warning if the keypath is not defined on \c self. |
extension Dictionary { | |
init(_ elements: [Element]){ | |
self.init() | |
for (k, v) in elements { | |
self[k] = v | |
} | |
} | |
func map<U>(transform: Value -> U) -> [Key : U] { | |
return Dictionary<Key, U>(Swift.map(self, { (key, value) in (key, transform(value)) })) |
import Foundation | |
import Quartz | |
extension Array { | |
func each(doThis: (element: T) -> Void) { | |
for e in self { | |
doThis(element: e) | |
} | |
} | |
} |
#!/bin/bash | |
############################################################################### | |
## ## | |
## Build and package OpenSSL static libraries for OSX/iOS ## | |
## ## | |
## This script is in the public domain. ## | |
## Creator : Laurent Etiemble ## | |
## ## | |
############################################################################### |
let dict = [1:"a", 2:"b"] | |
let key: Int? = 2 | |
if let value = key.map({ dict[$0] }) { | |
print(value) // "Optional("b")" | |
} | |
if let key = key, value = dict[key] { | |
print(value) // "b" | |
} | |
if let value = key.flatMap({dict[$0]}) { | |
print(value) // "b" |