Skip to content

Instantly share code, notes, and snippets.

View jkeam's full-sized avatar
🍻

Jon Keam jkeam

🍻
View GitHub Profile
@jkeam
jkeam / zoos_and_animals.viz
Created March 22, 2017 20:38
Zoos and Animals
digraph SimplestDiagrams {
Zoo1
"Zoo1" -> "Cat"
"Zoo1" -> "Dog"
Zoo2
"Zoo2" -> "Cat"
"Zoo2" -> "Crow"
Zoo3
@jkeam
jkeam / replace_expo_urls.rb
Last active August 1, 2017 06:54
Ruby script to update expo config files that need to be updated as you change networks. This script will update the urls expo is using to serve up the JS resources. This configs should be auto updated during the build process, but for some reason it sometimes does not work. Running this script will fix those urls.
#!/usr/bin/env ruby
require 'json'
require 'rexml/document'
include REXML
def fix_exshell_json(filename, url)
json_file = JSON.parse File.read(filename)
json_file['developmentUrl'] = url
File.open(filename, 'w') { |file| file.puts(json_file.to_json) }
end
@jkeam
jkeam / escape_newline.sh
Created October 12, 2017 16:57
I used this when taking multiline configs, like rsa keys to a single line that .env files can use.
awk '{printf "%s\\n", $0}' file
@jkeam
jkeam / python_installation_notes
Created November 25, 2017 06:30
Installing Python
Install These Tools:
https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-virtualenv
Then in .zshrc add:
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
@jkeam
jkeam / getcert.sh
Last active January 25, 2018 18:37
Get SSL Cert
#!/bin/sh
#
# usage: getcert.sh remote.host.name [port]
# eg) getcert.sh api.mailgun.net
#
RHOST=$1
RPORT=${2:-443}
# see cert
echo -n | openssl s_client -connect ${RHOST}:${RPORT} | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
@jkeam
jkeam / mac_ip.sh
Created December 25, 2018 04:50
Get My Mac IP
#!/bin/bash
#ifconfig en0 | grep 'inet ' | awk '{print $2}'
ipconfig getifaddr en0
@jkeam
jkeam / setup_postgres.sh
Created February 20, 2019 02:41
Postgres Setup
# install postgres
sudo apt update
sudo apt install postgresql postgresql-contrib libpq-dev
# login as postgres user
sudo -i -u postgres
# log into psql shell
psql
@jkeam
jkeam / heroku_postgres_table_dump.sh
Created February 25, 2019 15:12
Heroku Table Dump
# get database info
heroku config:get DATABASE_URL -a app_name
# dump command
pg_dump --column-inserts --no-acl --no-owner -h host_name -U postgres_user -t table_name --data-only db_name > output_filename.dump
@jkeam
jkeam / show_codesigning_identities.sh
Created May 12, 2019 16:06
A lot of times building things on Macs require you to use to a codesigning identity. This quick one-liner will show you your code signing identities.
#!/bin/bash
security find-identity -v -p codesigning
@jkeam
jkeam / encode_base64.sh
Created May 29, 2019 01:36
Encode a file into a base 64 format
#!/bin/bash
# -A doesn't print out newlines and entire file will be on a single line.
openssl base64 -A -in ./input_file -out ./output_file