Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
barbietunnie / download-old-chrome-versions.md
Last active April 23, 2024 10:56
How to download old versions of Chrome

How to download old versions of Chrome

Click here to download old versions of Chrome for Linux, Mac and Windows.

The download_url field of the desired section houses the URL to the download.

Alternatively, for not too old versions, you can get it directly here.

@maxivak
maxivak / readme.md
Last active January 12, 2024 06:53
Integrating Gem/Engine and Main Rails App
@mfpiccolo
mfpiccolo / serializer_monkey.rb
Last active August 29, 2015 14:13
A active record monkey patch to make serialization easy with active model serializers
# Monkey patch for ActiveRecord::Base to return serialized JSON in the format
# of an ActiveModel::Serializer.
module SerializedJson
extend ActiveSupport::Concern
def to_serial(serializer=nil, opts={})
if self.respond_to?(:map)
serializer ||= (self.base_class.name + "Serializer").constantize
serialized_collection = self.map do |resource|
@peterberkenbosch
peterberkenbosch / count_complete_orders_by_sku.rb
Created August 12, 2014 20:39
Count number of sold products
Spree::LineItem.joins(:variant).merge(Spree::Variant.where(sku: "ROR-00011")).joins(:order).merge(Spree::Order.where(state: 'complete')).count
@peter
peter / recursive_struct.rb
Created March 26, 2014 16:09
Using a recursive struct in Ruby to honor the Uniform Access Principle when accessing data from hashes/structs/objects
# Simple wrapper to allow hashes to be accessed via dot notation recursively.
# Recurses over hashes and arrays. Works with string keys
# and symbol keys - other types of keys are not supported and
# all keys must be of the same type. Write access is only supported via
# []= Hash syntax. Supports accessing hash values with square bracket Hash syntax ([...])
# and access is indifferent to if the key is given as a string or a symbol.
# Supports JSON generation.
#
# Dependencies: Ruby.
#
@SabretWoW
SabretWoW / 42-things.md
Last active May 13, 2022 07:32 — forked from xdite/42-things.md
42 Sweet, sweet things Rails (and Ruby) can do. Wonderful reference.
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')