Skip to content

Instantly share code, notes, and snippets.

@mjc
mjc / README.md
Last active February 10, 2017 17:53 — forked from erikwennerberg/README.md

Setup

Add the following gems to your Gemfile:

gem 'activeresource'
gem 'newrelic_api'

Update your bundle:

@mjc
mjc / config.ru
Last active January 3, 2016 06:09 — forked from ngs/config.ru
config.ru for running CakePHP apps under Pow. Includes an app/webroot rewrite and some other things from the rack-legacy example.
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
webroot = File.join(Dir.getwd,'app','webroot')
use Rack::Rewrite do
rewrite %r{/(.*)}, lambda { |match, rack_env|
File.exists?(File.join(webroot,match[1])) ? File.join('app','webroot',match[1]) : '/app/webroot/index.php/%s' % match[1]
}
@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: