Skip to content

Instantly share code, notes, and snippets.

View karlding's full-sized avatar
🤔

Karl Ding karlding

🤔
View GitHub Profile
@karlding
karlding / android-flashing.md
Created May 8, 2016 21:16
How to flash a new Android Factory Image, and various tips and tricks post-installation

Android fastboot flashing

Here are some instructions on how to successfully flash a new Android System Image.

Preparation

First download and extract the Android System Image that you want to flash. I'll be using hammerhead-mob30h, which is the May security update for my Nexus 5 (2013).

Extract the archive and enter the directory. You'll also want to extract the image-*.zip file as well (image-hammerhead-mob30h.zip in my case), which contains the other img files.

cd ~/Downloads/image-hammerhead-mob30h
@karlding
karlding / itunes-artist-photos.md
Created March 3, 2016 05:17
Grab iTunes image artwork from the DOM using the Open Graph meta tags

iTunes Artist Photos

The iTunes API doesn't provide a way to grab artist images, but the iTunes website uses Open Graph meta tags, which embeds a meta tag with a property attribute value set to og:image. As it turns out, this seems to be the same image used in the iTunes artwork.

The URL structure is similar to the artworkUrl values returned by the API, but what concerns us here is the part I've indicated at the end of the URL.

http://is3.mzstatic.com/image/thumb/Music7/v4/68/68/41/68684190-833b-bfb4-5018-e5a2e6f69eb0/source/1200x630bf.jpg
                                                                                                   └─ widthxheight
@karlding
karlding / downloading-vagrant-boxes-manually.md
Created January 14, 2018 05:45
how to download vagrant boxes manually

Download Vagrant boxes manually

In this example, we're going to download the Midnight Sun box.

# The box URL is https://app.vagrantup.com/uwmidsun/boxes/box/versions/2.1.0
# In general, we just take the box URL, and then append the provider URL
# https://app.vagrantup.com/<organization name>/boxes/<box name>/versions/<version>/providers/<provider>.box
wget https://app.vagrantup.com/uwmidsun/boxes/box/versions/2.1.0/providers/virtualbox.box -O box-2.1.0.box
@karlding
karlding / cygwin-symlinks.md
Created March 24, 2018 04:39
making cygwin use native symlinks
@karlding
karlding / pyenv+virtualenv cheat sheet.md
Last active June 2, 2020 03:45
pyenv and virtualenv cheat sheet
@karlding
karlding / testj1939.py
Created April 25, 2020 09:45
A partial re-implementation of testj1939 from can-utils in Python to test bpo-40291
"""A partial re-implementation of testj1939 from can-utils in Python to test
https://github.com/python/cpython/pull/19538
"""
import socket
def main():
with socket.socket(
family=socket.PF_CAN, type=socket.SOCK_DGRAM, proto=socket.CAN_J1939
) as s:
@karlding
karlding / bs-sans.py
Last active July 19, 2019 09:56
Parse TTX dumps and grab ligatures substitution rules found in GSUB tables (using Sans Bullshit Sans as an example)
import xml.dom.minidom
import sys
data = "".join(sys.stdin)
dom = xml.dom.minidom.parseString(data)
ligature_sets = dom.getElementsByTagName('LigatureSet')
char_map = dom.getElementsByTagName('cmap')[0].getElementsByTagName('cmap_format_4')[0].getElementsByTagName('map')
for ligature_set in ligature_sets:
@karlding
karlding / disable-narrator.reg
Created January 14, 2016 19:05
Disable Narrator
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Narrator.exe]
"Debugger"="%1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\AtBroker.exe]
"Debugger"="%1"
@karlding
karlding / find-modified-files-by-pr.sh
Created May 21, 2019 07:58
get a list of all files modified by the given PRs
#!/bin/bash
ACTIVE_PRS=(290 539 554 567)
DIFF_FILE="output.txt"
echo "" >| "${DIFF_FILE}"
for PR in "${ACTIVE_PRS[@]}"; do
git fetch origin pull/"${PR}"/head:pr-"${PR}"
git diff --name-only develop...pr-"${PR}" | tee -a "${DIFF_FILE}"

Keybase proof

I hereby claim:

  • I am karlding on github.
  • I am karlding (https://keybase.io/karlding) on keybase.
  • I have a public key ASDjk5bahFgKFcF7XNRR3loS6sakwJv0X0WE1ljuJSzefQo

To claim this, I am signing this object: