Skip to content

Instantly share code, notes, and snippets.

@pd
pd / api-auth-profiling.rb
Created November 3, 2015 19:49
Quick script to benchmark & profile ApiAuth request validation
# Don't use bundle. Run from your api_auth checkout.
#
# ENV:
# V = {local, gem}
# use an installed gem, or the current working dir
# M = {bench, object, cpu, wall}
# run benchmark/ips, or choose to profile object allocations or cpu cost
require 'benchmark/ips'
require 'pry'
@pd
pd / 00-symbol-vs-string-equality.rb
Created January 27, 2015 00:52
rbx -v == rubinius 2.5.0.n24 (2.1.0 af7eb1b4 2015-01-24 3.5.0 JI) [x86_64-darwin14.0.0]
require 'benchmark/ips'
SYM = :magic_key
MYS = :key_magic
STR = 'magic_key'
RTS = 'key_magic'
Benchmark.ips do |x|
x.config(time: 2, warmup: 1)
@pd
pd / 00_dbg.rb
Created December 16, 2014 04:51
rubinius-debugger deferred breakpoints patch
class A
def hi
'hi'
end
def many(n)
1.upto(n) do |i|
puts "hi #{i}"
end
end
@pd
pd / rbx-travis-run-segfault.txt
Created December 2, 2014 17:11
rbx SEGV on a travis run of ruby-json-schema/json-schema PR #196
Using worker: worker-linux-docker-25563cc4.prod.travis-ci.org:travis-linux-8
Build system information
Build language: ruby
$ git clone --depth=50 git://github.com/ruby-json-schema/json-schema.git ruby-json-schema/json-schema
Cloning into 'ruby-json-schema/json-schema'...
remote: Counting objects: 2030, done.
remote: Compressing objects: 100% (797/797), done.
remote: Total 2030 (delta 1301), reused 1897 (delta 1187)
@pd
pd / kw.rb
Last active August 29, 2015 14:10
rbx JIT/kwargs bug
def kw(a: 0); end
N = Integer(ARGV[0]) rescue 250_000
N.times { kw }
@pd
pd / keybase.md
Last active January 8, 2020 01:22
Keybase proof of identity.

Keybase proof

I hereby claim:

  • I am pd on github.
  • I am pd (https://keybase.io/pd) on keybase.
  • I have a public key ASCAInw0XoV-EBb31ilHLmST9jfq84TBV-T06XS-XnJtVAo

To claim this, I am signing this object:

@pd
pd / uuid-vs-sha1.rb
Created October 27, 2014 13:26
UUID v5 vs SHA1 hexdigest
require 'json-schema'
require 'digest/sha1'
require 'benchmark'
N = 5000
SCHEMAS = Dir['test/schemas/*.json'].map { |f| File.read(f) }
Benchmark.bmbm do |x|
x.report('v5') do
N.times do
@pd
pd / fail.rb
Created October 25, 2014 18:25
Reproducing hoxworth/json-schema issue #96
# https://github.com/hoxworth/json-schema/issues/96
require 'json-schema'
schema = {
:type => :object,
:required => [
:id,
:name,
:real_name,
@pd
pd / example.txt
Created August 8, 2013 18:12
let's call it an mvp
$ npm i esprima falafel
$ node sib.js | node
{ '4': [ [ 2, 'big' ], [ 2, 'big' ] ],
'8': [ [ 6, 'little' ] ],
'11': [ [ 11, 'big' ], [ 11, 'little' ] ] }
@pd
pd / 00_before.txt
Last active December 20, 2015 16:19
puzzle 0 solved in 111ms
puzzle 1 solved in 387ms
puzzle 2 solved in 403ms
puzzle 3 solved in 18174ms
puzzle 4 solved in 5284ms
puzzle 5 solved in 59081ms
puzzle 6 solved in 17535ms
puzzle 7 solved in 240ms
puzzle 8 solved in 13946ms
puzzle 9 solved in 19302ms