Skip to content

Instantly share code, notes, and snippets.

View kwstannard's full-sized avatar

Wolf kwstannard

  • Andros
  • New York City
View GitHub Profile
@kwstannard
kwstannard / gist:3130154
Created July 17, 2012 15:36
Indent, trailing whitespace, and long line highlighting
highlight LongLines guibg=#333300
au BufWinEnter * call matchadd('LongLines', '^.\{80,119}$', -1)
highlight VeryLongLines guibg=#330000
au BufWinEnter * call matchadd('VeryLongLines', '^.\{120,}$', -1)
highlight Indent9 guibg=#645640
au BufWinEnter * call matchadd('Indent9', '^\s\{20}\&^\s\{17}', -1)
highlight Indent8 guibg=#564832
@kwstannard
kwstannard / gist:3492093
Created August 27, 2012 20:49
Refinements polymorphism?
module Animal
end
module Runner
refine Animal do
puts "I have #{legs} and I'm running!"
end
end
Dog.include Animal
@kwstannard
kwstannard / gist:3532475
Created August 30, 2012 16:31
Testing modules
module Foo
def bar
"A cow"
end
end
describe Foo
let :subject_class { Class.new }
let :subject { subject_class.new }
refinement Runner
def run
puts "I have legs and I am running"
end
end
object = Object.new
do
@kwstannard
kwstannard / gist:3834222
Created October 4, 2012 15:08
evaluate in psql
mobi_dev=# create or replace function eval (expression text, arg text, val text) returns boolean
as
$body$
declare
result boolean;
begin
execute replace(replace(expression, 'arg', '''' || arg || ''''), 'val', '''' || val || '''') into result;
return result;
end;
$body$
colorscheme camo
set nocompatible
set background=dark
set noautoindent smartindent
set expandtab
set softtabstop=2
set shiftwidth=2
set hlsearch " highlight search results
set nowrap " don't wrap lines
#!/bin/sh
# Taken from febuiles on github.
# This assumes you have:
# 1) A user called `hubot` in charge of the bot.
# 2) A file called /home/hubot/.hubotrc that contains the Hubot credentials.
#
# To set the adapter either edit bin/hubot to specify what you want or append
# `-- -a campfire` to the $DAEMON variable below.
function git_contributions() {
shortstat=$(git log --author=$1 --oneline --shortstat | grep deletions)
`/usr/bin/env ruby <<-RUBY
additions = 0
deletions = 0
%[ $shortstat ].each_line do |line|
addition_matches = line.match(/(\d+) insertions/)
additions += addition_matches[1].to_i if addition_matches
arg = `echo $COUNT_CALLS_TO`
KLASS, METHOD = *arg.split('#').map(&:strip)
module MethodCounter
module ClassMethods
@@method_times_run_var = 0
def method_times_called
@@method_times_run_var
end
@kwstannard
kwstannard / gist:5030824
Last active December 14, 2015 04:49
vimrc relative numbering. Leaves relative numbering on loss of focus and on entering insert mode. Re-enters when appropriate.
set relativenumber
au InsertEnter * :set number
au InsertLeave * :set relativenumber
function! FocusGainNumbering()
if(mode() == 'i')
:set number
else
:set relativenumber