Skip to content

Instantly share code, notes, and snippets.


Michael Elfassy elfassy

View GitHub Profile
View apple_pay_in_browser.js
function applePayButtonClicked(event)
var paymentRequest = {
// countryCode: The merchant’s ISO country code.
countryCode: 'US',
// currencyCode: The ISO currency code for the payment.
currencyCode: 'USD',
// total: The total amount for the payment.
total: {
label: 'Canine Clothing',
View rails_bug_has_many_through_with_foreign_key.rb
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
gemfile(true) do
source ''
gem 'activerecord', '4.2.0'
View capybara_cheat_sheet.rb
#=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click_on('Button Value')
View hstore_getter_setter.rb
module HstoreSetterGetter
# To use simply add to your models:
# include HstoreSetterGetter
# hstore_attributes :test1, :test2, type: :integer #assumes column_name: :data
# hstore_attributes :test3, :test4, column_name: :properties #assumes type: :string
# Written by Michael Elfassy
View clone_rails.thor
#!/usr/bin/env ruby
require "rubygems" # ruby1.9 doesn't "require" it though
require "thor"
class CloneRails < Thor
include Thor::Actions
desc "new NAME, TEMPLATE", "Create a new rails app based on a template app"
method_options :template => "template"
def new(name)
puts "Copying the template..."
View setup_template.rb
# Setup a template that can be cloned later
# Command:
# rails new NAME -m setup_template.rb
# (by default you should use "template" as NAME)
plugin("Rename", :git => "")
# See if you need more customization of the template generator
View image_tag_helper.rb
#Orverwrite the image_tag based on the idea from Designer Wall (
def image_tag(source, options = {})
image_width = image_height = nil
image_width_css = image_height_css = ""
options[:class] = "image-wrap " + options[:class]