Skip to content

Instantly share code, notes, and snippets.

@TommyLau
TommyLau / wx_mp_markdown.css
Created September 4, 2016 11:32
Stylesheet for Weixin MP with Chrome Markdown.here plugin
/*
* NOTE:
* - The use of browser-specific styles (-moz-, -webkit-) should be avoided.
* If used, they may not render correctly for people reading the email in
* a different browser than the one from which the email was sent.
* - The use of state-dependent styles (like a:hover) don't work because they
* don't match at the time the styles are made explicit. (In email, styles
* must be explicitly applied to all elements -- stylesheets get stripped.)
*/
@TommyLau
TommyLau / signapk.sh
Created April 25, 2016 08:03
Android sign apk
#!/bin/bash
# Sample usage is as follows;
# ./signapk myapp.apk debug.keystore android androiddebugkey
#
# param1, APK file: Calculator_debug.apk
# param2, keystore location: ~/.android/debug.keystore
# param3, key storepass: android
# param4, key alias: androiddebugkey
USER_HOME=$(eval echo ~${SUDO_USER})
@TommyLau
TommyLau / mkver.sh
Created April 12, 2016 07:23
Generate version string based on the git repository
VERSION=$(git branch | sed -n -e 's/^\* release\/\(.*\)/\1/p')
if [ "$VERSION" == "" ]; then
echo "Develop branch"
VERSION="DEV"
else
VERSION="V$VERSION"
fi
BUILD=`git log --pretty=format:'' | wc -l | tr -d '[[:space:]]'`
HASH=`git log --pretty=format:'%h' -n 1`
TIME=`date '+%y%m%d%H%M'`
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
sudo sysctl -w net.inet.tcp.delayed_ack=0
sudo sysctl -w net.inet.tcp.mssdflt=1440
sudo sysctl -w net.inet.tcp.sendspace=250000
sudo sysctl -w net.inet.tcp.recvspace=250000
@TommyLau
TommyLau / push-web.sh
Created March 3, 2015 04:16
Stash post receive hooks
#!/bin/bash
# Make a temp file
keyfile=`mktemp`
# Get repository to push
repository="$1"
# Create the private key
while shift; do
@TommyLau
TommyLau / ddns.sh
Last active November 26, 2021 04:33
Tommy DnsPod DDNS Client
#!/bin/sh
########################################
#
# Tommy DnsPod DDNS Client v0.2.0
#
# Author: Tommy Lau <tommy@gen-new.com>
#
# Created: 2015-02-23 08:52:00 UTC
# Updated: 2016-07-15 15:48:00 UTC
@TommyLau
TommyLau / local.conf
Created February 16, 2015 08:29
Optimizing Shadowsocks
# max open files
fs.file-max = 51200
# max read buffer
net.core.rmem_max = 67108864
# max write buffer
net.core.wmem_max = 67108864
# default read buffer
net.core.rmem_default = 65536
# default write buffer
net.core.wmem_default = 65536
@TommyLau
TommyLau / hexo_gitbook.sh
Last active March 28, 2017 12:54
Generate GitBook project for Hexo
#!/bin/sh
# Setup the directory name
DIRNAME=GitBook
# Remove the old GitBook directory
rm -fr $DIRNAME
mkdir $DIRNAME
# Generate the README.md
cat <<-EOF >$DIRNAME/README.md
@TommyLau
TommyLau / install-docker.sh
Created January 15, 2015 12:03
Server scripts for installations
#!/bin/sh
# Check whether apt-get support https
[ -e /usr/lib/apt/methods/https ] || {
apt-get update
apt-get install apt-transport-https
}
# Add offical key
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9