Skip to content

Instantly share code, notes, and snippets.

ruby-1.9.3-p194:
system:
uname: "Linux tsiyon 3.3.2-gentoo #3 SMP Sun Apr 22 02:47:35 MDT 2012 x86_64 Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz GenuineIntel GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.2.20(1)-release (x86_64-pc-linux-gnu)"
zsh: "/bin/zsh => zsh 4.3.15 (x86_64-pc-linux-gnu)"
rvm:
version: "rvm 1.13.4 () by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
#!/bin/env ruby
def broken
people = Hash.new([])
people['a'].push 1
people['b'].push 2
p people
end
broken
--- Terminal codes ---
t_AB=^[[4%p1%dm t_db= t_ms=y t_ue=^[[24m
t_AF=^[[3%p1%dm t_DL=^[[%p1%dM t_nd=^[[C t_us=^[[4m
t_AL=^[[%p1%dL t_dl=^[[M t_op=^[[39;49m t_vb=^[g
t_al=^[[L t_fs= t_RI=^[[%p1%dC t_vi=^[[?25l
t_bc= t_IE= t_RV= t_vs=^[[34l
t_cd=^[[J t_IS= t_Sb= t_WP=
t_ce=^[[K t_ke=^[[?1l^[> t_Sf= t_WS= t_cl=^[[H^[[J t_ks=^[[?1h^[= t_se=^[[23m t_SI=
t_Co=256 t_le=^H t_so=^[[3m t_EI=
t_CS= t_mb=^[[5m t_sr=^[M t_xs=
@ryanjosephking
ryanjosephking / vim-pager
Created April 11, 2012 03:36
Use vim like "less". Makes "space" page downwards and Ctrl+c quit.
#!/bin/sh
# Use vim like "less". Makes "space" page downwards and Ctrl+c quit.
if [ -z "$STAYOPEN" ]; then
EXTRA_COMMANDS='redraw|if (&lines - 3) > line("$")|echo "# Quick-quit enabled. Maybe set env var STAYOPEN=1 ?"|q|end'
else
EXTRA_COMMANDS=':'
fi
vim - \
#!/bin/sh
# Use vim like "less". Makes "space" page downwards and Ctrl+c quit.
if [ -z "$STAYOPEN" ]; then
EXTRA_COMMANDS=+'redraw|if &lines > getpos("$")[1]|q|end'
else
EXTRA_COMMANDS=+'exec "set tw=".&tw' # noop
fi
vim - \
@ryanjosephking
ryanjosephking / foo.py
Created April 8, 2012 17:11
Trying to get unittest to be vocal only on failure.
#!/bin/env python
import unittest
class TestFoo(unittest.TestCase):
def test_bar(self):
# This much should be silent.
self.assertEquals(1,1)
# ...but this should still stop the script:
# self.assertEquals(2,1)
if __name__ == '__main__':
@ryanjosephking
ryanjosephking / Debugging Ruby
Created April 6, 2012 15:06
A couple of ways to drop into a debugger
require 'pry'
binding.pry
require 'ruby-debug'; Debugger.start; Debugger.settings[:autoeval] = 1; Debugger.settings[:autolist] = 1; debugger