Skip to content

Instantly share code, notes, and snippets.

View pilotmoon's full-sized avatar
🏠
Working from bed

Nick Moore pilotmoon

🏠
Working from bed
View GitHub Profile
#!/usr/bin/ruby
# Log in to Red Hot Pawn, check if there are games waiting, and print a message
# indicating the result.
require 'net/http'
require 'uri'
MAIL='you@example.com'
PASS='password'
QUERY_URL=URI::parse('http://www.redhotpawn.com/xml/xstatus/gameswaitingxml.php')
- (NSImage *)blankImageOfSize:(NSSize)size;
{
NSBitmapImageRep *rep=[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:size.width
pixelsHigh:size.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
@pilotmoon
pilotmoon / gist:820151
Created February 10, 2011 08:43
Checking the receipt is signed
// This is based on https://github.com/roddi/ValidateStoreReceipt
// However, we use a hard coded SHA-1 hash to check the root cert, rather than the going to the keychain.
// Sorry for bad indenting. It looks OK in my Xcode!
// link with Foundation.framework and IOKit.framework libCrypto (via -lcrypto in Other Linker Flags)
// #import <Foundation/Foundation.h>
// #include <openssl/pkcs7.h>
// #include <openssl/objects.h>
// #include <openssl/sha.h>
// #include <openssl/x509.h>
// #include <openssl/err.h>
# This file contains functions to handle conversion between Julian Day Number (JDN) and
# Julian and Gregorian dates. These algorithms are optimised for readability
# and non-repetition of code, rather than speed.
#
# Benchmark results for 500_000 runs on my machine:
# user system total real
# jdn_to_gregorian_direct 2.930000 0.020000 2.950000 ( 2.984025)
# jdn_to_gregorian 3.590000 0.020000 3.610000 ( 3.636085)
# jdn_to_julian 3.110000 0.020000 3.130000 ( 3.175516)
# user system total real
@pilotmoon
pilotmoon / insert_version.sh
Created August 17, 2011 10:30
XCode 4 Git Version Script
# This script fixes up the CFBundleShortVersionString with a string derived from git.
# Place it as a Build Phase just before Copy Bundle Resources
# clone: git submodule add git@gist.github.com:1151287.git gist-1151287
# call: ${SRCROOT}/gist-1151287/insert_version.sh
# PlistBuddy and git executables
buddy='/usr/libexec/PlistBuddy'
git='/usr/bin/git'
@pilotmoon
pilotmoon / gist:2975339
Created June 22, 2012 21:37
AppleScript to create a new message in Sparrow and set the text.
tell application "Sparrow"
set newMessage to make new outgoing message with properties {content:"some text"}
compose newMessage
activate
end tell
//
// DCUniversalAccessHelper.m
// dc
//
// Created by Work on 22/10/2010.
// Copyright 2010 Nicholas Moore. All rights reserved.
//
#import "NMUniversalAccessHelper.h"
#import "NMAppUtils.h"
@pilotmoon
pilotmoon / asoturl.py
Created October 16, 2016 20:53
Get the url of the latest A State Of Trance mp3 file listed at archive.org
#! /usr/bin/python
import urllib, json
data = json.load(urllib.urlopen('https://archive.org/metadata/asotarchive'))
mp3files=filter(lambda x: x.get('name','').endswith('.mp3'), data.get('files', []))
mp3files.sort(cmp=lambda x,y: cmp(int(x.get('mtime',0)), int(y.get('mtime',0))))
mp3name = mp3files.pop().get('name', '')
mp3url = 'https://' + data.get('d1', '') + data.get('dir', '') + '/' + mp3name
@pilotmoon
pilotmoon / spelling.swift
Created November 10, 2016 10:48
Print NSSpellChecker available languages.
#!/usr/bin/swift
import Cocoa
print(NSSpellChecker.shared().availableLanguages);
//
// DCStatusItemController.m
// dc
//
// Created by Work on 20/12/2010.
// Copyright 2010 Nicholas Moore. All rights reserved.
//
#import "NMStatusItemController.h"
#import "NMKit.h"