Skip to content

Instantly share code, notes, and snippets.

View todd's full-sized avatar
🤘

Todd Bealmear todd

🤘
View GitHub Profile
@todd
todd / mix.exs
Created April 25, 2016 02:32
Redis Keyevents -> RabbitMQ Messages
# mix.exs
defmodule RedisRabbitElixir.Mixfile do
use Mix.Project
def project do
[app: :redis_rabbit_elixir,
version: "0.0.1",
elixir: "~> 1.2",
build_embedded: Mix.env == :prod,
@todd
todd / learning_plug.ex
Created March 10, 2016 02:12
Learn Me Some Plug
defmodule LearningPlug do
use Plug.Builder
plug Plug.Logger
plug :extract_name
plug :greet, %{my_option: "Hello"}
def extract_name(%Plug.Conn{request_path: "/" <> name} = conn, opts) do
assign(conn, :name, the_name(name))
end
@todd
todd / Makefile
Last active December 12, 2015 02:41
Ruby 2.3.0-preview2 Build Log
RUBY_RELEASE_DATE = 2015-12-11
SHELL = /bin/sh
NULLCMD = :
n=$(NULLCMD)
ECHO1 = $(V:1=$n)
RUNCMD = $(SHELL)
CDPATH = .
CHDIR = cd -P
exec = exec
NULL = /dev/null
@todd
todd / apt list
Last active November 25, 2015 19:22
Ruby 2.3.0-preview1 Build Log
vagrant@development:~$ apt list --installed
Listing... Done
accountsservice/now 0.6.35-0ubuntu7.1 amd64 [installed,upgradable to: 0.6.35-0ubuntu7.2]
acl/trusty,now 2.2.52-1 amd64 [installed,automatic]
adduser/trusty,now 3.113+nmu3ubuntu3 all [installed]
apparmor/trusty-security,now 2.8.95~2430-0ubuntu5.1 amd64 [installed,upgradable to: 2.8.95~2430-0ubuntu5.3]
apt/now 1.0.1ubuntu2.6 amd64 [installed,upgradable to: 1.0.1ubuntu2.10]
apt-transport-https/now 1.0.1ubuntu2.6 amd64 [installed,upgradable to: 1.0.1ubuntu2.10]
apt-utils/now 1.0.1ubuntu2.6 amd64 [installed,upgradable to: 1.0.1ubuntu2.10]
apt-xapian-index/trusty,now 0.45ubuntu4 all [installed,automatic]
@todd
todd / npm_sucks.txt
Created August 25, 2015 20:15
NPM is the Worst
==> default: npm ERR! Error: No compatible version found: abbrev@'^1.0.5'
==> default: npm ERR! Valid install targets:
==> default: npm ERR! ["1.0.3","1.0.4","1.0.5","1.0.6","1.0.7"]
@todd
todd / secure_attributes.rb
Created February 6, 2015 21:22
SecureAttributes PoC
module SecureAttributes
extend ActiveSupport::Concern
included do
# Load bcrypt gem only when SecureAttributes is used.
# This is to avoid ActiveModel (and by extension the entire framework)
# being dependent on a binary library.
begin
require 'bcrypt'
rescue LoadError
@todd
todd / deprecation_warnings.rb
Last active January 3, 2023 18:31
Print All Rails Deprecation Warnings to File
# test.rb
config.active_support.deprecation = -> (message, callstack) {
File.open("#{Rails.root}/deprecations", "a") do |f|
f.write message
f.write callstack.join("\n ")
f.write "\n"
end
}
@todd
todd / deploy_branch.sh
Last active February 9, 2018 23:51
Deploy Command
deploy-branch() {
stage=$1
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) bundle exec cap $stage deploy
}
@todd
todd / poc.rb
Created September 16, 2014 18:38
ISO4217 number_to_currency Proof of Concept
def number_to_currency(number, options = {})
if options[:currency_code].present?
options[:unit] = unit_from_currency_code(options[:currency_code])
end
super
end
private
@todd
todd / shell_provisioner.sh
Last active August 29, 2015 14:05
Vagrant Shell Provisioner for gompd
#!/bin/bash
sudo apt-get update -qq
sudo apt-get install -y git mercurial bison pkg-config mpd mpc libmpdclient2 libmpdclient-dev
# Install GVM
clean=no bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /home/vagrant/.gvm/scripts/gvm
gvm get
gvm update && source $HOME/.gvm/scripts/gvm