Skip to content

Instantly share code, notes, and snippets.

View J3RN's full-sized avatar
💼
Seeking a new job

Jonathan Arnett J3RN

💼
Seeking a new job
View GitHub Profile
@J3RN
J3RN / contractions.txt
Last active August 31, 2015 20:19
List of Common English Contractions
ain't
aren't
can't
could've
couldn't
couldn't've
didn't
doesn't
don't
hadn't
#!/usr/bin/env python
import RPi.GPIO as GPIO
from time import *
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
@J3RN
J3RN / post-update
Created October 20, 2015 02:31
A post-update Git hook that I use to deploy my portfolio site
#!/bin/sh
GIT_REPO=$HOME/portfolio.git
TMP_GIT_CLONE=$HOME/tmp_portfolio
PUBLIC_WWW=$HOME/www
touch $HOME/deploy
git clone $GIT_REPO $TMP_GIT_CLONE
cp -rv $TMP_GIT_CLONE/* $PUBLIC_WWW
rm -rf $TMP_GIT_CLONE
@J3RN
J3RN / keybase.md
Created March 19, 2016 01:39
keybase.md

Keybase proof

I hereby claim:

  • I am j3rn on github.
  • I am j3rn (https://keybase.io/j3rn) on keybase.
  • I have a public key ASBhifQXfnaOXVcs8wkePXEhYqHf5sX7-XkL_U5IX_CALwo

To claim this, I am signing this object:

@J3RN
J3RN / parser.rb
Last active June 16, 2016 14:38
Another balanced parens parser
class Parser
ENCLOSURES = {
'"' => '"',
'(' => ')',
'{' => '}',
'[' => ']'
}
def initialize
@i = 0
@J3RN
J3RN / proc_fix.rb
Last active January 23, 2017 16:22
Convert proc scopes to stabby lambda scopes
# USAGE: ruby proc_fix.rb <one or more space-separated model names without path or extension>
# e.g. ruby proc_fix.rb activity
# e.g. ruby proc_fix.rb accessory bill_charge
# **Must be run in Rail's root**
# What it do: Converts all "Proc.new { |foo|" to "(foo) -> {"
before = /scope(.*)Proc\.new\s*\{\s*\|(.*)\|/
after = 'scope\1->(\2) {'
ARGV.each do |modelname|
@J3RN
J3RN / old2new.zsh
Last active March 9, 2017 15:30
old2new, the Ruby hash syntax updater
# This script has been tested with zsh 5.2 on macOS 10.12.3 with BSD sed and find.
# It may work under other conditions, but likely does not.
# old2new, the Ruby hash syntax updating function
# Takes the given files and replaces all instances of `:key => value` with the equivalent `key: value`
# Usage: old2new <path>
# NOTE: <path> can be a file or directory
function old2new() {
find $argv \( -name "*.haml" -or -name "*.rb" -or -name "*.erb" \) -exec sed -E -i '' 's/:([A-z]+) =>/\1:/g' '{}' \;
}
@J3RN
J3RN / backup.sh
Created January 14, 2018 01:13
A simple script I use to backup my flashdrive
#!/bin/bash
# Usage: ./backup.sh <path to directory to archive> <GPG user>
tar -C $1 -c . | gpg --recipient $2 -e > $(date -Iminutes | tr -d ':').tar.gz.gpg
@J3RN
J3RN / elixir_test.exs
Created October 9, 2018 03:47
Trying to pattern match in Elixir, variable to variable
pattern = %{foo: "bar", bar: %{baz: "qux"}}
good_data = %{foo: "bar", bar: %{baz: "qux", qux: "asdf"}}
bad_data = %{foo: "baz", bar: %{baz: "asdf"}}
### This is perfect
match?(%{foo: "bar", bar: %{baz: "qux"}}, good_data)
#=> true
match?(%{foo: "bar", bar: %{baz: "qux"}}, bad_data)
#=> false
@J3RN
J3RN / deploy.rake
Last active February 26, 2020 16:34 — forked from njvitto/deploy.rake
# Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app',
'deploy:push',
'deploy:migrate',
'deploy:restart']
task :deploy_production => ['deploy:set_production_app',
'deploy:push',
'deploy:migrate',
'deploy:post_deploy',
'deploy:restart']