Skip to content

Instantly share code, notes, and snippets.

View zmwangx's full-sized avatar
🐍
Pythonista learning new technologies

Zhiming Wang zmwangx

🐍
Pythonista learning new technologies
View GitHub Profile
@zmwangx
zmwangx / Save URL to Safari reading list.scpt
Created February 2, 2014 07:44
AppleScript for saving URL to Safari reading list.
set theUrl to do shell script "pbpaste | grep -o -E \"\\b(https?|ftp|file)://[-A-z0-9+&@#/%?=~_|.;]*[A-z0-9+&@#/%=~_|]\" | head -1"
if theUrl = "" then
set html to do shell script "osascript -e '«class HTML» of (the clipboard as record)' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))'"
set theUrl to do shell script "echo " & quoted form of html & " | grep -o -E \"\\b(https?|ftp|file)://[-A-z0-9+&@#/%?=~_|.;]*[A-z0-9+&@#/%=~_|]\" | head -1"
end if
using terms from application "Safari"
tell application "Safari"
add reading list item theUrl as string
end tell
@zmwangx
zmwangx / LaTeX - making tables and figures the same type of float.tex
Last active August 29, 2015 13:56
LaTeX - making tables and figures the same type of float
% This code snippet in the preamble makes tables and figures the same type of float, so that they are placed in the same queue (and hence appear in the order of appearance).
\makeatletter
\let\ftype@table\ftype@figure
\makeatother

To ignore whitespace when diffing in GitHub, simply append ?w=1 to the URL. e.g., compare this page and this page.

#!/usr/bin/env python3.3
# Convert LaTeX type dashes: - for hyphen, -- for en-dash, --- for
# em-dash to html: -, –, — in markdown.
#
# Usage:
# python dashify FILE_PATH
# ./dashify FILE_PATH
#
# One file allowed at a time. A backup file will be created each time
#!/usr/bin/env python
# Take one argument--the doi, and convert it to bibtex using an API
# call to dx.doi.org.
from sys import argv
import os
if argv[0].find('doi') != -1:
# run as executable
@zmwangx
zmwangx / Use custom script with xargs.md
Last active October 12, 2021 08:33
Explains how to use custom script with xargs without eating up all arguments in the first call.

To use xargs with custom script that takes in a fixed number of arguments, we need to use the replacement feature of xargs. For instance, given a script that indends to take one argument, e.g.

$ cat awesome.sh                                                      
#!/bin/zsh
is_awesome=' is awesome!'
awesome_sentence=$1$is_awesome
echo $awesome_sentence

A naive xargs call

@zmwangx
zmwangx / Black hole information paradox.md
Last active August 29, 2015 13:58
Black hole information paradox possible solutions.

Question: How does information get out of the black hole?

Proposed options:

  1. It doesn't get out -- black hole doesn't evaporate fully, information is in remnants.
*Problem*: Pathological properties. Remnants of the Planck scale (where Hawking's black hole radiation calculations fail) enclose a huge amount of entropy.
  1. Information never falls through the horizon ("brick wall").
@zmwangx
zmwangx / markdown-latex-etc.md
Last active March 5, 2023 09:47
An incomplete guide to Markdown, LaTeX, and more, initially written for Jiawen Li.

Markdown, LaTeX, etc.

Caution

  • (10/30/2016) I am not sure when and how this gist gained quite a few stars... But as stated in the v1.13 change log (from 06/16/2015): some content may be outdated, and I am not going to fix them. Moreover, having learned much myself, I do not necessarily agree with every point made in this document from 2.5 years ago. Therefore, please take views from this document with a grain of salt, and do further research as you see fit.

  • This document was initally written for a friend of mine, Jiawen Li, so it might reflect some personal tastes here and there. For instance, some discussions are geared towards Windows, though *nix is obviously superior. For another example, when I say "you seem to love Sublime Text a lot," I'm certainly not expecting most people to love Sublime (in fact I never used it for more than three minutes in a row).

  • This document is written in Markdown. The Markdown rendering engine on GitHub Gist is somewhat limited a

@zmwangx
zmwangx / ical.md
Created April 9, 2014 04:31
The iCalendar standard (.ics/.vcs) and validators.
@zmwangx
zmwangx / mac-keys-unicode.md
Last active January 8, 2024 03:32
Unicode characters for special keys on the Mac keyboard (not necessarily Mac specific). #symbols

⌘ – ⌘⌘ – the Command Key symbol
⌥ – ⌥⌥ – the Option Key symbol
⇧ – ⇧⇧ – the Shift Key symbol
⌃ – ⌃⌃ – the Control Key symbol
⎋ – ⎋⎋ – the ESC Key symbol
⇪ – ⇪⇪ – the Capslock symbol
⏎ – ⏎⏎ – the Return symbol
⌫ – ⌫⌫ – the Delete / Backspace symbol
⇥ – ⇥⇥ – the Tab Key symbol