Skip to content

Instantly share code, notes, and snippets.

🐍
Pythonista learning new technologies

Zhiming Wang zmwangx

🐍
Pythonista learning new technologies
Block or report user

Report or block zmwangx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zmwangx
zmwangx / stripNonBMPCharacters.m
Created Dec 29, 2019
Strip non-BMP characters from string in Mathematica <12.
View stripNonBMPCharacters.m
surrogateQ[ch_] := # >= 55296 && # < 57344 &@First@ToCharacterCode[ch];
surrogateQ::usage =
"Tests whether the given character is a surrogate, i.e., in the \
range U+D800 to U+DFFF.";
stripNonBMPCharacters[s_] :=
StringJoin[Select[Characters[s], ! surrogateQ[#] &]];
stripNonBMPCharacters::usage =
"Strips the given string of Unicode code points outside of the \
Basic Multilingual Plane (BMP), i.e., characters beyond U+FFFF, by \
@zmwangx
zmwangx / getgoogler.py
Created Nov 15, 2019
googler installation script (working copy)
View getgoogler.py
#!/usr/bin/env python3
import builtins
import collections
import hashlib
import os
import pathlib
import shutil
import subprocess
import sys
View _m.weibo.cn.md
@zmwangx
zmwangx / read_keypress_with_timeout.py
Last active Dec 29, 2018
Python: cross-platform code to read keypress with a timeout. Good for "press any key to continue" with an expiration timer.
View read_keypress_with_timeout.py
import os
import time
from typing import Optional
if os.name == "posix":
import select
import sys
import termios
import tty
@zmwangx
zmwangx / urlgrep
Created Dec 27, 2018
Python script to extract URLs from HTML documents.
View urlgrep
#!/usr/bin/env python3
"""Extract URLs from HTML documents."""
import argparse
import re
import sys
import urllib.parse
import bs4
@zmwangx
zmwangx / pythonista-ytdl.py
Created Dec 7, 2018
Share sheet extension to download YouTube videos and save them to apps of your choice, powered by youtube-dl and Pythonista
View pythonista-ytdl.py
import contextlib
import logging
import os
import shutil
import sys
import tempfile
import appex
import console
import youtube_dl
@zmwangx
zmwangx / fonts.reg
Created Oct 20, 2018
How to make Chinese filenames not so ugly in Windows 10
View fonts.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Segoe UI (TrueType)"="-segoeui.ttf"
"Segoe UI Black (TrueType)"="-seguibl.ttf"
"Segoe UI Black Italic (TrueType)"="-seguibli.ttf"
"Segoe UI Bold (TrueType)"="-segoeuib.ttf"
"Segoe UI Bold Italic (TrueType)"="-segoeuiz.ttf"
"Segoe UI Emoji (TrueType)"="-seguiemj.ttf"
"Segoe UI Historic (TrueType)"="-seguihis.ttf"
@zmwangx
zmwangx / .gitignore
Last active Jul 22, 2018
Trivial program to reload apache without root
View .gitignore
/a2graceful
@zmwangx
zmwangx / client.py
Last active May 29, 2019
Python requests.iter_content with timeout
View client.py
#!/usr/bin/env python3
import sys
import eventlet
eventlet.monkey_patch(socket=True)
from eventlet.timeout import Timeout
import requests
View python-benchmark-setup-macos
#!/usr/bin/env zsh
# macOS 10.13.2.
setopt xtrace errexit
ROOTDIR=$PWD/python-benchmark
brew install python2 python3 llvm llvm@4 llvm@3.9
You can’t perform that action at this time.