Skip to content

Instantly share code, notes, and snippets.

View coldnebo's full-sized avatar

Larry Kyrala coldnebo

View GitHub Profile
@coldnebo
coldnebo / Default (OSX).sublime-keymap -- User
Created February 3, 2012 16:21
Sublime Text 2 fix for OSX home/end keys
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }
@coldnebo
coldnebo / error.sh
Created August 31, 2011 19:54
[FIXED] ruby encodings... can we word this error differently?
$ irb
ruby-1.9.2-p180 :001 > "“"
=> "“"
ruby-1.9.2-p180 :002 > "“".encoding
=> #<Encoding:UTF-8>
ruby-1.9.2-p180 :003 > "\“"
SyntaxError: (irb):7: invalid multibyte char (UTF-8)
(irb):7: invalid multibyte char (UTF-8)
from /local/rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
@coldnebo
coldnebo / bind_cursor.bash
Created August 18, 2011 18:44
bash helper to navigate directory stacks
# I use pushd and popd to maintain a directory stack and so I like being able to navigate
# around the stack with the cursor keys. Here's how:
# 1) pushd <new dir>
# 2) use CTRL+UP, CTRL+LEFT or CTRL+RIGHT as follows:
# bind ctrl + cursor keys:
# left = prev; right = next; up = list
bind '"\e[1;5A":"dirs\C-m"'
bind '"\e[1;5D":"pushd -0 2>/dev/null\C-m"'
bind '"\e[1;5C":"pushd +1 2>/dev/null\C-m"'
@coldnebo
coldnebo / minecraft-sethd.ps1
Created August 16, 2011 02:39
win7 powershell script to automatically resize a minecraft window for 1280x720 HD fraps recording.
# Win7 Powershell script to resize Minecraft to 1280x720 (HD for fraps youtube capture)
# use by typing the following at a command prompt:
# > PowerShell -ExecutionPolicy Bypass -File minecraft-sethd.ps1
# refs:
# http://stackoverflow.com/questions/2556872/how-to-set-foreground-window-from-powershell-event-subscriber-action
# http://richardspowershellblog.wordpress.com/2011/07/23/moving-windows/
# http://www.suite101.com/content/client-area-size-with-movewindow-a17846
@coldnebo
coldnebo / Default (Linux).sublime-keymap
Created August 10, 2011 23:20
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]
@coldnebo
coldnebo / Default (Linux).sublime-keymap
Created July 5, 2011 20:12
simple script to checkout files with perforce while in sublime text 2
[
{ "keys": ["f8"], "command": "p4_edit" }
]
@coldnebo
coldnebo / string_patch.rb
Created June 9, 2011 18:49
ruby 1.9.2 character encoding helper
class String
def hexbytes
self.bytes.to_a.map {|c| c.to_s(16).upcase}.join
end
def hexchars
self.chars.to_a.map {|c| c.hexbytes}
end
def unicodechars
@coldnebo
coldnebo / Rakefile
Created June 1, 2011 23:50
patch for rake in ruby-1.9.2-p180
# testing rakefile
task :default do
sh('exit 1')
end
@coldnebo
coldnebo / gist:832527
Created February 17, 2011 19:58
blog: example of possible ruby xml marshaling...
<foo>
<bar @mike="hi">
<ug>what</ug>
<ug>who</ug>
</bar>
</foo>
> foo.bar.mike # = "hi"
> foo.bar.ug # = ["what", "who]
> foo.bar.ug[0] # = "what"
@coldnebo
coldnebo / lambda_no_call.rb
Created July 28, 2010 20:07
blog: how to call lambdas without call()
# inspired by the protovis library pv.Scale.linear().range()
# adapted from rspec codebase
def let(name, scale_function)
Kernel.send :define_method, name do |p|
scale_function.call(p)
end
end
# returns a mapping function from the desired domain (x1,x2) to the desired range (y1,y2)