Skip to content

Instantly share code, notes, and snippets.

@hawx
hawx / NOTES.md
Created September 21, 2011 17:02
Run tests for all installed versions of ruby under rbenv

This took a while for me to work out, but essentially you need to remember two things:

  1. everything that needs to be prefixed with rbenv exec
  2. and everything that can be needs to be prefixed with bundle exec as well

The downside to this is that you need to add rake to your Gemfile. Just running rbenv exec rake will not work, for some reason.

@hawx
hawx / google.com.js
Created November 4, 2011 16:45
Fix Google Reader, for people who read in All Feeds sequentially with j/k
// for https://github.com/defunkt/dotjs, put in ~/.js/google.com.js
// there may be side effects put I haven't really noticed any
$('body').css('font', '1em/1.5em Georgia, Serif');
$('#top-bar').css('height', '0').css('opacity', '0');
$('#nav').css('display', 'none');
$('#chrome').css('margin-left', '0');
$('#entries').css('padding-right', '0');
$('#viewer-header').css('height', '0');
$('#title-and-status-holder').css('display', 'none');
@hawx
hawx / instance-class-def.rb
Created March 17, 2012 12:38
Define a instance method with a class method crazy-meta-ness
class Base
def self.method_missing(sym, *args, &block)
send :define_method, sym, (args.empty? ? block : args[0].to_proc)
end
end
class A < Base
intify :to_i
floatify :to_f
end
@hawx
hawx / README.md
Created March 30, 2012 17:34
It's like the people who designed java didn't imagine reading files would be a common task...

SimpleIO

Really who, WHO? designed java. It's so verbose it makes [something verbose] look simple. The designers must have been in a meeting, I guess this can only be the product of a TON of meetings, and they were all like here's an idea "let's make common tasks simple", and some other guy (probably middle-aged, balding with a harley said "yeah, like reading and writing to files". And then everyone in the room gave him the death stare, Dr Cooper style, and one guy just said "what, who needs to do that?". Everyone in the room just nodded like sheep.

Anyway this class makes life easier, less java-like if you will:

@hawx
hawx / config.h
Created April 9, 2012 16:35
My config for dvtm. Sets ^g as mod key, makes titlebar cyan & removes hash from titlebar
/* curses attributes for the currently focused window */
/* valid curses attributes are listed below they can be ORed
*
* A_NORMAL Normal display (no highlight)
* A_STANDOUT Best highlighting mode of the terminal.
* A_UNDERLINE Underlining
* A_REVERSE Reverse video
* A_BLINK Blinking
* A_DIM Half bright
@hawx
hawx / Guardfile
Created May 8, 2012 11:47
guard-shell with forking?
module Processes
extend self
def max
@max || 10
end
attr_writer :max
def processes
@processes ||= []
@hawx
hawx / tab-format.rb
Created May 15, 2012 18:06
Script to reformat ascii tabs to a given maximum width
#!/usr/bin/env ruby
#
# Usage: tab-format <max-width> <input-file>
# eg. tab-format 120 tango.txt > out.txt
#
# Reformats ascii tabs to different widths. Will complain if tab contains any
# other text. So <file> will look like (obviously with numbers in):
#
# E |---------- ...
# B |---------- ...
@hawx
hawx / meta-meta-meta.rb
Created June 19, 2012 13:00
A Journey Into the Meta
# Ruby _is_ meta-programming. Well maybe not, but I read somewhere that you
# should always start with a strong statement, even if not exactly true, then
# clarify it later.
#
# Anyway, meta-programming is amazing. Let's start with some stupid recursive
# definition thing...
class SelfDefining
def define(&block)
self.class.send(:define_method, :define, &block)
@hawx
hawx / prettymaker.sh
Created September 20, 2012 14:40
Make large prettymap maps.
#!/usr/bin/env sh
#
# Usage: prettymaker <start-row> <end-row> <start-col> <end-col>
#
# Prettymaker will pull map tiles from in the ranges specified at level 10
# zoom from prettymaps.stamen.com and build a massive map. Each tile is
# 256x256px so fully created map may be large!
#
# Note: run this in an empty folder, it deletes stuff during processing and
# may catch items you didn't want deleted.
@hawx
hawx / Monokai.css
Created October 17, 2012 08:55
Modified Monokai theme for Espresso
/*
@theme Monokai
@override-placeholders html, xml, css, sourcecode.js, sourcecode.php, sass, markdown
@author Derek Reynolds
@version 1.0b1
@original https://github.com/derekr/monokai.foam
This is a port of the Monokai theme for TextMate.
The original theme can be found at: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
TextMate can be found at: http://macromates.com/