Skip to content

Instantly share code, notes, and snippets.

View swanwish's full-sized avatar

Stephen swanwish

View GitHub Profile
@oleksii-zavrazhnyi
oleksii-zavrazhnyi / gist:968e5ea87e99d9c41782
Created November 28, 2014 17:32
BASH Absolute path of current script
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from

These will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you want to also resolve any links to the script itself, you need a multi-line solution:

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
@yulanggong
yulanggong / cnNum2ArabNum.js
Created August 7, 2012 01:05
中文数字转阿拉伯数字
var cnNum2ArabNum = function(cn){
var arab, parts, cnChars = '零一二三四五六七八九'
if (!cn) {
return 0
}
if (cn.indexOf('亿') !== -1){
parts = cn.split('亿')
return cnNum2ArabNum(parts[0]) * 1e8 + cnNum2ArabNum(parts[1])
@pitch-gist
pitch-gist / gist:2999707
Created June 26, 2012 22:21
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>