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
#!/bin/bash | |
set -ex | |
# Reproduce bundler issue: | |
# https://github.com/bundler/bundler/issues/4373 | |
rm -rf /tmp/bundler-GH-4373 | |
mkdir -p /tmp/bundler-GH-4373 | |
cd /tmp/bundler-GH-4373 |
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
#!/bin/bash | |
set -ex | |
# Reproduce bundler bug: | |
# https://github.com/bundler/bundler/issues/4144 | |
rm -rf /tmp/bundler-GH-4144 | |
mkdir -p /tmp/bundler-GH-4144 | |
cd /tmp/bundler-GH-4144 |
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 'json-schema' | |
require 'json-schema/validator' | |
require 'thread' | |
require 'thwait' | |
schema = { | |
"$schema" => "http://json-schema.org/draft-03/schema#", | |
"properties" => { | |
"a" => {"type" => "string", "required" => true}, | |
"b" => {"type" => "string"} |
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
module Kernel | |
alias_method :_aq_original_require, :require | |
def require(name) | |
fail 'No loading in threads!' if Thread.main != Thread.current | |
_aq_original_require(name) | |
end | |
end |
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 ruby | |
# filter git repo to only files interested in by regex | |
# | |
# Get all files ever in the repo. | |
# git log --pretty=format: --name-only --diff-filter=A | sort -u > list.txt | |
# ruby filter_reduce.rb | tr '\r\n' ' ' > reduced_list.txt | |
# git filter-branch --index-filter "git rm -rfq --cached --ignore-unmatch $(cat reduced_list.txt)" --prune-empty | |
list = [] |
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
stackprof --stackcollapse stackprof.dump | ~/Code/FlameGraph/flamegraph.pl > blah.html; open blah.html |
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
[1] pry(main)> class Foo | |
[1] pry(main)* private def bar; end | |
[1] pry(main)* def baz; end | |
[1] pry(main)* end | |
=> :baz | |
[2] pry(main)> Foo.new.baz | |
=> nil | |
[3] pry(main)> Foo.new.bar | |
NoMethodError: private method `bar' called for #<Foo:0x007fc34419c6c0> | |
from (pry):6:in `__pry__' |
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
[1] boris> $things = ['foo' => 'bar', 'baz' => 'qux']; | |
→ array( | |
'foo' => 'bar', | |
'baz' => 'qux' | |
) | |
[2] boris> array_map(function($thing) { return "{$thing}s";}, $things); | |
→ array( | |
'foo' => 'bars', | |
'baz' => 'quxs' | |
) |
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
Thread::spawn(move|| { | |
let mut eviction_lifo: Vec<(Vec<u8>, Timespec)> = vec![]; | |
let mut timer = Timer::new().unwrap(); | |
let validity = Duration::seconds(5); | |
loop { | |
let timeout = if eviction_lifo.len() > 1 { | |
let (_, arrival) = eviction_lifo[0]; | |
let eviction_time = arrival + validity; | |
timer.oneshot(eviction_time - get_time()) |
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
<?php | |
function testThrows() { | |
$this->assertThrows(function() { | |
// throw new \Exception('BAH!'); | |
}, 'Exception', "/BAH/"); | |
} | |
function testThrowsA() { | |
$this->assertThrows(function() { | |
throw new \RuntimeException('BAH!'); | |
}, 'InvalidArgumentException'); |