Skip to content

Instantly share code, notes, and snippets.

View jesseadams's full-sized avatar

Jesse Adams jesseadams

View GitHub Profile
@jesseadams
jesseadams / keybase.md
Created September 12, 2019 14:33
keybase.md

Keybase proof

I hereby claim:

  • I am jesseadams on github.
  • I am geek (https://keybase.io/geek) on keybase.
  • I have a public key ASBZcy0kaDyXPHhnV0qWaLrZD9S61Qs_kUhEtThH5lWYeQo

To claim this, I am signing this object:

@jesseadams
jesseadams / .pa11yci
Last active August 29, 2019 22:15
pa11y-ci example
{
"defaults": {
"chromeLaunchConfig": {
"args": ["--no-sandbox"]
}
},
"urls": [
"http://pa11y.org/",
"http://pa11y.org/contributing"
]
@jesseadams
jesseadams / psych_patch.rb
Created April 22, 2019 21:01
Psych monkey patch
# Psych's first step is to parse the Yaml into an AST of Node objects
# so we open the Node class and add a way to track the line.
class Psych::Nodes::Node
attr_accessor :line
end
# We need to provide a handler that will add the line to the node
# as it is parsed. TreeBuilder is the "usual" handler, that
# creates the AST.
class LineNumberHandler < Psych::TreeBuilder
@jesseadams
jesseadams / get_lambda_logs.rb
Created February 15, 2019 20:16
Download log streams for a lambda in CloudWatch
require 'aws-sdk'
log_group_name = '/aws/lambda/LAMBDA-NAME'
log_stream_name_prefix = '2019/02/14'
client = Aws::CloudWatchLogs::Client.new(region: 'us-east-1')
response = client.describe_log_streams(log_group_name: log_group_name, log_stream_name_prefix: log_stream_name_prefix)
log_streams = response.log_streams.collect{ |log_stream| log_stream.log_stream_name + ':' + log_stream.creation_time.to_s }
while response.next_token
@jesseadams
jesseadams / text_message_formatting.sh
Last active January 11, 2017 17:49
Awk script to convert a raw SMS conversation to a readable, printable format
#!/usr/bin/env bash
awk '{
printf "%s", $1 " @ " $2 " - "
if ($3 == "in")
printf "%s", "Heather"
else
printf "%7s", "Jesse"
printf "%s", ": "
for(i=7;i<=NF;++i)printf "%s ", $i
print ""
function warn() {
echo -e "\e[1;33m${1}\e[0m"
}
function success() {
echo -e "\e[1;32m${1}\e[0m"
}
function error() {
echo -e "\e[1;31m${1}\e[0m"
#!/usr/bin/env bash
$* &> /tmp/$$ &
sudo strace -p $!
cat /tmp/$$
rm /tmp/$$
@jesseadams
jesseadams / determine_platform.sh
Created September 19, 2012 20:48
Useful bash scripts for handling cross platform support
#!/usr/bin/env bash
function determine_platform(){
local platform_raw=`uname -s | tr "[A-Z]" "[a-z]"`
case $platform_raw in
"linux") platform='linux';;
"darwin") platform='mac';;
"freebsd") platform='freebsd';;
cygwin*) platform='windows';;
"sunos") platform='solaris';;
@jesseadams
jesseadams / autounit.sh
Created November 12, 2011 05:26
Automatically execute phpunit
#!/bin/bash
#
# Automatically run phpunit when you save a test
#
# Requires: inotify-tools
#
###################
path=$1
orig_dir=`pwd`
@jesseadams
jesseadams / orm.php
Created October 28, 2011 02:21
PHP ORM
$user = new User;
$user->name = 'foo';
$user->save;