Skip to content

Instantly share code, notes, and snippets.

@joshpencheon
joshpencheon / mongo-cluster.yaml
Last active November 22, 2017 10:35
Basic notes for getting a mongo cluster running on docker
version: '2'
services:
mongo_rs_1_1:
container_name: mongo_rs_1_1
image: mongo
command: mongod --shardsvr --replSet mongo_rs_1 --dbpath /data/db --port 27017
expose:
- "27017"
volumes:
- /Users/josh/data/mongo_cluster/data_rs_1_1:/data/db
@joshpencheon
joshpencheon / predicate_builder_behaviour.rb
Last active October 3, 2017 16:49
Observing a change between Rails 5.0.x and 5.1.x, when using cancancan. See https://github.com/CanCanCommunity/cancancan/issues/424.
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# gem "rails", "5.0.6" # PASS
@joshpencheon
joshpencheon / table_column_name_collision.rb
Last active October 3, 2017 13:03
Failures on some versions of Rails 5.1.x when table has a column with same name. Addressed in 5.1.4 by https://github.com/rails/rails/pull/29058
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# gem "rails", "5.0.6"
@joshpencheon
joshpencheon / belongs_to_join_issue_reproduction.rb
Created August 16, 2017 16:34
Failing test case to highlight issue with joining in a belongs_to definition
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# gem "rails", "5.0.5"
@joshpencheon
joshpencheon / action_methods_test_case.rb
Last active August 9, 2017 20:57
Minimal failing test case to demonstrate the perceived issue
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", github: "rails/rails"
@joshpencheon
joshpencheon / planio.rb
Last active July 6, 2017 13:20
Update plan.io tickets programmatically, by parsing SVN commit messages
#!/usr/bin/env ruby
@revision = ENV.fetch('REVISION')
@message = ENV.fetch('COMMIT_MESSAGE')
@user = ENV.fetch('SVN_USERNAME')
@api_key = ENV.fetch('REDMINE_API_KEY')
require 'json'
require 'net/http'
@joshpencheon
joshpencheon / compare_trunk_to_branch.sh
Last active May 7, 2017 16:15
Support Material for ruby/ruby stdlib CSV pull request
#!/bin/sh
git checkout trunk
ruby benchmark.rb > benchmark-trunk.log
ruby allocations.rb > allocations-trunk.log
git checkout csv_allocation_reduction
ruby benchmark.rb > benchmark-patch.log
ruby allocations.rb > allocations-patch.log
@joshpencheon
joshpencheon / .block
Last active June 26, 2016 12:05
D3 Jazz demo
border: no
height: 1000
@joshpencheon
joshpencheon / USAGE
Last active August 29, 2015 14:26
Proof-of-concept for shelling out to achieve syck-to-psych up serialization
$ irb -r ./up_serializer.rb
irb(main):001:0> YAML.load YAML::UpSerializer.new('1.9.3-p484').up_serialize "---\nkey: ,oh,dear\n"
=> {"key"=>",oh,dear"}
irb(main):002:0>
db.dummies.aggregate([
{
$group: {
_id: { num: "$num" },
records: { $push: "$$ROOT" }
}
},
{
$project: {
_id: 0,