Skip to content

Instantly share code, notes, and snippets.

View zerowidth's full-sized avatar

Nathan Witmer zerowidth

View GitHub Profile
@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 / 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 / highlight_indent_fix.rb
Created April 8, 2013 03:20
Jekyll monkeypatch to strip leading space from indented `highlight` liquid blocks
Jekyll::Tags::HighlightBlock.module_eval do
def render(context)
code = strip_leading_space_from super
if context.registers[:site].pygments
render_pygments(context, code)
else
render_codehighlighter(context, code)
end
end
@zerowidth
zerowidth / coffeescript.rb
Created April 8, 2013 03:16
Jekyll plugins for rendering compass stylesheets and auto-converting coffeescript files without requiring YAML front-matter.
require "coffee-script"
module Jekyll
# Automatically force coffeescript files to be compiled, even if they don't
# have the YAML front-matter.
class CoffeeConvertor < Generator
def generate(site)
converted = []
site.static_files.each do |sf|
@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 / port_tables.rb
Created February 14, 2013 03:23
Script to parse a text table and convert to a reasonable output. Demonstration of an idiomatic ruby script for a friend.
require "pp"
def convert_to_offsets(widths)
offsets = []
position = 0
widths.each.with_index do |width, index|
offsets << (position...(width+position)) # range does not include the end
position += width + 1 # assume spacing of 1 character
end
@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 / git-workflow.md
Last active July 18, 2017 17:50
A brief discusson on git workflow preferences (now published on zerowidth.com)

A colleague asks [slightly edited]:

Why didn't you squash your [feature branch merge] commit? I'm new to [project], but I found on [other project] that squashed commits made it much easier to git bisect. And since the [project] test suite is broken frequently, I assume we'll be git bisecting a lot. Un-squashed commits tended to leave broken tests or functionality that never actually shipped.

Git, because it's just "the stupid content tracker", is flexible enough to support just about any development workflow you can think of. You can use pull