Skip to content

Instantly share code, notes, and snippets.

View dingzeyuli's full-sized avatar

Dingzeyu Li dingzeyuli

View GitHub Profile
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -dPDFSETTINGS=/prepress -sOutputFile=compressed.pdf $1
# largest printer / prepress
# mid-size ebook
# smallest screen
@dingzeyuli
dingzeyuli / tmux_local_install.sh
Last active October 22, 2016 14:02 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
lin = @(x) x;
sqr = @(x) x.^2;
cub = @(x) x.^3;
x = -pi/2:pi/1000:pi/2;
y1 = atan(lin(tan(x)));
y2 = atan(sqr(tan(x)));
y3 = atan(cub(tan(x)));
@dingzeyuli
dingzeyuli / copy
Created November 11, 2016 15:33
Faster and more efficient alternative to scp for file copying
#!/bin/sh
# whenever you use "scp", use "copy" instead, it ignores duplicate files.
rsync -azhe ssh --progress $1 $2
@dingzeyuli
dingzeyuli / check_github_repo_size
Created December 16, 2016 22:34
Check the size of a github repo before downloading
# http://webapps.stackexchange.com/questions/39587/view-estimated-size-of-github-repository-before-cloning
# tested on macOS
echo https://github.com/torvalds/linux.git | perl -ne 'print $1 if m!([^/]+/[^/]+?)(?:\.git)?$!' | xargs -I{} curl -s -k https://api.github.com/repos/'{}' | grep size
# output:
# "size": 1746294,
@dingzeyuli
dingzeyuli / fix_mac_camera.sh
Created April 12, 2017 17:41
This script fixes Macbook's and iMac's Facetime Camera.
#!/bin/bash
sudo killall VDCAssistant
sudo killall AppleCameraAssistant
@dingzeyuli
dingzeyuli / DeleteGmusicDupes-Python35.py
Created April 16, 2017 23:05 — forked from TKIPisalegacycipher/DeleteGmusicDupes-Python35.py
Python script to find and delete duplicate tracks from Google Play Music library.
#!/usr/bin/env python
# created by shuichinet https://gist.github.com/shuichinet
# forked from https://gist.github.com/shuichinet/8159878 21 Nov 2015
# using minor edits by fcrimins https://www.reddit.com/user/fcrimins from https://www.reddit.com/r/google/comments/2xzgyv/remove_duplicate_songs_from_google_play_music/csh6mrh
# also using clever edits by Morgan Gothard https://medium.com/@mgothard
# updated for Python 3.5 by John M. Kuchta https://medium.com/@sebvance 22 Nov 2016 (hey I was busy)
# compiled by John M. Kuchta https://medium.com/@sebvance
# thanks to shuichinet, fcrimins and Mr. Gothard for their work
@dingzeyuli
dingzeyuli / install.sh
Last active June 19, 2017 17:24 — forked from kilfu0701/install.sh
Install PyQt5 with Python2.7 on Mac
cd ~
mkdir dev_tools
cd dev_tools
## download SIP source code
wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.16.7/sip-4.16.7.tar.gz
tar zxf sip-4.16.7.tar.gz
cd sip-4.16.7
python configure.py
make
@dingzeyuli
dingzeyuli / CoreTemp.sh
Last active September 27, 2017 14:23
get all the core temperature
cat /sys/devices/platform/coretemp.?/hwmon*/hwmon*/temp*_input
cat /sys/devices/platform/coretemp.?/hwmon*/hwmon*/temp*_input | awk '{ total += $1 } END { print total/NR/1000 }'
mv "$1" "$1".ori.pdf
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -dPDFSETTINGS=/prepress -sOutputFile="$1" "$1".ori.pdf
# the PDFSETTINGS can be set to following values for different compression ratio.
# largest printer / prepress
# mid-size ebook
# smallest screen