Skip to content

Instantly share code, notes, and snippets.

View markedmondson's full-sized avatar

Mark Edmondson markedmondson

View GitHub Profile
canada = OpenStruct.new(name: "Canada", iso: "CA")
usa = OpenStruct.new(name: "United States", iso: "US")
australia = OpenStruct.new(name: "Australia", iso: "AU")
all_countries = [
canada,
usa,
australia
]
state_counts = [
OpenStruct.new(name: "BC", country: "Canada", count: 5),
OpenStruct.new(name: "Ontario", country: "CA", count: 15),
OpenStruct.new(name: "QC", country: nil, count: 25),
OpenStruct.new(name: "Oregon", country: "USA", count: 35),
OpenStruct.new(name: "WA", country: "United States", count: 45),
OpenStruct.new(name: "CA", country: nil, count: 55),
OpenStruct.new(name: "WA", country: "Australia", count: 65)
]
@markedmondson
markedmondson / States level 3
Last active August 29, 2015 14:01
Level++ ++
state_counts = [
OpenStruct.new(name: "BC", country: "Canada", count: 5),
OpenStruct.new(name: "British Columbia", country: "CA", count: 65),
OpenStruct.new(name: "Ontario", country: "CA", count: 15),
OpenStruct.new(name: "QC", country: nil, count: 25),
OpenStruct.new(name: "Oregon", country: "USA", count: 35),
OpenStruct.new(name: "WA", country: "United States", count: 45),
OpenStruct.new(name: "CA", country: nil, count: 55),
OpenStruct.new(name: "WA", country: "Australia", count: 65)
]
@markedmondson
markedmondson / States level 4
Last active August 29, 2015 14:01
Level++ ++ ++
state_counts = [
OpenStruct.new(name: "BC", country: "Canada", count: 5),
OpenStruct.new(name: "British Columbia", country: "CA", count: 65),
OpenStruct.new(name: "Ontario", country: "CA", count: 15),
OpenStruct.new(name: "QC", country: nil, count: 25),
OpenStruct.new(name: "Oregon", country: "USA", count: 35),
OpenStruct.new(name: "WA", country: "United States", count: 45),
OpenStruct.new(name: "CA", country: nil, count: 55),
OpenStruct.new(name: "WA", country: "Australia", count: 65),
OpenStruct.new(name: "WA", country: nil, count: 100)
@markedmondson
markedmondson / 00.howto_install_phantomjs.md
Created October 7, 2015 17:16 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@markedmondson
markedmondson / ink_helpers.rb
Last active December 25, 2015 00:01
Rails helpers for Zurb Ink
module InkHelper
def ink_container(*styles, &block)
styles = ["container"].concat(Array(styles))
content_tag(:table, class: styles.join(" ")) do
ink_block do
content_tag(:tr) do
content_tag(:td) do
capture { yield }
end
@markedmondson
markedmondson / random_tests.sh
Last active June 23, 2021 18:24
Run 25 random test files 50 times before your known test file (with randomized time). Once you get a solid failing $TEST_FILES keep going!
#!/bin/bash
# Requires sudo apt-get install libfaketime
# Run with bash ./scraps/random_tests.sh
# You may or may not need these...
# export DYLD_FORCE_FLAT_NAMESPACE=1
# export DYLD_INSERT_LIBRARIES=/path/to/libfaketime.1.dylib
for i in {1..50}
@markedmondson
markedmondson / faster_system_tests.rb
Last active August 10, 2023 07:53
Faster system test sign in
module SessionHelper
extend ActiveSupport::Concern
class ::SessionsBypassController < ActionController::Base
def show
session[:user_id] = params[:user_id]
session[:team_id] = params[:team_id]
session[:tenant] = Apartment::Tenant.current
@markedmondson
markedmondson / policy_example.rb
Created October 8, 2024 23:10
Policy example
module FeaturePolicy
extend ActiveSupport::Concern
class_methods do
def policy_access_klass(klass)
self.policy_access_klass = klass
end
included do
class_attribute :policy_access_klass,