Skip to content

Instantly share code, notes, and snippets.

View todd's full-sized avatar
🤘

Todd Bealmear todd

🤘
View GitHub Profile
@todd
todd / tmux_battery_indicator.sh
Last active August 29, 2015 14:04
Variable Color Battery Indicator for Tmux Status Bar on OS X
#!/bin/sh
input=$(pmset -g batt)
battery_level=$(echo $input | pcregrep -o1 -i "(\d+)%" | bc)
charging=$(echo $input | grep "AC")
color=yellow
bolt=""
if [ "$battery_level" -gt 75 ]; then
color=green
@todd
todd / current_spotify_song.scpt
Last active April 24, 2019 10:00
AppleScript to Get Current Song from Spotify formatted for Tmux Status Bar
tell application "System Events"
set processList to (name of every process)
end tell
if (processList contains "Spotify") is true then
tell application "Spotify"
set artistName to artist of current track
set trackName to name of current track
set symbol to "◻︎"
set col to "red"
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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