Skip to content

Instantly share code, notes, and snippets.

View robinkunde's full-sized avatar

Robin Kunde robinkunde

View GitHub Profile
@robinkunde
robinkunde / generic_dispatch_lock.swift
Created July 18, 2016 19:47
generic_dispatch_lock.swift
@inline(__always) func with<T>(queue: dispatch_queue_t, @autoclosure(escaping) get block: () -> T) -> T {
assert(dispatch_queue_get_label(queue) != dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), "Invoked dispatch_sync in a way that will deadlock")
var result: T!
dispatch_sync(queue) {
result = block()
}
return result
}
#!/usr/bin/env python3
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('message')
parser.add_argument('--start', type=int, help='Pass start timestamp to append run time to notification')
parser.add_argument('--apikey', type=str, help='Pushover API key (can also be implicitly defined as ENV variable in $PUSHOVER_API_KEY)', default=os.getenv('PUSHOVER_API_KEY', ''))
parser.add_argument('--userkey', type=str, help='Pushover user key (can also be implicitly defined as ENV variable in $PUSHOVER_USER_KEY)', default=os.getenv('PUSHOVER_USER_KEY', ''))
args = parser.parse_args()
@robinkunde
robinkunde / gist:8425a7b0459760e3c5e6
Created February 29, 2016 20:33
UIAccessibilityNotificationVoiceOverIdentifier
UIAccessibilityPostNotification(UIAccessibilityPauseAssistiveTechnologyNotification, UIAccessibilityNotificationVoiceOverIdentifier)
@robinkunde
robinkunde / osx-for-hackers.sh
Created November 30, 2015 18:39 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@robinkunde
robinkunde / ssl_cert_expiration.sh
Last active August 29, 2015 14:20
Bash script that checks expiration date of SSL certificates
#!/bin/bash
DATE_STRING="1 months"
display_usage() {
echo "This script displays the expiration dates of the passed SSL certificates if they expire before a set date (defaults to one month from now)."
echo "See usage of the -d parameter of the date command on how to format the optional date string."
echo -e "\nUsage:\n$0 [-d \"DATE_STRING\"] FILE... \n"
}
### Keybase proof
I hereby claim:
* I am robinkunde on github.
* I am robinkunde (https://keybase.io/robinkunde) on keybase.
* I have a public key whose fingerprint is 74B3 6554 9086 90BA A7C1 25B0 9491 BAB4 65E0 3C6B
To claim this, I am signing this object:
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@robinkunde
robinkunde / hexEncodedStringFromData.m
Last active August 29, 2015 14:04
High performance function for creating hex encoded string from NSData
NSString *hexEncodedStringFromData(NSData *data)
{
static const char hexChars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
// Store the length, otherwise it would be re-evalued on each loop iteration
NSUInteger length = data.length;
// malloc result data NULL terminated string
char *resultData = malloc(length * 2 + 1);
const unsigned char *sourceData = (const unsigned char *)data.bytes;