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 | |
struct NuclearPowerStationOperator { | |
class Storage { | |
var turnOffCores: Bool = false | |
func copy() -> Storage { | |
let new = Storage() | |
new.turnOffCores = turnOffCores | |
return new |
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 python | |
# | |
# To use this, just put the DSYMS in the same directory as the sample dump file, | |
# and run the script from that directory, passing the sample dump file name as only argument | |
# | |
import re, sys, os, subprocess | |
sampleFile = sys.argv[1] |
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
# Enter two file names as arguments. | |
# Will print out the ones that appear in both files. | |
# This is a set intersection. | |
emails-common-to-both () { | |
comm -12 -i <(sort -u -f "$1") <(sort -u -f "$2"); | |
}; | |
# Enter two filenames. | |
# Will print emails from first that don't appear in second. | |
# This is like a set subtraction. |
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
func flatMap<U, V, T>(_ i: U?, _ j: V?, block: (U, V)->T) -> T? { | |
var result: T? | |
if let i = i, let j = j { result = block(i,j) } | |
return result | |
} | |
func flatMap<U, V, W, T>(_ i: U?, _ j: V?, _ k: W?, block: (U, V, W)->T) -> T? { | |
var result: T? | |
if let i = i, let j = j, let k = k { result = block(i,j,k) } |
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
/// Verify the signature passed with the Paddle request parameters. | |
/// Details here: https://paddle.com/docs/reference-verifying-webhooks | |
func verifyPaddleSignature(inParameters parameters: [String:String]) throws -> Bool { | |
guard let signatureString = parameters[PaddleParameter.signature.rawValue], | |
let signature = Data(base64Encoded: signatureString) else { | |
return false | |
} | |
// Need to gather sorted parameters | |
var signatureParameters = parameters |
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
// Open in Script Editor, and Export as an Application | |
// To use, drag files from folder onto Droplet | |
function openDocuments(docs) { | |
var mail = Application("Mail") | |
for (var i = 0; i < docs.length; i++) { | |
var doc = docs[i].toString() | |
var filename = doc.replace(/^.*[\\\/]/, '') | |
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 bash | |
# If your OS X WiFi connection stops working, but can be fixed by | |
# toggling WiFi off and then on, this script can help prevent mouse arm. | |
# Pings Apple's server repeatedly, toggling WiFi off/on when a connection times out. | |
while true ; do | |
curl --head --silent --connect-timeout 10 http://www.apple.com/my-wifi-keeps-dropping-out > /dev/null | |
if [ $? -ne 0 ] ; then | |
networksetup -setairportpower en1 off | |
networksetup -setairportpower en1 on |
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 CGImageIsOpaque(CGImageRef image) | |
{ | |
size_t width = CGImageGetWidth(image); | |
size_t height = CGImageGetHeight(image); | |
unsigned char pixelData[width * height]; | |
CGContextRef context = CGBitmapContextCreate( pixelData, width, height, 8, width, NULL, (kCGBitmapAlphaInfoMask & kCGImageAlphaOnly) ); | |
CGContextDrawImage( context, CGRectMake(0, 0, width, height), image ); | |
CGContextRelease( context ); | |
for (NSInteger i = 0; i < width * height; ++i) { |
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
// Dispatch | |
// | |
// Usage: | |
// Async dispatch to main queue | |
// -->block | |
// Async dispatch to queue | |
// queue --> block | |
// Sync dispatch to main queue | |
// -->|block | |
// Sync dispatch to queue |
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> | |
#if TARGET_OS_IPHONE && !defined(__IPHONE_7_0) | |
#define __IPHONE_7_0 70000 | |
#endif | |
#if !TARGET_OS_IPHONE && !defined(__MAC_10_9) | |
#define __MAC_10_9 1090 | |
#endif |