Skip to content

Instantly share code, notes, and snippets.

View ericksli's full-sized avatar

Eric Li ericksli

View GitHub Profile
@ericksli
ericksli / traffic-speed-map.kml
Created September 23, 2014 05:27
Data.One Traffic Speed Map KML
<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns='http://www.opengis.net/kml/2.2'>
<Document>
<name>Traffic Speed Map</name>
<description><![CDATA[]]></description>
<Folder>
<name>Links</name>
<Placemark>
<styleUrl>#line-0BA9CC-5</styleUrl>
<name>722-50059</name>
@ericksli
ericksli / file-hash.sh
Last active August 29, 2015 14:09
List all files with version hash in a Git repository
#!/bin/bash
# Usage: Git checkout to the commit you want, then run this script to print the files in the repository and its version hash.
files="`git ls-files`"
while read -r filename; do
hash="`git log -1 --pretty=%h ${filename}`"
echo -e "$filename\t$hash"
done <<< "$files"
@ericksli
ericksli / git-change-author.sh
Created December 1, 2014 08:31
Change the author of a Git commit using filter-branch, modified from GitHub's git-author-rewrite.sh
#!/bin/sh
git filter-branch --env-filter '
TARGET_COMMIT="b2e9c940f383c916d783d414ea8626c59922661a"
CORRECT_NAME="John Doe"
CORRECT_EMAIL="john.doe@gmail.com"
if [ "$GIT_COMMIT" = "$TARGET_COMMIT" ]
then
@ericksli
ericksli / align-box.html
Created December 3, 2014 04:48
Horizonal and vertical align middle
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Align Box</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
html {
height: 100%;
@ericksli
ericksli / share.html
Created February 23, 2016 02:02
Social media share pop-up
<ul class="dropdown-menu dropdown-menu-right" role="menu" data-share-list="share" aria-labelledby="comment-dropup-menu-2929">
<li><a rel="nofollow" data-share="facebook" href="http://facebook.com/share.php?u=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-facebook"></i> Facebook</a></li>
<li><a rel="nofollow" data-share="twitter" href="https://twitter.com/intent/tweet?url=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-twitter"></i> Twitter</a></li>
<li><a rel="nofollow" data-share="googlePlus" href="http://plus.google.com/share?url=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-google-plus"></i> Google+</a></li>
<li><a rel="nofollow" data-share="renren" href="http://share.renren.com/share/buttonshare?link=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-renren"></i> 人人網</a></li>
<li><a rel="nofollow" data-share="sinaWeibo" href="http://v.t.sina.com.cn/share/share.php?url=http%3A%2F%2Fcityuge.
@ericksli
ericksli / private.xml
Created March 15, 2016 06:02
Map the mouse button 4 and 5 to browser's back and forward commands using Karabiner
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>DELUX</vendorname>
<vendorid>0x093a</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>DELUX_M618</productname>
<productid>0x2521</productid>
@ericksli
ericksli / diff.sh
Created April 1, 2016 02:13
Diff PNG files between two folders and list out the images that are different using ImageMagick
#!/bin/bash
files=`find $1/*.png`
while read -r srcfile; do
name=`basename $srcfile`
targetfile="${2}/${name}"
result=`compare -metric RMSE $srcfile $targetfile /dev/null 2>&1;`
if [[ $result != 0* ]]; then
echo "${name} = ${result}"
@ericksli
ericksli / doze.sh
Created April 12, 2017 08:25
Check device idle state
#!/bin/bash
while true
do
adb shell dumpsys deviceidle step
sleep 1
done
@ericksli
ericksli / SemVer.kt
Last active June 18, 2017 13:29
Kotlin data object for Semantic Versioning (SemVer) 2.0.0 specification
/**
* Version number in [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html) specification (SemVer).
*
* @property major major version, increment it when you make incompatible API changes.
* @property minor minor version, increment it when you add functionality in a backwards-compatible manner.
* @property patch patch version, increment it when you make backwards-compatible bug fixes.
* @property preRelease pre-release version.
* @property buildMetadata build metadata.
*/
data class SemVer(
@ericksli
ericksli / lr-station-platform.json
Last active September 2, 2017 14:36
Hong Kong MTR Light Rail stations and platforms
[
{
"code": "001",
"initial": "FEP",
"titleZh": "屯門碼頭",
"titleEn": "Tuen Mun Ferry Pier",
"latitude": 22.37284525,
"longitude": 113.9661371,
"fareZone": "1",
"platforms": [