Skip to content

Instantly share code, notes, and snippets.

View tdwong's full-sized avatar

T. David Wong tdwong

  • Cupertino, CA, USA
View GitHub Profile
@tdwong
tdwong / dummy-web-server.py
Last active April 28, 2016 06:45 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
#https://gist.github.com/bradmontgomery/2219997
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@tdwong
tdwong / punk.py
Created July 12, 2016 19:40 — forked from briandeheus/punk.py
Don't be a punk, punk
import binascii
import struct
class Punk(object):
_END_CHUNK_TYPE = 'IEND'
_PUNK_CHUNK_TYPE = 'puNk'
_MAX_BYTES = 2147483647
_chunks = dict()
@tdwong
tdwong / gist:c988c87d7812647d437516b5c4f62286
Created November 20, 2016 19:03 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@tdwong
tdwong / recover_source_code.md
Created March 11, 2017 17:39 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@tdwong
tdwong / htpasswd.py
Created May 8, 2017 17:26 — forked from eculver/htpasswd.py
htpasswd script in python (no need to install apache utils)
#!/usr/local/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
@tdwong
tdwong / Makefile
Created February 7, 2020 19:21 — forked from xenogenesi/Makefile
create self signed certificates
DOMAIN ?= mydomain.com
COUNTRY := IT
STATE := IT
COMPANY := Evil Corp.
# credits to: https://gist.github.com/fntlnz/cf14feb5a46b2eda428e000157447309
# usage:
@tdwong
tdwong / build.sh
Last active June 29, 2021 17:39 — forked from authmane512/build.sh
Sample build script to create Android app from command line
#!/bin/bash
set -e
AAPT="/path/to/android-sdk/build-tools/23.0.3/aapt"
DX="/path/to/android-sdk/build-tools/23.0.3/dx"
ZIPALIGN="/path/to/android-sdk/build-tools/23.0.3/zipalign"
APKSIGNER="/path/to/android-sdk/build-tools/26.0.1/apksigner" # /!\ version 26
PLATFORM="/path/to/android-sdk/platforms/android-19/android.jar"
@tdwong
tdwong / 00_Raspberry_Pi_3B+_as_AP
Last active April 26, 2023 00:48
Configure Raspberry Pi 3B+ as an AP
Configure Raspberry Pi 3B+ as an AP
Configure Raspberry Pi 4B as an AP
- use virtual interface wlan0_ap