Skip to content

Instantly share code, notes, and snippets.

View xn's full-sized avatar

Christian Trosclair xn

View GitHub Profile
@xn
xn / Findable.rb
Last active February 3, 2016 22:10 — forked from lypborges/Findable.rb
Create a concern to use when using uuid as default primary key
module Findable
extend ActiveSupport::Concern
# When you use uuid some methods stop to work as expected. Using this concern in your models will do the job.
# Override methods on module FinderMethods that use id as default order when no order is defined
# It's a working in progress
# referencer:
# http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-take
# https://github.com/rails/rails/blob/f52354ad1d15120dcc5284714bee7ee3f052986c/activerecord/lib/active_record/relation/finder_methods.rb#L503
module ClassMethods
@xn
xn / helpers.rb
Last active December 26, 2015 02:19
def render_stack(blockitem, size)
size = nil if size < 2
html = ""
link = localized.include?(blockitem) ? "" : "something"
html << "<a href=\"#{link}\" class=\"stack-link\">" # Not done, still need to change that for things
html << "<div class=\"recipe-icon\" style=\"background: url(#{url('images/wiki/#{blockitem}.png')});\" title=\"{$name}\">#{size}</div>"
html << "</a>"
end
@xn
xn / 0-readme.md
Created February 21, 2012 11:24 — forked from mickm/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

@xn
xn / pathy.rb
Created December 28, 2011 23:55 — forked from krainboltgreene/pathy.rb
class Hash
#this is pseudocode
def locate_and_find_all(nodes*, &block)
enum = self
while !nodes.empty?
node = nodes.pop
if enum.has_key? node
enum = enum[node]
else
@xn
xn / gist:875262
Created March 17, 2011 22:31 — forked from leshill/gist:870866
# Add this to more_web_steps.rb
# Selenium docs: http://code.google.com/p/selenium/wiki/RubyBindings#Javascript_Alert/Confirm today!
When /^I (accept|dismiss) the "([^"]*)" alert$/ do |action, text|
window = page.driver.browser.window_handle
alert = page.driver.browser.switch_to.alert
alert.text.should == text
alert.send(action)
page.driver.browser.switch_to.window window
end