Skip to content

Instantly share code, notes, and snippets.

@mjc
mjc / gist:8786371
Created February 3, 2014 15:49
dtruss -- rbx -e 'puts "hi"'
dtrace: 12538 dynamic variable drops with non-empty dirty list
SYSCALL(args) = return
madvise(0x10180A000, 0x3000, 0x5) = 0 0
open("/dev/dtracehelper\0", 0x2, 0x7FFF5EF28100) = 3 0
ioctl(0x3, 0x80086804, 0x7FFF5EF28088) = 0 0
close(0x3) = 0 0
open("/dev/urandom\0", 0x20104, 0x2068) = 3 0
fstat64(0x3, 0x7FFF5EF27F30, 0x0) = 0 0
read(0x3, "\317\221\206\f\340\220T\263\364yz\276\026\001\241\212\0", 0x10) = 16 0
@mjc
mjc / Gemfile
Last active August 29, 2015 13:57 — forked from eirc/.rvmrc
Message format benchmarks
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'json'
gem 'multi_json'
gem 'oj', platform: [:mri, :rbx]
gem 'yajl-ruby', platform: [:mri, :rbx], require: 'yajl'
gem 'jrjackson', platform: :jruby
gem 'gson', platform: :jruby
@mjc
mjc / widgets.coffee
Created May 29, 2014 15:55
Sortable example for ember.js
WidgetsController = Ember.ArrayController.extend
sortProperties: ["user.firstName"]
sortAscending: true
actions:
sortBy: (sortProperties) ->
old = @get("sortProperties")
@set "sortProperties", [sortProperties]
@toggleProperty "sortAscending" if sortProperties in old
return false
class A
def bar(*blah)
blah
end
end
class Foo < A
def bar(*)
no_commands { super }
end
---
AED:
code: AED
name: Dirhams
AFN:
code: AFN
name: Afghanis
symbol: ؋
unicode_hex: 1547
ALL:
@mjc
mjc / jruby-bench-results.md
Last active August 29, 2015 14:04
All benchmarks run on a Late 2013 15" Retina Macbook Pro (2.3GHz Core i7, 16GB, 512GB SSD)

Rails

Blank rails app with puma, serving a high_voltage static homepage (https://github.com/mjc/blankrails), warmed with 5 minutes of traffic.

MRI 2.1.2: 4 puma workers

Running 15s test @ http://localhost:3000
  1 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
@mjc
mjc / securecrt_export_sshconfig.rb
Created March 31, 2015 23:14
export users and hostnames to ssh_config format
#!/usr/bin/env ruby
require 'pathname'
path = Pathname.new(ENV['HOME']).join("Library","Application Support","VanDyke","SecureCRT","Config”,”Sessions”,”**.ini")
paths = Dir.glob(path)
paths.each do |path|
lines = File.readlines(path)
hostname = nil
username = nil
lines.each do |line|
result = line.match(/S:"(.+)"=(.+)/)
@mjc
mjc / jruby-bench.md
Last active August 29, 2015 14:18
JRuby benchmark

blank rails 4.2.1 app with blank controller in production mode with torquebox 4 alpha 1 started with rails s -e production torquebox

JRuby be07196

wrk -c 50 -d 10m -t 1 http://localhost:3000 once for warmup and second time for actual run

warmup:

@mjc
mjc / Gemfile
Last active August 29, 2015 14:23
Class vs Struct vs OpenStruct
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'ruby-progressbar'
@mjc
mjc / primalitytest6.rb
Last active August 29, 2015 14:27 — forked from jzakiya/primalitytest6.rb
primalitytest6.rb
#!/usr/local/bin/ruby -w
require 'rational' if RUBY_VERSION =~ /^(1.8)/ # for 'gcd' method
class Integer
def primz?
residues = [1,7,11,13,17,19,23,29,31,37,41,43,47,49,53,59,61]
res1 = [1,13,17,29,37,41,49,53]
res2 = [7,19,31,43]