Skip to content

Instantly share code, notes, and snippets.

Nathan Witmer zerowidth

Block or report user

Report or block zerowidth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
zerowidth / portal.rb
Last active Nov 18, 2019
Calculations for siting a Minecraft portal in the nether
View portal.rb
require "set"
exclusion = 8 # one nether block distance, or 8 overworld
existing = [[-743, 63, -39], [-743, 63, -40]]
targets = [[-791, 152, -48], [-792, 152, -48], [-793, 152, -48]]
existing_nether = [[-87, 67, -4]]
search_from = existing_nether.first
zerowidth / port_tables.rb
Created Feb 14, 2013
Script to parse a text table and convert to a reasonable output. Demonstration of an idiomatic ruby script for a friend.
View port_tables.rb
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
zerowidth / paginated_collection.js
Created Nov 18, 2010
first whack at pagination with backbone.js
View paginated_collection.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage'); = 1;
fetch: function(options) {
options || (options = {});
zerowidth / do-stuff.rb
Created Jan 23, 2018
do-stuff to make git commits for demonstration purposes
View do-stuff.rb
#!/usr/bin/env ruby
require "pathname"
class RandomEditor
def initialize
@files =".")
def run(iterations = 1, commit = false)
iterations.times do
zerowidth /
Last active Jul 18, 2017
A brief discusson on git workflow preferences (now published on

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

zerowidth /
Last active Apr 11, 2017
GitHub::SQL - a helping hand for SQL in a rails app


GitHub::SQL has been released as an officially-maintained project and ruby gem: github/github-ds.

zerowidth / music.rb
Created May 7, 2012
A functional, lazily-evaluated solution to for a "coding challenged" competition
View music.rb
Proc.module_eval { def method_missing(m,*a); call(m.to_s,*a); end }
Array.module_eval { def rest; self[1..-1]; end }
Object.module_eval { def let; yield self; end }
Music = do
def self.load(filename)
depth = ->(l) { %r(^([\s-]*)\w).match(l)[1].length }
ldepth = ->(l) { %r(^(\s*)\S).match(l)[1].length }
nonzero = ->(n) { n > 0 }
empty = ->(c) { c.empty? }
zerowidth / coffeescript.rb
Created Apr 8, 2013
Jekyll plugins for rendering compass stylesheets and auto-converting coffeescript files without requiring YAML front-matter.
View coffeescript.rb
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 / highlight_indent_fix.rb
Created Apr 8, 2013
Jekyll monkeypatch to strip leading space from indented `highlight` liquid blocks
View highlight_indent_fix.rb
Jekyll::Tags::HighlightBlock.module_eval do
def render(context)
code = strip_leading_space_from super
if context.registers[:site].pygments
render_pygments(context, code)
render_codehighlighter(context, code)
zerowidth / atom_id.rb
Created Apr 8, 2013
Jekyll liquid tag for creating atom ids for atom feeds
View atom_id.rb
module Jekyll
module AtomId
# from
def atom_id(post)
You can’t perform that action at this time.