Skip to content

Instantly share code, notes, and snippets.

View dkubb's full-sized avatar
🏠
Working from home

Dan Kubb dkubb

🏠
Working from home
  • Betterment
  • Mission, BC, Canada
  • X @dkubb
View GitHub Profile
@dkubb
dkubb / axiom-mutant-coverage.txt
Last active December 27, 2015 08:09
Mutant Coverage for Axiom
Subjects: 440
Mutations: 8541
Kills: 8541
Runtime: 3773.23s
Killtime: 3670.90s
Overhead: 2.71%
Coverage: 100.00%
Alive: 0
require 'coercible'
class Transformer
include Enumerable
COERCER = Coercible::Coercer.new
COERCIONS = Hash.new(:to_string).update(
id: :to_integer,
updated_on: :to_date,
@dkubb
dkubb / credit_card_decorator.rb
Last active December 26, 2015 09:18
Spree::CreditCard#expiry= fix
Spree::CreditCard.class_eval do
MONTH_PATTERN = /(?<month>0?[1-9]|1[012])/.freeze
YEAR_PATTERN = /(?<year>(?:20)?\d{2})/.freeze
EXPIRY_PATTERN = /\A#{MONTH_PATTERN}#{YEAR_PATTERN}\z/.freeze
# Set the expiry month and year
#
# @param [#to_s] expiry
#
#!/bin/bash
unset UCF_FORCE_CONFFOLD
export UCF_FORCE_CONFFNEW=YES
export DEBIAN_FRONTEND=noninteractive
export MAKEFLAGS="-j"
export CONCURRENCY_LEVEL=$(($(nproc) + 1))
# Configure apt to not install recommended or suggested packages
tee /etc/apt/apt.conf.d/10recommended <<-CONFIG
@dkubb
dkubb / thread_safe_set.rb
Created July 21, 2013 08:07
Ruby Thread-safe Set
require 'thread_safe'
module ThreadSafe
class Set < ::Set
def initialize(*)
@hash = Hash.new
super
end
end
end
@dkubb
dkubb / axiom-memory-adapter-examples.rb
Last active December 19, 2015 22:59
Examples for axiom-memory-adapter
require 'axiom-memory-adapter'
adapter = Axiom::Adapter::Memory.new(
customers: Axiom::Relation.new([[:id, Integer], [:name, String]]),
orders: Axiom::Relation.new([[:id, Integer], [:customer_id, Integer]])
)
# Insert customer data
customers = adapter[:customers]
customers.insert([[1, 'Dan Kubb']])
#!/bin/sh
# Dropbox setup on a headless Ubuntu Server
# Script written by Jesse B. Hannah (http://jbhannah.net) <jesse@jbhannah.net>
# Based on http://wiki.dropbox.com/TipsAndTricks/UbuntuServerInstall
###
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@dkubb
dkubb / asset-compiler-proxy.md
Last active December 16, 2015 01:49
These are some notes about a more efficient asset compiler than what is currently being used in Rails 3.2.x

Improving Asset Compilation in Development

In order for this to work the following changes will need to be made in preparation:

  • Change js to use require.js to specify dependencies
  • Change html to use async loading of the js

Compilation

@dkubb
dkubb / git-remove-merged.sh
Last active March 8, 2023 17:24 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
git remote update &&
git remote prune origin &&
git branch -r --merged origin/master |
awk -F"/" '!/(>|master)/ {print $2}' |
xargs -rL1 git push origin --delete
@dkubb
dkubb / eager_repository.rb
Last active May 13, 2019 21:10
Eager Loading DataMapper Associations
require 'memoist'
# Usage:
#
# customers = Customer.preload(Customer.orders.line_items.item)
#
# customers.each do |customer|
# customer.orders.each do |order|
# order.line_items.each do |line_item|
# line_item.item # yay, no more N+1, only 4 queries executed !