Skip to content

Instantly share code, notes, and snippets.

@ryanong
ryanong / gist:1038659
Created June 21, 2011 19:27
Compare Strings By Character Pairs
def compare_strings(str1,str2)
str1.downcase!
pairs1 = (0..str1.length-2).collect {|i| str1[i,2]}.reject { |pair| pair.include? " "}
str2.downcase!
pairs2 = (0..str2.length-2).collect {|i| str2[i,2]}.reject { |pair| pair.include? " "}
union = pairs1.size + pairs2.size
intersection = 0
@ryanong
ryanong / ryan_ong_resume.md
Created July 12, 2011 05:10
Ryan Ong's Resume

Ryan Ong

:dng  :js  :html  :nosql  :php  :pl  :psd  :py  :rb  :sh  :sql 

Relevant Experience

Pivotal Labs New York, NY November 2011 - Current Pivot

CarZen LLC New York, NY September 2009 - October 2011 Senior Developer

  • Mentored and managed two junior developers
@ryanong
ryanong / erb_source.rb
Last active August 29, 2015 14:18
Show source of a block from a rails ERB file
class ERBSource
ERB = ::ActionView::Template::Handlers::ERB
def self.for(block)
new(block).source
end
attr_reader :block, :file, :line_number
def initialize(block)
@block = block
@ryanong
ryanong / capybara.rb
Created June 8, 2015 18:34
Capybara Puma NGINX
# spec/support/capybara.rb
require "capybara"
require "puma/server"
require "support/nginx"
Capybara.server do |app, port|
server = Puma::Server.new(app)
server.min_threads = 1
server.max_threads = 1
if ENV["PRECOMPILE"] == "true"
@ryanong
ryanong / keybase.md
Last active December 1, 2016 15:46
keybase.md

Keybase proof

I hereby claim:

  • I am ryanong on github.
  • I am ryanong (https://keybase.io/ryanong) on keybase.
  • I have a public key ASBRZGdZ9UuDs3nNbrSqVePEWul8ohFEnkoxuJewOCzTkgo

To claim this, I am signing this object:

@ryanong
ryanong / _style.html.erb
Created August 28, 2020 16:27
documentation of rails helper components
<div id="cg-<%= name.parameterize %>">
<h1 class="uk-article-title"><%= name.humanize %></h1>
<p class="uk-article-lead"><%= description %></p>
<h2 id="usage"><a href="#usage" class="uk-link-reset">Usage</a></h2>
<h3 class="tm-article-subtitle">Example</h3>
<div class="uk-border uk-padding uk-grid">
@ryanong
ryanong / service.rb
Created November 16, 2020 16:08
Service Class
require "active_job/arguments"
module Service
extend ActiveSupport::Concern
class ServiceJob
include Sidekiq::Worker
sidekiq_options queue: :web_default
@ryanong
ryanong / latest_test_failure.rb
Last active December 22, 2022 16:35
This will extract any test failures into a separate log file for rspec. Useful for trying to get debug info on large test runs or flakey specs on CI
module LatestTestFailure
class << self
def around(example)
Rails.logger.info start_log(example.location)
example.run
Rails.logger.info end_log(
example.location,
example.exception ? "FAILED" : "PASSED"
)
end