Skip to content

Instantly share code, notes, and snippets.

View bramswenson's full-sized avatar

Bram Swenson bramswenson

View GitHub Profile
#cloud-config
bootcmd:
- |
/bin/bash <<-'EOS'
#!/bin/bash
exec > >(tee /root/log.txt)
exec 2>&1
set -x
set -e
if [ -e /new ]; then
@bramswenson
bramswenson / paper_trail_explore.md
Last active August 29, 2015 14:15
paper_trail exploration

Exploring paper_trail gem

  1. These notes are meant to follow reading the README. Please start there.
  2. Primary interface is the has_paper_trail class method added to ActiveRecord::Base.
  3. Calling this method adds some associations and callbacks to the model.
  4. These associations are to PaperTrail::Version models or its ancestors all which inherit ActiveRecord::Base. This ActiveModel::Concern module provides all the features.
  5. Versions can be in many tables and a model may have many version types [1](https://github.com/airb
@bramswenson
bramswenson / benchmark.rb
Last active August 29, 2015 14:15
replace greater than 3 byte utf8
# encoding: utf-8
require 'gemoji'
require 'benchmark'
require 'benchmark/ips'
task :default => :benchmark
task :benchmark do
regex = /([^\u0000-\uD7FF\uE000-\uFFFF])/
replacement = "�"
@bramswenson
bramswenson / development_casts.md
Last active August 29, 2015 14:12
Development Screen and Pod Casts
@bramswenson
bramswenson / rad_python.md
Last active June 14, 2016 16:23
Rad Python Libraries
@bramswenson
bramswenson / sqs_notes.md
Last active September 25, 2020 07:27
Amazon SQS Notes
@bramswenson
bramswenson / 01_summary.md
Last active August 29, 2015 14:04
What happens when we kill databases with rails replication/sharding solutions?

The goal of this spike is to determine the behavior of rails replication and sharding solutions, specifically when selecting against associated records. We would like to see reads distributed across slaves where not instructed to do otherwise. Like so in the Octopus api:

# contrived example that actually doesn't work in octopus 0.8.2
irb(main):002:0> Artist.first.albums.count
[Shard: slave1]  Artist Load (1.3ms)  SELECT `artists`.* FROM `artists` LIMIT 1
[Shard: slave2]   (1.1ms)  SELECT COUNT(*) FROM `albums` WHERE `albums`.`artist_id` = 1
=> 4
module Geoip
def self.geocode(ip)
Geoip::Block.geocode(ip)
rescue Mongoid::Errors::DocumentNotFound
false
end
class Block
include Mongoid::Document
@bramswenson
bramswenson / ssh_config
Last active December 31, 2015 14:29
~/.ssh/config
Host host1.example.com host2.example.com host3.example.com
ForwardAgent yes
IdentityFile ~/.ssh/id_rsa
@bramswenson
bramswenson / em_link_view_ext.js.coffee
Created October 10, 2013 16:16
make ember link views accept data- attributes