This file contains 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
everywhere=$(ag '^\s*require' -w --ruby --no-numbers --ignore=test/ --ignore=tasks/ --ignore=scripts/ | awk -F: '{gsub(/^ */, "", $2); print $2}' | sort | uniq) | |
shotgun=$(ag '^\s*require' -w --no-numbers shotgun.rb) | |
echo "$everywhere" | grep -v -f <(echo "$shotgun") |
This file contains 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 "benchmark" | |
$baz = nil | |
class Foo | |
def self.foo | |
@foo || $baz | |
end | |
end |
This file contains 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 "benchmark" | |
COUNT = 1_000_000 | |
@status = 200 | |
Benchmark.bm(20) do |x| | |
x.report("noop") do | |
COUNT.times { } | |
end |
This file contains 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
Node = Struct.new(:value, :children) | |
tree = Node.new( | |
1, | |
[ | |
Node.new( | |
2, | |
[Node.new(5, []), Node.new(6, [])] | |
), |
This file contains 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
#!/bin/bash | |
usage() { | |
cat >&2 <<EOS | |
Usage: vim-install <Git URL> | |
EOS | |
exit 1 | |
} |
This file contains 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
# If some requests in your web application fail but subsequent requests don't, | |
# you may be a victim of Kernel#autoload. | |
# | |
# As you know, Kernel#autoload is not thread-safe. Moreover, missing constants | |
# trigger requiring other files, which can some times do more than just provide | |
# that missing constant. Yet many libraries still use it: | |
# https://github.com/search?l=ruby&q=autoload+language%3Aruby&type=Code | |
# | |
# So if you think you're having any of these issues, this middleware should be | |
# able to provide a hint as to which files are the ones you should be requiring |
This file contains 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 File.expand_path("helper", File.dirname(__FILE__)) | |
setup do | |
users = Cuba.new do | |
on get do | |
on "foo" do | |
res.write "foo" | |
end | |
on "bar" do |
This file contains 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 "redis/pool" | |
require "ohm" | |
# The current version of Ohm (1.3.2) does not use Redis.current, so we need to | |
# monkey patch or create a base class for models. | |
class Ohm::Model | |
def self.db | |
Redis.current | |
end | |
end |
This file contains 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 "cuba" | |
module Cuba::Routable | |
def self.setup(app) | |
app.define do | |
self.class.routes.each do |route, app| | |
on(route) { run(app) } | |
end | |
end | |
end |
This file contains 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_relative "benchmark" | |
require "ffaker" | |
require "batch" | |
redis = Redis.connect | |
until (begin; redis.ping; rescue; nil; end); end | |
class Post < Ohm::Model |