Skip to content

Instantly share code, notes, and snippets.

View nickdowell's full-sized avatar

Nick Dowell nickdowell

  • UK
View GitHub Profile
#!/bin/bash
set -o errexit
set -o pipefail
langs=(de es fr pt)
for path in en.lproj/*.xib; do
git diff --quiet $path && git diff --cached --quiet $path || {
echo -n "updating localizations for $path"
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]];
const char *ptr = [data bytes], *start = NULL, *end = NULL;
for (size_t i = 0; i < [data length] - 8; i++) {
if (memcmp(ptr + i, "<plist", 6) == 0) {
start = ptr + i;
}
if (memcmp(ptr + i, "</plist>", 8) == 0) {
end = ptr + i + 8;
}
}
@nickdowell
nickdowell / auto_examples
Last active August 29, 2015 14:01
automount configuration examples
# /etc/auto_examples
afp_vol -fstype=afp afp://user:password@server/afp_vol
smb_vol -fstype=smbfs ://user:password@server/smb_vol
#note: no password can be specified for NFS
nfs_vol server:/nfs_vol
#import <dlfcn.h>
#import <mach-o/dyld.h>
#import <mach-o/loader.h>
int main(int argc, char *argv[]) {
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] executablePath]];
NSData *codeSignatureData = nil;
#import <Foundation/Foundation.h>
#import <notify.h>
void test()
{
int notify_token;
notify_register_dispatch("com.apple.springboard.lockstate", &notify_token, dispatch_get_main_queue(), ^(int token) {
uint64_t state = UINT64_MAX;
notify_get_state(token, &state);
NSLog(@"com.apple.springboard.lockstate = %llu", state);
@nickdowell
nickdowell / gist:2236186
Last active October 2, 2015 11:28
GetPluginBundle()
#include <CoreFoundation/CoreFoundation.h>
#include <dlfcn.h>
static CFBundleRef GetPluginBundle()
{
static CFBundleRef bundle;
if (bundle) {
return bundle;
}
@nickdowell
nickdowell / gist:4492320
Created January 9, 2013 11:01
parsing query parameters from an NSURL
NSMutableDictionary *queryParameters = [NSMutableDictionary dictionary];
for (NSString *string in [[URL query] componentsSeparatedByString:@"&"]) {
NSArray *array = [string componentsSeparatedByString:@"="];
if ([array count] == 2)
[queryParameters setObject:[array objectAtIndex:1] forKey:[array objectAtIndex:0]];
}
#include <assert.h>
#include <CoreMIDI/CoreMIDI.h>
char buffer[1024];
MIDIClientRef client = 0;
MIDIEndpointRef endpoint = 0;
MIDIPacketList *packetList = (void *)buffer;
MIDIPacket *packet = 0;
MIDIPortRef port = 0;
@nickdowell
nickdowell / gist:5336704
Created April 8, 2013 13:18
mkv to mp4 conversion (no transcoding) using ffmpeg
ffmpeg -loglevel verbose -i input.mkv -acodec copy -vcodec copy output.mp4
@nickdowell
nickdowell / gist:5678403
Created May 30, 2013 14:44
bash aliases
alias bbc6music='open -a "QuickTime Player" $(curl -s http://www.bbc.co.uk/radio/listen/live/r6_aaclca.pls | grep File1= | sed s/File1=//)'