Skip to content

Instantly share code, notes, and snippets.

View mikehwang's full-sized avatar

Michael Hwang mikehwang

View GitHub Profile
@mikehwang
mikehwang / list_emails.py
Last active March 5, 2020 15:55
Script to list emails using IMAP for the purpose of trying to **understand** how to parse emails for an ETL project
from imaplib import IMAP4_SSL
import email
# Usage: python list_emails.py <hostname> <user> <password>
# https://stackoverflow.com/questions/2230037/how-to-fetch-an-email-body-using-imaplib-in-python
# Was very helpful meaning I probably copied code from there
def list_emails(hostname, user, password):
try:
@mikehwang
mikehwang / adding-ca-cert-on-ubuntu.md
Last active January 30, 2020 13:53
Walk-through on adding a new CA cert on ubuntu and additional steps to make sure certain command-line apps work

I was getting SSL verification issues on my Ubuntu 18.04 machine because I was missing a root CA cert.

Let's call the new CA cert some-cert.pem.

I followed the first answer on this post:

cp some-cert.pem /usr/local/share/ca-certificates/some-cert.crt
sudo update-ca-certificates
@mikehwang
mikehwang / check_dir_contained.py
Created April 20, 2019 04:24
Python script to check if all files in one directory exists in another
"""Script checks to see if all files in src exists in dest"""
import os
import subprocess
def does_file_exist(dest: str, name: str):
"""Checks if the file exists
Approach was taken from
@mikehwang
mikehwang / bashrc-tidbits.md
Created April 22, 2017 21:10
Bashrc Tidbits

Prompt

  • Remove user and hostname
  • Show UTC datetime with the format "week of year, day of week, month, day, hour, minutes, seconds"
  • Show git branch name
PS1='$(date -u +"%U %a %m-%dT%k:%M:%S") ${debian_chroot:+($debian_chroot)}:\w $(__git_ps1 "(%s)")\$ '
@mikehwang
mikehwang / how-to-upstart-ngrok.md
Created November 8, 2016 13:09
Setting up upstart to run ngrok then to email tunnel info

How to add ngrok to upstart

Dependencies

  • upstart (tested on Ubuntu 14.04)
  • ngrok
  • ssmtp
  • jq
@mikehwang
mikehwang / jq-profilejsonschema.md
Last active April 7, 2024 17:55
Use jq to profile the schema of a given JSON object or an array of JSONs objects

Profile JSON schema

Using jq is great for examining JSON objects. You can extend its functionality with custom methods. The following is useful to understand at a high level the structure of arbitrary JSONs which is useful when trying to understand new data sources.

Requires jq verison 1.5.

Profile an object

Add the following method to your ~/.jq: