Skip to content

Instantly share code, notes, and snippets.

View shadoi's full-sized avatar

Blake Barnett shadoi

  • Apple
  • San Francisco
View GitHub Profile
main.rs:18:5: 18:13 error: cannot move out of `yaml_str` because it is borrowed
main.rs:18 yaml_str
^~~~~~~~
main.rs:16:45: 16:53 note: borrow of `yaml_str` occurs here
main.rs:16 let mut emitter = YamlEmitter::new(&mut yaml_str);
@shadoi
shadoi / main.rs
Last active August 29, 2015 14:27
#[macro_use]
extern crate nickel;
extern crate yaml_rust;
use nickel::{ Nickel, HttpRouter };
use yaml_rust::{ Yaml, YamlEmitter };
mod yaml_handler;
fn get_yaml() -> String {
@shadoi
shadoi / keybase.md
Created June 3, 2015 22:29
keybase.io identity proof

Keybase proof

I hereby claim:

  • I am shadoi on github.
  • I am shadoi (https://keybase.io/shadoi) on keybase.
  • I have a public key whose fingerprint is 1ED7 5BF9 10BB 6C09 2C22 2E9B B0F5 9B35 4723 7AE5

To claim this, I am signing this object:

# Write a method that takes a string in and returns true if the letter
# "z" appears within three letters **after** an "a". You may assume
# that the string contains only lowercase letters.
#
# Difficulty: medium.
# may want to do max+1 as base-zero can be confusing
def x_after_y?(str, char1, char2, max)
range = Range.new(1, max)
str.slice!(str.chars.index(char1))
@shadoi
shadoi / conc_test.rb
Created April 3, 2014 01:27
Reel 0.4.0 concurrency test
require 'rack'
require 'sinatra/base'
require 'json'
require 'reel/rack'
class ConcTest < Sinatra::Base
configure do
enable :logging
set :logging, :debug
set :environment, :production
irb(main):025:0> conn = Net::HTTP.new(uri.host, uri.port)
=> #<Net::HTTP 127.0.0.1:3000 open=false>
irb(main):026:0> req = Net::HTTP::Get.new('http://127.0.0.1:3000/stuff')
=> #<Net::HTTP::Get GET>
irb(main):027:0> conn.request(req) {|r| r.read_body}
EOFError: end of file reached
from /usr/lib/ruby/1.9.1/net/protocol.rb:141:in `read_nonblock'
from /usr/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
from /usr/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from /usr/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
@shadoi
shadoi / Makefile
Last active December 17, 2015 11:19
PKG_DIR := $(CURDIR)/debian/$(PACKAGE)
BIN_DIR := /usr/bin
MAN_DIR := /usr/share/man/man1
INC_DIR := /usr/include/$(PACKAGE)
LIB_DIR := /usr/lib
GEM_DIR := /usr/lib/rubinius/gems
export FAKEROOT=$(PKG_DIR)
configure: configure-stamp
Building digest
Unable to load the bytecode compiler. Please run 'rake' or 'rake install'
to rebuild the compiler.
An exception occurred
no such file to load -- /tmp/buildd/rubinius-2.0.0pre/lib/ext/melbourne/rbx/melbourne20 (LoadError)
Backtrace:
Rubinius::CodeLoader#load_error at kernel/common/codeloader.rb:391
Rubinius::CodeLoader#resolve_require_path at kernel/common/codeloader.rb:378
Using the following configuration to build
------------------------------------------
module Rubinius
# Make this reload friendly without silly constant defined warnings.
BUILD_CONFIG = {
:command_line => "--system-name=ubuntu-12.04 --bindir=/usr/bin --includedir=/usr/include/rubinius --libdir=/usr/lib --mandir=/usr/share/man/man1 --gemsdir=/usr/lib/rubinius/gems",
:which_ruby => :ruby,
:build_ruby => "/usr/bin/ruby1.9.1",
:build_rake => "rake",
:build_perl => "perl",
irb(main):001:0> module MyMod; define_method(:foo) do |test='test', bah| puts test; puts bah; end; end
=> #<Proc:0x00000001bbb470@(irb):1 (lambda)>
irb(main):002:0> include MyMod
=> Object
irb(main):003:0> foo
ArgumentError: wrong number of arguments (0 for 1)
from (irb):1:in `block in <module:MyMod>'
from (irb):3
from /usr/local/bin/irb:12:in `<main>'
irb(main):004:0> foo('asdf')