This file contains hidden or 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> | |
typedef NS_OPTIONS(uint32_t, SomeOption) { | |
SomeOptionNone = 0, | |
SomeOptionFoo = 1 << 0, | |
SomeOptionBar = 1 << 1, | |
}; | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { |
This file contains hidden or 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 | |
# | |
# git-is-ancestor, by Simon Whitaker | |
# | |
# Suggested usage | |
# | |
# Store this file somewhere, make it executable, then alias | |
# it to git is-ancestor by putting this in your $HOME/.gitconfig: | |
# | |
# [alias] |
This file contains hidden or 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> | |
void timeThis(NSString *label, NSUInteger iterations, void(^block)()) { | |
CFAbsoluteTime start = CFAbsoluteTimeGetCurrent(); | |
for (NSUInteger i = 0; i < iterations; i++) { | |
block(); | |
} | |
CFAbsoluteTime interval = CFAbsoluteTimeGetCurrent() - start; | |
printf("%s: %lu iterations, %.3fs\n", [label UTF8String], iterations, interval); |
This file contains hidden or 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 re | |
tweet = "Currently chilling out at W1B 2EL, then on to WC2E 8HA or maybe even L1 8JF! :-)" | |
# Here's a simple regex that tries to recognise postcode-like strings. | |
# See http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation | |
# for the rules on how UK postcodes are formatted. | |
postcode_regex = '[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}' | |
postcodes = re.findall(postcode_regex, tweet) |
This file contains hidden or 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
var tweet = "Currently chilling out at W1B 2EL, then on to WC2E 8HA or maybe even L1 8JF! :-)"; | |
// Here's a simple regex that tries to recognise postcode-like strings. | |
// See http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation | |
// for the rules on how UK postcodes are formatted. | |
var postcode_regex = /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/g; | |
var postcodes = tweet.match(postcode_regex); | |
console.log(postcodes); |
This file contains hidden or 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> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
// Declare some config values; the input and output file paths and the | |
// number of bytes per word | |
NSString *inputFile = @"/Users/simon/Desktop/input.dat"; | |
NSString *outputFile = @"/Users/simon/Desktop/output.dat"; |
This file contains hidden or 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
kill-adobe-updater() { | |
killall "AAM Updates Notifier" 2>/dev/null || echo "AAM Updater not running" | |
rm ~/Library/LaunchAgents/com.adobe.AAM.Updater-1.0.plist 2>/dev/null || echo "LaunchAgent not found" | |
} |
This file contains hidden or 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
// GSDismissableViewControllerDelegate.h | |
// | |
// Created by Simon Whitaker at Goo Software Ltd. | |
// https://gist.github.com/simonwhitaker/4745057 | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@protocol GSDismissableViewControllerDelegate <NSObject> | |
This file contains hidden or 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 hashlib | |
from django.contrib.auth.hashers import PBKDF2PasswordHasher | |
class PBKDF2SHA512PasswordHasher(PBKDF2PasswordHasher): | |
""" | |
Alternate PBKDF2 hasher which uses SHA512 instead of SHA256. | |
Note: As of Django 1.4.3, django.contrib.auth.models.User defines password | |
with max_length=128 |
This file contains hidden or 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 | |
ssl_expiry() { | |
# Show usage info if not called with a hostname | |
if [ $# -eq 0 ]; then | |
echo "Usage: ssl_expiry HOSTNAME" | |
return 0 | |
fi | |
domain=$1 |