Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / .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 / 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