Skip to content

Instantly share code, notes, and snippets.

View ryansch's full-sized avatar

Ryan Schlesinger ryansch

View GitHub Profile
"let g:solarized_visibility="normal"
"let g:solarized_specialbg="off"
"color solarized
color ry-solarized
"color torte
"highlight NonText guifg=#4a4a59
"highlight SpecialKey guifg=#4a4a59
@ryansch
ryansch / redis-em.mdown
Created May 25, 2011 20:44 — forked from zacharyvoase/redis-em.mdown
Redis + EventMachine - CPS == WIN.

A (Nicer) Redis Client for EventMachine

Redis is my favourite key/value store; it’s flexible, easy to set up and insanely fast. [EventMachine][] is a popular Ruby library for doing asynchronous I/O using an event loop. Bindings already [exist][em-redis] for accessing a Redis server using EM’s async-I/O (courtesy of Jonathan Broad), but unfortunately the resulting code has to use [Continuation-Passing Style][cps] via Ruby blocks. A very basic example of what that looks like follows:

@ryansch
ryansch / s3up.py
Created May 17, 2011 22:51 — forked from mtigas/0001.markdown
Command-line s3 uploader that uses the MultiPart (chunked) S3 upload functionality to parallelize and speed up large file uploads.
#!/usr/bin/env python
# coding=utf-8
#
# s3up.py
# 2010-2011, Mike Tigas
# https://mike.tig.as/
#
# Usage:
# s3up filename
# Uploads the given file to the DEFAULT_BUCKET (see below)
# hack for the chef - we cannot read file in http_request resource
ruby_block "Set attributes for http request for #{database[:name]} #{database[:kind]}" do
block do
request = resources(:http_request => "Create backup record for #{database[:name]} #{database[:kind]}")
request.message({:backup => {:filename => compressed_file_name, :kind => database[:kind], :size => File.size(compressed_file_path)}})
end
end
http_request "Create backup record for #{database[:name]} #{database[:kind]}" do
url "http://some-url/backups"
undefined method `[]' for nil:NilClass
The error occurred line 73 of /path/to/lib/ruby/gems/1.8/gems/mixlib-log-1.1.0/lib/mixlib/log.rb in method 'level' while executing:
71 def level(lv=nil)
72 if lv.nil?
** @@levels.find() {|l| logger.level==l[1]}[0]
74 else
75 self.level=(lv)
ruby_block "rvm use default" do
block do
Chef::Mixin::Command.popen4('bash -l -c "rvm use default && env"') do |p,i,o,e|
o.each_line do |line|
next if line.nil?
line.chomp!
next if line.empty?
env_bits = line.split("=")
ENV[env_bits[0]] = env_bits[1]
require 'rubygems/format'
define :rvm_cookbook_gem, :action => :install do
remote_file params[:name] do
action :create_if_missing
backup false
end
ruby_block "Load gemspec and install gem" do
block do
ps1_rvm()
{
if command -v rvm-prompt >/dev/null 2>/dev/null ; then
if [[ ! $(rvm-prompt) == $OLD_RVM ]]; then
export OLD_RVM=$(rvm-prompt)
printf "$(rvm-prompt) "
fi
fi
}
color ry-solarized
"color torte
"highlight NonText guifg=#4a4a59
"highlight SpecialKey guifg=#4a4a59
set guifont=Menlo:h12
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
@ryansch
ryansch / mysql_error.log
Created April 8, 2011 23:25
mysql2 gem error
$ rake -T
(in /home/bar/foo)
rake aborted!
/usr/local/rvm/gems/ruby-1.9.2-p180@foo/gems/mysql2-0.2.7/lib/mysql2/mysql2.so: undefined symbol: rb_prohibit_interrupt - /usr/local/rvm/gems/ruby-1.9.2-p180@foo/gems/mysql2-0.2.7/lib/mysql2/mysql2.so
/home/bar/foo/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)