Skip to content

Instantly share code, notes, and snippets.

View rmm5t's full-sized avatar
🌐
building itsy bitsy parts of the internet that grow

Ryan McGeary rmm5t

🌐
building itsy bitsy parts of the internet that grow
View GitHub Profile
@rmm5t
rmm5t / benchmark_command_object_vs_poro.rb
Last active June 18, 2019 23:42
Benchmarking command object pattern vs PORO
require 'benchmark'
require 'active_support/all'
class CommandObject
def self.execute_with(arg)
new(arg).tap(&:run)
end
def initialize(arg)
@arg = arg
@rmm5t
rmm5t / benchmark_local_var_vs_instance_var.rb
Last active June 18, 2019 20:35
Benchmark local var caching vs direct method access
require 'benchmark'
require 'active_support/all'
Source = Struct.new(:value, keyword_init: true)
def local_var_test(source)
value = source.value
return if value.nil?
value
end
@rmm5t
rmm5t / benchmark_instance_var_vs_delegate.rb
Last active June 18, 2019 23:38
Benchmark instance variable vs delegation
require 'benchmark'
require 'active_support/all'
Source = Struct.new(:value, keyword_init: true)
class InstanceVarTest
attr_reader :source, :value
def initialize(source)
@source = source
@rmm5t
rmm5t / benchmark_tag_vs_interpolation.rb
Last active June 18, 2019 20:36
Benchmarking tag vs content_tag vs string interpolation
require 'benchmark'
require 'action_view'
include ActionView::Helpers::TagHelper
include ERB::Util
def output_buffer=(s)
end
def output_buffer
end
@rmm5t
rmm5t / benchmark_style_multiple_comparison.rb
Last active June 18, 2019 20:36
Style/MultipleComparison benchmark
require 'benchmark'
def test_conditionals(n)
n == 1 || n == 2 || n == 3 || n == 4 || n == 5 || n == 6 || n == 7
end
def test_include(n)
[1, 2, 3, 4, 5, 6, 7].include?(n)
end
@brettkelly
brettkelly / makeAmazonAffUrl.py
Created July 15, 2012 04:29
Python to rework Amazon URL to contain the user's affiliate code
#!/usr/bin/env python
# (c) 2012 Brett Kelly.
# Licensed under the MIT license
# http://www.opensource.org/licenses/mit-license.php
import re
import sys
from urlparse import urlparse
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.