Skip to content

Instantly share code, notes, and snippets.

@machuiwen
machuiwen / Mac.terminal
Created April 25, 2019 01:26
Mac terminal setup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NGMCAw
IDAAEAGAAtIQERITWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVj
dF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290gAEIERojLTI3O0FITltiaWttcn2GjpGa
@machuiwen
machuiwen / sys_info_page.sh
Created March 7, 2017 07:26
System report generator (HTML format)
#!/bin/bash
# sys_info_page: program to output a system information page
PROGNAME=$(basename $0)
TITLE="System Information Report For $HOSTNAME"
CURRENT_TIME=$(date +"%x %r %Z")
TIME_STAMP="Generated $CURRENT_TIME, by $USER"
report_uptime() {
@machuiwen
machuiwen / shuffle_file.sh
Created September 30, 2016 04:13
Shuffle files in a folder, for example musics.
#!/bin/bash
shuffle () {
if [ -d $1 ]; then
local folder=${1%/}
read -p "Do you really want to shuffle folder: $folder? (yes/no) > "
if [ $REPLY == "no" ]; then
exit 1
elif [ $REPLY != "yes" ]; then
echo "Invalid entry." >&2
@machuiwen
machuiwen / .vimrc
Created August 31, 2016 06:00
Vim configuration file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer: amix the lucky stiff
" http://amix.dk - [email protected]
"
" Version: 3.6 - 25/08/10 14:40:30
"
" Blog_post:
" http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc
" Syntax_highlighted:
" http://amix.dk/vim/vimrc.html
@machuiwen
machuiwen / .bash_profile
Last active April 25, 2019 01:10
My bash profile
alias zsh="chsh -s /usr/local/bin/zsh"
alias deleteTrash="rm -rf ~/.Trash/*"
# export TESSDATA_PREFIX="/usr/local/share/"
# export PATH=/Developer/NVIDIA/CUDA-5.0/bin:$PATH
export PATH=/usr/local/bin:$PATH
export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
export PYTHONPATH=/Users/WilliamMa/Desktop/:$PYTHONPATH
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
@machuiwen
machuiwen / git-prompt.sh
Last active September 1, 2016 21:52
This script allows you to see repository status in your prompt.
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
@machuiwen
machuiwen / emptyTrash.py
Created November 20, 2015 07:08
Python script to empty trash
#!/usr/local/bin/python
# delete all files and folders in trash box
import os
import sys
os.chdir('/Users/YourUserName/.Trash')
if len(sys.argv) >= 2:
if sys.argv[1] == '-t' or sys.argv[1] == '-T':
os.system("tree ./")
elif sys.argv[1] == '-l' or sys.argv[1] == '-L':
@machuiwen
machuiwen / ImageCompressor.m
Created October 21, 2015 18:31
convert any image format to jpeg-2000 format
% convert any image format to jpeg-2000 format
img = imread('/path/to/your/source/image.xxx');
imwrite(img,'/path/to/your/destination/image.jp2', 'compressionratio', 60);