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 / 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
@zmwangx
zmwangx / literalize_regex.sh
Created May 28, 2014 08:01
Regex: escape all meta characters in a string. Keywords: escape, literal, meta, regex.
# this is experimental, assuming the metacharacters are ^[.${*(\+)|?
gsed -e 's/[\^\[\.\$\{\*\(\\\+\)\|\?]/\\&/g'
@zmwangx
zmwangx / unix_system_mail.md
Created May 29, 2014 06:27
A little tutorial (more accurately, several basic tips) on UNIX system mail. This is a clone of the post http://kevinsayhiiiiiiiii.tumblr.com/post/87179246018/05-28-2014-getting-started-with-unix-system-mail. (That's my blog, btw.)

BSD periodic can no longer satisfy my needs, so I switched to Vixie cron last week, and also got started with system mail. (Of course periodic can also mail results, but I never took advantage of that.) I'll list the things I've learned about mail thus far.

Warning: Here are things I've learnt on OS X 10.9. YMMV on other systems.

  1. It's easy to let cron email output to you. Add to your crontab

     MAILTO=torvalds,torvalds@klaava.helsinki.fi
    

    As in the above example, you can either specify a local user, e.g., torvalds, or an actual email address, torvalds@klaava.helsinki.fi. Do separate email addresses with a comma. Do not add an extra space. See man 5 crontab, though you might not find the tip above.

@zmwangx
zmwangx / emacs-pb.el
Last active August 29, 2015 14:02
Emacs: make kill ring and system pasteboard function more reasonably in window systems.
;;; Tested on:
;;; 1. GNU Emacs 24.3.1 (x86_64-apple-darwin13.0.0)
;;; of 2013-12-22 on tennine-slave.macports.org
;;; (MacPorts emacs@24.3_1)
;;;
;;; 2. GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
;;; of 2013-03-12 on bob.porkrind.org
;;; (Emacs For Mac OS X)
(defun isolate-kill-ring()
@zmwangx
zmwangx / html-entity-decode
Created July 1, 2014 19:25
Shell script: decode html entities via php.
#!/bin/bash
# The ENT_QUOTES flag converts both double and single quotes.
# See http://www.php.net/manual/en/function.html-entity-decode.php.
php -R 'echo html_entity_decode($argn, ENT_QUOTES)."\n";'
@zmwangx
zmwangx / test-newline.sh
Created July 4, 2014 16:37
Bash: test for newline in a string.
#!/bin/bash
# Use pattern matching: http://goo.gl/q6qNco.
# The newline in the pattern string needs to be quoted.
# See ANSI-C quoting: http://goo.gl/I3HZTR
string=$(echo -e 'hello\nworld')
if [[ ${string} == *$'\n'* ]]; then
echo 'newline detected' >&2
else
@zmwangx
zmwangx / ports.txt
Last active August 29, 2015 14:04
MacPorts: my list of installed ports. Auto resolved deps are not included.
bison
bzr
coreutils
dos2unix
emacs
fdupes
ffmpeg +gpl2+nonfree
gawk
gcc48
getopt
@zmwangx
zmwangx / ere-uri.md
Created August 28, 2014 22:54
Regex matching URI (with POSIX Extended Regular Expressions — ERE). #regex #ere #uri

Below are POSIX ERE expressions matching relevant expressions defined in RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax, constructed according to the ABNF definitions.

# RFC 3986
# http://tools.ietf.org/html/rfc3986
#
# pct-encoded   %[0-9A-Fa-f]{2}
# reserved      [:/?#[]@!$&'()*+,;=]
# gen-delims    [:/?#[]@]
# sub-delims    [!$&'()*+,;=]

unreserved [A-Za-z0-9._~-]

@zmwangx
zmwangx / pip.txt
Last active August 29, 2015 14:06
pip: my list of installed packages, auto deps removed
beautifulsoup4
colorama
feedparser
flickrapi
grip
pipdeptree
pyimgur
python-dateutil
python-magic
requests