Skip to content

Instantly share code, notes, and snippets.

def self.extract_data_from_yaml(yml_metrics_data)
metrics_data = {}
extract_flog_data!(metrics_data, yml_metrics_data)
extract_flay_data!(metrics_data, yml_metrics_data)
extract_reek_data!(metrics_data, yml_metrics_data)
extract_roodi_data!(metrics_data, yml_metrics_data)
extract_saikuro_data!(metrics_data, yml_metrics_data)
extract_churn_data!(metrics_data, yml_metrics_data)
metrics_data
end
def browse_string(body)
Tempfile.open('browse_string') do |f|
# I recommend starting testing command with
# BROWSER="open -a firefox" on OS X
browser = ENV.fetch('BROWSER') { 'firefox' }
f.write(body)
f.close
puts "Starting browser #{browser} with response..."
unless system(browser + " " + f.path)
warn "Error starting browser #{browser}"
require 'sinatra'
# Define a route
get "/foo" do
"x"
end
# Try to redefine it
get "/foo" do
"y"
require 'sinatra'
require 'rack'
require 'ruby-debug'
Sinatra::Application.reset!
configure do
use Rack::Reloader, 1
end
1) Failure:
test_spec {Rack::JSONP when a callback parameter is provided} 001 [should wrap the response body in the Javascript callback](Rack::JSONP when a callback parameter is provided) [./test/spec_rack_jsonp.rb:14]:
<"foo({\"bar\":\"foo\"})"> expected but was
<["{\"bar\":\"foo\"}"]>.
2) Failure:
test_spec {Rack::JSONP when a callback parameter is provided} 002 [should modify the content length to the correct value](Rack::JSONP when a callback parameter is provided) [./test/spec_rack_jsonp.rb:23]:
<"18"> expected but was
<nil>.
require 'benchmark'
require 'typhoeus'
require 'yajl'
require 'json'
require 'yaml'
require 'ruby-debug'
require 'uri'
require 'yajl/http_stream'
hash = {:a => 1}
module Rack
class Cap
def initialize(app, options = {})
@app = app
end
def call(env)
response = @app.call(env)
-e escape_char
Sets the escape character for sessions with a pty (default: `~'). The escape character is only rec-
ognized at the beginning of a line. The escape character followed by a dot (`.') closes the connec-
tion; followed by control-Z suspends the connection; and followed by itself sends the escape charac-
ter once. Setting the character to ``none'' disables any escapes and makes the session fully trans-
parent.

Sleep research

I expected a strong biological preference for amount of sleep and for the sleep cycle (how often we need sleep) but didn't expect there to be a strong biological cause for various sleep timings.

I was wrong: there does seem to be a biological cause for sleep timing (and it can change with age). However, most people aren't strong early birds are or night owls (estimates of people with strong preferences range widely, from 15% up to 50%, although most are around 30%), even though people commonly overestimate their preference. For those that aren't, sleep patterns can vary up to 2 hours on either side and people can shift sleep cycles (presumably without ill effect, although I haven't found good information on exact effects). Also, there are many external factors, social and biological that can shift sleep cycles.

Based on my limited research, my findings are:

  • There definitely is a biological preference for being early bird or night owl.
  • For a minority of people, this preference is ver
# A really early look how Tack runners might be constructed. Everything in this example may change since the code is really new.
runner = Tack::Runner.new(:root => Dir.pwd) do |runner|
runner.use Tack::Reverse if options[:reverse] # Optionally reverse the order of tests
runner.use Tack::Shuffle if options[:shuffle] # Optionally shuffle the tests
runner.use Tack::Formatters::Profiler, # Write out some profiling info
:tests => options[:profile_number].to_i if options[:profile_number]
runner.use Tack::Formatters::TotalTime # Display the total running time
runner.use Tack::Formatters::PrintFailures
runner.use Tack::Formatters::BasicSummary # e.g. 5 tests, 2 failures, 0 pending