Skip to content

Instantly share code, notes, and snippets.

View sowbug's full-sized avatar

Mike Tsao sowbug

View GitHub Profile
@sowbug
sowbug / event.js
Created April 25, 2014 19:38
A different way of letting users know that your Chrome extension or app has been installed/updated
chrome.runtime.onInstalled.addListener(function() {
var options = {
type: "basic",
title: "Version " +
chrome.runtime.getManifest().version +
" installed",
message: "Just thought you'd like to know that this extension is now installed!",
iconUrl: "assets/icon_128.png"
};
@sowbug
sowbug / create_split_secret.sh
Created October 12, 2015 04:12
Use Shamir's Secret Sharing Scheme to split a strong passphrase into five QR codes, any three of which will reconstruct the passphrase.
#!/bin/bash
#
# Use Shamir's Secret Sharing Scheme to split a strong passphrase into
# five QR codes, any three of which will reconstruct the passphrase.
#
# Requires packages qrencode, ssss, and optionally zbarimg.
PASSPHRASE_LENGTH=32
SHARES=5 # max 9 (fix single-digits below if you need more)
MIN_TO_COMBINE=3
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 0
#define NUM_PIXELS (16)
#define NUM_SPRITES (2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN,

Keybase proof

I hereby claim:

  • I am sowbug on github.
  • I am sowbug (https://keybase.io/sowbug) on keybase.
  • I have a public key ASB5RA9_urOndti5yz1PD3yTsS_dKnADrZVPCLTMd5Y7-wo

To claim this, I am signing this object:

@sowbug
sowbug / gist:c7f83140581fbe3e6a9b3ddf24891e77
Last active January 25, 2023 09:22
Making an encrypted DVD image
# All the code from http://billauer.co.il/blog/2010/10/encrypted-iso-dvd-luks-dm-crypt-fedora-linux/
MB_COUNT=100
VOL_NAME=MyVolName
DIR_TO_COPY=/tmp/mydir
# Make a 100MB disk image
dd if=/dev/zero of=disk.img bs=1M count=$MB_COUNT
# become root
@sowbug
sowbug / gist:5628ab9cd4a21c39808bf1d7113ef1f1
Created November 5, 2017 05:11
Generate 128-bit base58 passphrase from shell without dependencies
$ cat /dev/urandom | base64 | tr -cd [:alnum:] | tr -d [0OIl] | head -c 22
# same but emit QR code
$ cat /dev/urandom | base64 | tr -cd [:alnum:] | tr -d [0OIl] | head -c 22 | qr
@sowbug
sowbug / generate_refresh_token.py
Created December 25, 2017 23:34
Given a Google APIs Client ID and Client secret, get back a refresh token for Compute Engine
#!/usr/bin/env python
"""Generates refresh token for Google API."""
# This is adapted from generate_refresh_token.py in
# https://github.com/googleads/googleads-python-lib
import argparse
import sys
from oauth2client import client, GOOGLE_TOKEN_URI
@sowbug
sowbug / gce_server.py
Created December 25, 2017 23:44
A script that you can wrap with helper scripts to make it easier for your kids to start up the Minecraft server on their own.
#!/usr/bin/env python
# sudo pip install --upgrade google-api-python-client
from apiclient.discovery import build
from oauth2client import client, GOOGLE_TOKEN_URI
import argparse
import httplib2
import sys
@sowbug
sowbug / auto_download_microbit.py
Created January 1, 2018 19:24
Automatically moves BBC micro:bit files from the browser to the device
# usage:
#
# auto_download_microbit.py dir_to_watch dir_of_microbit
import os.path, shutil, sys, time
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
src = sys.argv[1] if len(sys.argv) > 1 else '.'
dst = sys.argv[2] if len(sys.argv) > 2 else '/Volumes/MICROBIT/'
@sowbug
sowbug / bitcoin-esp32.ino
Last active July 13, 2022 11:39
Display Bitcoin prices on a $10 OLED ticker
//
// For Wemos Lolin ESP32 OLED Module For Arduino ESP32 OLED WiFi + Bluetooth
//
// All of these are available in Arduino Library Manager
#include <ArduinoJson.h>
#include <HTTPClient.h>
#include <SSD1306.h>
#include <WiFiMulti.h>