Skip to content

Instantly share code, notes, and snippets.

View phurni's full-sized avatar

Pascal Hurni phurni

View GitHub Profile
@phurni
phurni / filterable.rb
Last active February 21, 2020 15:45 — forked from justinweiss/filterable.rb
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
# Original code from https://github.com/shakycode/ruby_sunday_refactor
# Second refactor, the addresses are objects! Create an address class that uses ValueType semantics
Address = Struct.new(:house_number, :street_address) do
def initialize(address)
super(*address.split(' ', 1).map(&:strip))
end
end
# now to compare two addresses, create instance of the Address class and compare those objects with the == operator
@phurni
phurni / application.rb
Created May 16, 2014 21:22
override active_record.initialize_database in rails (rails4)
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if ar_initdb = ActiveRecord::Railtie.initializers.find {|item| item.name == 'active_record.initialize_database'}
ActiveRecord::Railtie.initializers.delete(ar_initdb)
ActiveRecord::Railtie.initializer :after => ar_initdb.after do
ActiveSupport.on_load(:active_record) do
self.configurations = Rails.application.config.database_configuration
--- /Users/phi/Temp/QxtGlobalShortcut_wrap.cxx 2013-03-04 10:01:25.000000000 +0100
+++ /Users/phi/Temp/QxtGlobalShortcut_wrap_debug.cxx 2013-03-05 14:15:39.000000000 +0100
@@ -1863,6 +1863,7 @@
void *argp1 = 0 ;
int res1 = 0 ;
QxtGlobalShortcut *result = 0 ;
+ printf("_wrap_new_QxtGlobalShortcut__SWIG_0 ENTERING\n");
if ((argc < 1) || (argc > 1)) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;