Skip to content

Instantly share code, notes, and snippets.

@gruis
gruis / popen3.rb
Created November 2, 2011 11:32 — forked from tokland/external-command.rb
Capture stderr data on EventMachine.popen
#!/usr/bin/env ruby -wW1
require 'eventmachine'
module EventMachine
# @see http://eventmachine.rubyforge.org/EventMachine.html#M000491
def self.popen3(cmd, handler=nil, *args)
klass = klass_from_handler(Connection, handler, *args)
w = Shellwords::shellwords(cmd)
w.unshift(w.first) if w.first
@gruis
gruis / .vimrc.local
Created November 16, 2011 05:20
home directory
set guifont=Inconsolata:h10.5
colors ir_black
" cspoc binary files are Ruby
au BufRead,BufNewFile cspoc-* set ft=ruby
" map CMD-SHFT-M to :TList
map <D-M> :Tlist<CR>
" have Taglist gain focus when you open it
let Tlist_GainFocus_On_ToggleOpen = 1
@gruis
gruis / demo.rb
Created February 12, 2012 05:09
Unblocking the keyboard in EventMachine
#!/usr/bin/env ruby -wW1
require File.expand_path("../nb-keyboard", __FILE__)
EM.run {
spinner = EventMachine::PeriodicTimer.new(0.5) do
$stderr.print "."
end
Fiber.new {
EM.open_keyboard(NbKeyboard) do |kb|
@gruis
gruis / gist:1840492
Created February 16, 2012 01:06 — forked from pwim/gist:1188099
Trying different encodings under Ruby 1.9
escaped = CGI.unescape(query)
return escaped if escaped.valid_encoding?
%w[EUC-JP Shift_JIS].each do |encoding|
s = escaped.force_encoding(encoding)
return s.encode("UTF-8") if s.valid_encoding?
end
escaped
@gruis
gruis / .tmux.conf
Created November 15, 2012 11:03
.files
unbind C-b
set -g prefix C-a
setw -g utf8 on
set-option -g utf8 on
set-option -g status-utf8 on
set -g default-terminal "screen-256color"
set-option -g visual-activity on
@gruis
gruis / Gemfile
Created November 19, 2012 14:49
Migrate nested SVN repositories to Git
source :rubygems
gem "svn2git", "~>2.2"
require 'rubygems'
require 'eventmachine'
children = []
Signal.trap('SIGINT') do
EventMachine.next_tick { EventMachine.stop_event_loop }
end
Signal.trap('EXIT') do
require 'rubygems'
require 'eventmachine'
children = []
Signal.trap('SIGINT') do
EventMachine.next_tick { EventMachine.stop_event_loop }
end
Signal.trap('EXIT') do
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArqNqtISknd/SnyNFppo+9x484VFZRTJoEpLMWcyPk9+bvRiiLkkZs3SUxjRrweBFvJUzRHqI9/KzPsvUXDzU1ngFU4V8M1yfQPt+kmouF8ZniSyB/lQUu8UZT9K4O3Eh123wj8kMS+KiBe3BV1YDBtQ8kjWnS8jMmyhY2S+msq64mK1cPFN60hNGfl5rFOHc9Uj+f/tFcBGO/UdguTLxlQ3w+RCXy2CQsSBOlaOmSrZAsLaCrIH2bZbBDeXxPvPyAKeufd8aM6n0wbLg3e83AsFSm+IOYaMgMJ89weLp78WngXb+5X3Jt/1y9HB1KbLH3rQz6yzr8DgoHduv3GfOow== calebcrane@Cubert.local
@gruis
gruis / keybase.md
Last active June 4, 2018 22:51
Keybase

Keybase proof

I hereby claim:

  • I am gruis on github.
  • I am simulacre (https://keybase.io/simulacre) on keybase.
  • I have a public key ASA1-P7TD9C7M4fYQJnlIgfRVA2DGe1Ri4tXfnVdfG8U3go

To claim this, I am signing this object: