Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / tracker_blocking.rb
Last active July 27, 2023 14:19
Current list of spy pixels named'n'shamed in HEY, as of April 23, 2020
module Entry::TrackerBlocking
extend ActiveSupport::Concern
included do
has_many :blocked_trackers
end
email_service_blockers = {
"ActiveCampaign" => /lt\.php(.*)?l\=open/,
"AWeber" => "openrate.aweber.com",
# http://www.evanmiller.org/bayesian-ab-testing.html implemented in ruby
# requires the distribution gem from https://github.com/clbustos/distribution (gem 'distribution', require: false)
def probability_b_beats_a(completed_a, total_a, completed_b, total_b)
require 'distribution/math_extension'
total = 0.0
alpha_a = completed_a + 1
beta_a = total_a - completed_a + 1
alpha_b = completed_b + 1
@davidkelley
davidkelley / .script.app
Last active June 15, 2016 16:34
Configures Vagrant to run Docker & Fig
# Run Application specific setup tasks here!
#!/usr/bin/env bash
cd /vagrant
fig run web foreman run rake db:create
fig run web foreman run rake db:migrate
@d11wtq
d11wtq / docker-ssh-forward.bash
Created January 29, 2014 23:32
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@schickling
schickling / Rakefile
Last active January 31, 2024 23:00
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@siddarth
siddarth / gist:6241382
Created August 15, 2013 14:44
Stripe FX: Getting the converted amount from the BalanceTransaction

Creating a USD charge on a GBP account:

$ curl https://api.stripe.com/v1/charges \
    -u REDACTED: \
    -d amount=400 \
    -d currency=usd \
    -d card[number]=4242424242424242 \
    -d card[exp_month]=04 \
    -d card[exp_year]=16 \

-d card[cvv]=390 \

@mendelgusmao
mendelgusmao / btsync
Last active March 4, 2021 15:37
init.d script for btsync (based on another script built to run dropbox)
#!/bin/sh
### BEGIN INIT INFO
# Provides: btsync
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of btsync.
# Place this file in the same directory as `Vagrantfile'
# then simply require "vagrant-snapshot.rb" at the top of Vagrantfile.
require 'optparse'
Vagrant.commands.register(:snap) { Snap::Commands }
# Provide rake-like desc() 'inflected' documentation
# See http://stackoverflow.com/questions/2948328/access-attributes-methods-comments-programmatically-in-ruby
class Module
@lost-theory
lost-theory / gist:3928813
Created October 21, 2012 22:48
flask dynamic url_prefix for blueprints
from flask import Flask, Blueprint, request
## blueprint ##################################################################
bp = Blueprint('category_functionality', __name__)
@bp.route('/')
def index(category):
return "this is the index page for %r" % category
[13:07:30] <mitsuhiko> does anyone have any ideas why upstart sometimes i unable to pickup changes?
[13:07:41] <mitsuhiko> how does one go about debugging upstart?
[13:13:39] jodh (~jodh@host-78-146-12-30.as13285.net) left IRC. (Ping timeout: 265 seconds)
[13:17:24] jodh (~jodh@host-78-147-31-235.as13285.net) joined the channel.
[13:29:39] <mitsuhiko> does this ring a bell to anyone? https://gist.github.com/5f9061af79bb8b38d240
[13:29:59] Md (~md@freenode/staff/md) joined the channel.
[13:30:00] <mitsuhiko> service start just hangs
[13:31:14] <mitsuhiko> i can confirm it does not even manage to start the executable
[13:31:19] <mitsuhiko> god knows what it waitpids for
[13:32:43] robotfuel (~robotfuel@ubuntu/member/robotfuel) joined the channel.