Skip to content

Instantly share code, notes, and snippets.

Jonathan Keam jkeam

View GitHub Profile
View heroku_postgres_table_dump.sh
# 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
View setup_postgres.sh
# 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 / mac_ip.sh
Created Dec 25, 2018
Get My Mac IP
View mac_ip.sh
#!/bin/bash
#ifconfig en0 | grep 'inet ' | awk '{print $2}'
ipconfig getifaddr en0
@jkeam
jkeam / getcert.sh
Last active Jan 25, 2018
Get SSL Cert
View getcert.sh
#!/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'
View python_installation_notes
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 / escape_newline.sh
Created Oct 12, 2017
I used this when taking multiline configs, like rsa keys to a single line that .env files can use.
View escape_newline.sh
awk '{printf "%s\\n", $0}' file
@jkeam
jkeam / replace_expo_urls.rb
Last active Aug 1, 2017
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.
View replace_expo_urls.rb
#!/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
View zoos_and_animals.viz
digraph SimplestDiagrams {
Zoo1
"Zoo1" -> "Cat"
"Zoo1" -> "Dog"
Zoo2
"Zoo2" -> "Cat"
"Zoo2" -> "Crow"
Zoo3
@jkeam
jkeam / gist:fdda2557ee2a28881f5a33356391f42c
Created Feb 17, 2017 — forked from sebboh/gist:f1dfe4f096746c45f3e9ea06a09743a0
Installing a Gem on Heroku from a Private GitHub Repo
View gist:fdda2557ee2a28881f5a33356391f42c

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

This method does not add your OAuth token to Gemfile.lock. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.

  1. Generate an OAuth token from GitHub
@jkeam
jkeam / gist:a8efc00c016b1f31f07aafb18a7fe9b1
Created Feb 17, 2017 — forked from sebboh/gist:f1dfe4f096746c45f3e9ea06a09743a0
Installing a Gem on Heroku from a Private GitHub Repo
View gist:a8efc00c016b1f31f07aafb18a7fe9b1

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

This method does not add your OAuth token to Gemfile.lock. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.

  1. Generate an OAuth token from GitHub
You can’t perform that action at this time.