Skip to content

Instantly share code, notes, and snippets.

View mattstevens's full-sized avatar

Matt Stevens mattstevens

View GitHub Profile
@mattstevens
mattstevens / interlink.rb
Created September 12, 2009 17:20
A modified version of the wikiwords filter for Webby
@mattstevens
mattstevens / com.alloysoft.DroboKeepAlive.plist
Created November 2, 2009 04:38
Launch agent to prevent Drobo spin down on OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.alloysoft.DroboKeepAlive</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/touch</string>
<string>/Volumes/Drobo/.keepalive</string>
@mattstevens
mattstevens / localpath.rb
Created December 9, 2009 17:17
Webby filter to create paths readable by the file system for CHM and Mac help bundles
module Webby
class Renderer
attr_reader :page
end
module Filters
# To use add localpath to the end of the list of filters in the layout.
# Converts all links starting with '/' to use relative paths and appends
# 'index.html' to all links both starting and ending with '/'.
@mattstevens
mattstevens / SITEFILE
Created December 9, 2009 21:43
Webby helper to convert links to absolute URLs
# Define the base URL in the sitefile
SITE.base = 'http://yourdomain.com'
#!/usr/bin/env node
var sys = require('sys'),
path = require('path'),
fs = require('fs'),
pcap = require('pcap'), pcap_session,
tcp_tracker = new pcap.TCP_tracker();
var device = undefined;
var filter = "";
@mattstevens
mattstevens / HD
Created May 22, 2011 21:23
Xbench results upgrading a 2010 MacBook Pro's stock HD with an SSD
System Info
Xbench Version 1.3
System Version 10.6.7 (10J869)
Physical RAM 8192 MB
Model MacBookPro6,2
Drive Type TOSHIBA MK5055GSXF
Disk Test 20.07
Sequential 80.14
Uncached Write 74.35 45.65 MB/sec [4K blocks]
Uncached Write 74.26 42.01 MB/sec [256K blocks]
@mattstevens
mattstevens / gist:989296
Created May 24, 2011 18:15
Monitoring for IP address changes
#import "NetworkMonitor.h"
NSString *NetworkConfigurationDidChangeNotification = @"NetworkConfigurationDidChangeNotification";
void storeCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) {
[(NetworkMonitor *)info update];
}
@implementation NetworkMonitor
@mattstevens
mattstevens / AppStoreReceipt.h
Created October 19, 2011 02:04
An insecure but simple method of validating Mac App Store receipts using only Security.framework.
#import <Cocoa/Cocoa.h>
BOOL VerifyAppStoreReceipt();
BOOL VerifyAppStoreReceiptData(NSData *data);
NSURL *BackupReceiptURL();
void BackupAppStoreReceipt();
NSData *MACAddressData();
NSDictionary *DictionaryFromAppStoreReceipt(NSData *fullData);
#import <Foundation/Foundation.h>
#import <Security/Security.h>
static const char *public_key = "-----BEGIN DSA PUBLIC KEY-----\n"
"MIHxMIGoBgcqhkjOOAQBMIGcAkEAvPM8vp7lHRrWFhpso2I/Wrq1qV8TSl7/YITH\n"
"7cHsINCP/xrZZpTlx14pKNkKwEEf3t3bdkKY97NQKRJ+cIRyawIVAMDJQP8l7EVy\n"
"fcqtVnJjJupPIccxAkBhLjwIRUNerlWb0kW357ABc4+65XB90lQIdcwVLGqRsx9A\n"
"wKoeeMUEyVdQhjJMnclvYJU+xqnl2AP9224QOGGLA0QAAkEAkFQyL1jGMfEjer1O\n"
"QjBq7knMY8zHEUVNRbPXBNS5QenFg07rgMUFL/Bj6/876pWvubwpDAcXkiK+SR3A\n"
"FRF/VA==\n"
@mattstevens
mattstevens / gist:3540222
Created August 30, 2012 20:34
NSDate for next minute
NSDate *now = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *nowComponents = [calendar components:NSSecondCalendarUnit fromDate:now];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setMinute:1];
[offsetComponents setSecond:-[nowComponents second]];
NSDate *nextMinute = [calendar dateByAddingComponents:offsetComponents toDate:now options:0];
NSTimeInterval interval = [nextMinute timeIntervalSinceDate:now];