Skip to content

Instantly share code, notes, and snippets.

View zerowidth's full-sized avatar

Nathan Witmer zerowidth

View GitHub Profile
@zerowidth
zerowidth / atom_id.rb
Created April 8, 2013 03:21
Jekyll liquid tag for creating atom ids for atom feeds
module Jekyll
module AtomId
# from http://diveintomark.org/archives/2004/05/28/howto-atom-id
def atom_id(post)
"#{post["date"].strftime("%Y-%m-%d")}:#{post["date"].to_i}"
end
end
end
Liquid::Template.register_filter(Jekyll::AtomId)
@zerowidth
zerowidth / build.sh
Last active January 4, 2016 10:08
stripe ctf level 3 loves ruby
#!/bin/sh
set -e
# Add or modify any build steps you need here
cd "$(dirname "$0")"
ruby --version
mkdir -p ./gems
@zerowidth
zerowidth / clipboard.vim
Created September 4, 2013 17:20
filenames + clipboard + vim
""" copy filename of current file to clipboard
map <Leader>cf :silent exe '!echo -n % \| pbcopy'<CR>:echo bufname('%')<CR>
""" edit filename from clipboard
map <silent> <Leader>ef :call EditFromClipboard()<CR>
function EditFromClipboard()
let filename = expand(fnameescape(system('pbpaste')))
if filereadable(filename)
exe 'edit ' . filename
@zerowidth
zerowidth / boulder.md
Created August 11, 2013 22:24
Boulder Brain Dump

What even is a Boulder

Here's about 10 minutes of brain dump that could become its own guide with lot more care and attention.

Where to stay

  • Hotel Boulderado: it's right downtown, and walking distance to just about everything
  • Quality Inn & Suites, still downtown-ish.
  • St. Julien, if you're feeling fancy.
@zerowidth
zerowidth / out.txt
Last active December 14, 2015 11:59
output of toml-test run for toml-parslet library
1.9.3-p385 macallan:~/Desktop/toml-test (master)? ▸ ./toml-test /Users/nathan/code/toml-parslet/script/toml-test.sh
Test: duplicate-keygroups (invalid)
Expected an error, but no error was reported.
-------------------------------------------------------------------------------
Test: duplicate-keys (invalid)
Expected an error, but no error was reported.
-------------------------------------------------------------------------------
Test: empty-implicit-keygroup (invalid)
(ns clj-shared-resource.coordinated)
; define a few helper functions
(defn thread-id []
(.getId (Thread/currentThread)))
; because stdout isn't synchronized:
(def logger (agent nil))
(defn log [& msgs]
(send-off logger (fn [_] (apply println (cons ";" msgs)))))
@zerowidth
zerowidth / grid.hs
Created February 4, 2013 05:50
My solutions for adventure.cueup.com, written in Haskell as an exercise. I first solved this puzzle using hacked-together ruby, but the algorithms here are essentially the same. The search in particular is not optimal, as it's a depth-first search rather than using any sort of cost heuristic to search the best paths first, but it works, and I go…
module Grid where
import Control.Monad
type Pos = Int
type Cost = Int
type Path = [Pos]
type Grid = [Cost]
type GridSize = Int
type CostFn = (Grid -> Path -> Cost)
@zerowidth
zerowidth / bash_profile.sh
Created January 3, 2013 16:21
custom test runners with bash / fuubar / test/unit. hacks heaped upon hacks for a particular dev environment.
# http://www.linuxjournal.com/content/use-date-command-measure-elapsed-time
function timer() {
if [[ $# -eq 0 ]]; then
echo $(date '+%s')
else
local stime=$1
etime=$(date '+%s')
if [[ -z "$stime" ]]; then stime=$etime; fi
@zerowidth
zerowidth / apple_usb_keyboard.txt
Last active October 18, 2015 04:34
usbconfig output for apple keyboard
# usbconfig -u 3 -a 3 dump_device_desc
ugen3.3: <Apple Keyboard Apple, Inc> at usbus3, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (20mA)
bLength = 0x0012
bDescriptorType = 0x0001
bcdUSB = 0x0200
bDeviceClass = 0x0000
bDeviceSubClass = 0x0000
bDeviceProtocol = 0x0000
bMaxPacketSize0 = 0x0008
@zerowidth
zerowidth / mountain_lion.md
Created July 27, 2012 19:43
Mountain Lion and You
  • stay calm
  • do not approach, and give it a way to escape
  • do not run, as it may encourage it to chase you
  • do not crouch or bend over, as you may look more like a 4-legged prey animal
  • do all you can to appear larger. raise your arms and open your jacket.

Installing

  • install Mountain Lion
  • Upgrade XCode