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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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:¬ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 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) |