Skip to content

Instantly share code, notes, and snippets.

View wezm's full-sized avatar

Wesley Moore wezm

View GitHub Profile
@wezm
wezm / net.wezm.squid.plist
Created January 13, 2013 02:40
launchd launch agent for squid installed via Homebrew, place in ~/Library/LaunchAgents.
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>net.wezm.squid</string>
<key>ProgramArguments</key>
<array>
@wezm
wezm / process.awk
Created August 9, 2012 00:07
Script to extract stats from web server access logs
#!/usr/bin/awk
BEGIN {
# Use tab as output field separator
OFS=" "
}
# Extracts the device family from the full device
# E.g iPhone from iPhone4,1
function device(full) {
@wezm
wezm / LICENSE
Created November 25, 2011 01:34
RPAlertView blocks based wrapper around UIALertView that uses objc_setAssociatedObject to bind the lifetime of the wrapper to the alert view.
Copyright (C) 2011 by TrikeApps Pty Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@wezm
wezm / strip.sh
Created August 27, 2011 09:25
Strip trailing whitespace in modified files tracked by git
#!/bin/sh
git ls-files --modified '*.[hm]' | xargs sed -i '.bak' 's/[[:space:]]*$//'
@wezm
wezm / Benchmark results.md
Created June 3, 2011 01:41 — forked from tsommer/gist:1005660
Given a list of directories, filter out all folders that have sub dirs
======= /etc Paths =======
                      user     system      total        real
Adam              0.210000   0.000000   0.210000 (  0.215259)
Andre             0.210000   0.000000   0.210000 (  0.207338)
David             0.090000   0.000000   0.090000 (  0.089603)
Pete              0.200000   0.000000   0.200000 (  0.201303)
Tim               0.010000   0.000000   0.010000 (  0.009618)
Tom               6.000000   0.000000   6.000000 (  5.998718)
Wes               0.000000   0.000000   0.000000 (  0.001508)

======= Random Paths =======

// This block is invoked when a row in the table view is chosen.
// The table view lists the weekdays from Mon-Sun, so the desiredWeekday line
// is about converting to a system where Sunday is 1
controller.didSelectObjectBlock = ^(id obj, NSUInteger idx) {
NSInteger desiredWeekday = (idx + 2) % 7;
// Set self.date to a date corresponding to the nearest chosen
// weekday in the future
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *today = [NSDate date];
@wezm
wezm / site.nu
Created May 12, 2011 07:13
My Vico site.nu
# Tab switching
# As of r1921 these are provided in keys.nu
#((ViMap normalMap) map:"<cmd-{>" to:"gT")
#((ViMap normalMap) map:"<cmd-}>" to:"gt")
((ViMap insertMap) map:"<cmd-{>" to:"<esc>gT")
((ViMap insertMap) map:"<cmd-}>" to:"<esc>gt")
# Enable command-s (save) in insert mode
((ViMap insertMap) map:"<cmd-s>" to:"<esc>:w<cr>")
@wezm
wezm / Makefile
Created May 11, 2011 23:23
Text processor for some strangely formatted geo data
CFLAGS = -O2 -Wall $(OPTFLAGS)
CC = clang
SOURCES = $(wildcard *.c)
OBJECTS := $(patsubst %.c, %.o, $(SOURCES))
all : main
main : $(OBJECTS)
$(CC) -o main $(CFLAGS) $(OBJECTS)
@wezm
wezm / Railscasts-wezm.xccolortheme
Created February 19, 2011 18:05
My attempt at a Railscasts inspired theme for Xcode
<?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>Colors</key>
<dict>
<key>Background</key>
<string>0.169 0.169 0.169</string>
<key>InsertionPoint</key>
<string>1.000 1.000 1.000</string>
@wezm
wezm / xmlpipe2.js
Created January 28, 2011 17:12
Example of using genx to generate a Sphinx xmlpipe2 stream
var genx = require('genx')
, http = require('http')
, jsdom = require('jsdom').jsdom
, qs = require('querystring');
function generateXml(body) {
var w = new genx.Writer()
, window = jsdom(body, null, {
features: {
FetchExternalResources: false,