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 / man-convert.sh
Created April 18, 2014 07:34
Convert man pages to PDF or HTML.
# convert a manpage to PDF, and open in Preview
# (in fact, man -t generates PostScript, which is converted to PDF by Preview)
function pman {
man -t "${1}" | open -f -a /Applications/Preview.app
}
# convert a manpage to HTML and open in the browser
function bman {
tmpfile="/tmp/bman.$RANDOM.html"
man "${1}" | man2html > $tmpfile
@zmwangx
zmwangx / random-auctex-tips.md
Last active May 20, 2016 19:04
Some tips regarding AUCTeX/Emacs/LaTeX, from an email to Tri Dao on 04/22/2014.

Hi Tri,

The other builtin way to insert fraction is to use C-c RET, which is bound, in LaTeX mode (AUCTeX), to TeX-insert-macro, which is an interactive function. According to its help (C-h f TeX-insert-macro RET),

TeX-insert-macro is an interactive compiled Lisp function in `tex.el'.

It is bound to C-c RET, <menu-bar> <LaTeX> <Macro...>.

(TeX-insert-macro SYMBOL)
@zmwangx
zmwangx / thumbnails.sh
Last active March 3, 2024 15:51
Script to generate thumbnails of a video and combine into one tile image. Uses FFmpeg and ImageMagick.
#!/bin/zsh
# Script to generate thumbnails of a video and combine into one tile image.
#
# CAUTION:
# FFprobe might fail to extract duration info from a MKV container. Use
# ffmpeg -i video.mkv -c:v copy -c:a copy video.mp4
# to swap to an MP4 container.
#
# Dependencies:
# 1. ffmpeg
@zmwangx
zmwangx / exif-modify.sh
Created May 9, 2014 19:57
Modify Exif data (esp. date of creation) for correct chronological order in Carousel.
# Modify the `DateTimeOriginal' field for photos and the `CreateDate' field for videos, namely:
# photos
exiftool -overwrite_original -DateTimeOriginal="2014:05:09 12:57:16" $dir
# videos
exiftool -overwrite_original -CreateDate="2014:05:09 12:57:16" $dir
@zmwangx
zmwangx / erase_completed_downloads
Last active August 29, 2015 14:01
Chrome extension to erase completed items in the download history from the beginning of time, thus eliminating the downloads icon next to the address bar.
We couldn’t find that file to show.
@zmwangx
zmwangx / 20140527_port_installed
Created May 28, 2014 03:49
MacPorts: port installed output on 05/27/2014 (under which I successfully built GCC 4.9.0 on OS X 10.9.3).
The following ports are currently installed:
a52dec @0.7.4_0 (active)
bison @2.7.1_0 (active)
boehmgc @7.4.0_0 (active)
bzip2 @1.0.6_0 (active)
coreutils @8.22_0 (active)
cppunit @1.12.1_0 (active)
curl @7.37.0_0+ssl (active)
curl-ca-bundle @7.37.0_0 (active)
cwdiff @0.2.6_0 (active)
@zmwangx
zmwangx / configure_output
Created May 28, 2014 03:51
Output of configure when building GCC 4.9.0 on OS X 10.9.3 (with coreutils installed from MacPorts, see https://gist.github.com/ZhimingWang/b76e6168d88031b6f4f9).
checking build system type... x86_64-apple-darwin13.2.0
checking host system type... x86_64-apple-darwin13.2.0
checking target system type... x86_64-apple-darwin13.2.0
checking for a BSD-compatible install... /opt/local/libexec/gnubin//install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /opt/local/libexec/gnubin//sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libcilkrts support... yes
@zmwangx
zmwangx / make_output
Created May 28, 2014 03:52
Output of make -j4 when building GCC 4.9.0 on OS X 10.9.3 (with coreutils installed from MacPorts, see https://gist.github.com/ZhimingWang/b76e6168d88031b6f4f9).
This file has been truncated, but you can view the full file.
[ -f stage_final ] || echo stage3 > stage_final
mkdir -p -- build-x86_64-apple-darwin13.2.0/libiberty
Configuring in build-x86_64-apple-darwin13.2.0/libiberty
Configuring stage 1 in ./gmp
Configuring stage 1 in ./libiberty
Configuring stage 1 in ./intl
configure: creating cache ../config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking for makeinfo... makeinfo --split-size=5000000 --split-size=5000000
configure: creating cache ./config.cache
@zmwangx
zmwangx / make_install_output
Created May 28, 2014 03:53
Output of sudo make -j4 install when building GCC 4.9.0 on OS X 10.9.3 (with coreutils installed from MacPorts, see https://gist.github.com/ZhimingWang/b76e6168d88031b6f4f9).
/bin/sh /Users/zmwang/src/gcc/mkinstalldirs /usr/local /usr/local
rm -rf /usr/local/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools
/bin/sh /Users/zmwang/src/gcc/fixincludes/../mkinstalldirs /usr/local/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools
mkdir -p -- /usr/local/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools
/bin/sh /Users/zmwang/src/gcc/fixincludes/../mkinstalldirs /usr/local/lib/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools/include
mkdir -p -- /usr/local/lib/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools/include
/opt/local/libexec/gnubin//install -c -m 644 /Users/zmwang/src/gcc/fixincludes/README-fixinc \
/usr/local/lib/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools/include/README
/opt/local/libexec/gnubin//install -c fixinc.sh /usr/local/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools/fixinc.sh
/opt/local/libexec/gnubin//install -c fixincl /usr/local/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.0/install-tools/fixincl
@zmwangx
zmwangx / build_gcc.sh
Created May 28, 2014 04:08
Successful build of GCC 4.9.0 on OS X 10.9.3.
# setup:
# installed ports are listed at http://goo.gl/x0tTpu
# almost clean /usr/local
# download the source tarballs
# cloog, gmp, isl, mpc, mpfr, and most importantly, gcc
cd ~/src/tarballs
wget -q ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz
wget -q ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget -q ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2