This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php | |
function human_filesize($bytes, $decimals = 2) { | |
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); | |
$factor = floor((strlen($bytes) - 1) / 3); | |
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor]; | |
} | |
echo human_filesize(filesize('example.zip')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'Safari Developer Library': 'https://developer.apple.com/library/safari/navigation/index.html', | |
'Safari HTML Reference': 'https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html', | |
'Safari Web Content Guide': 'https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/Introduction/Introduction.html' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* find all markdown files in given directory, (here just current directory) | |
* and then fetch their title to generate index markdown file | |
* | |
* use -v to show verbose detail | |
* use -o to specify output file, default to ./index.md | |
* use -d to specify scanner directory, such as -d the_directory, default to ./ | |
*/ | |
var fs = require('fs'), | |
path = require('path') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
decodeSpecialUnicode: function(str) { | |
var ptn = /\\u([0-f]{4})/ig; | |
return str.replace(ptn, function(match, group) { | |
return String.fromCharCode(parseInt(group, 16)); | |
}); | |
}, | |
encodeSpecialUnicode: function(str) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://github.com/mishoo/UglifyJS2/blob/harmony/lib/output.js | |
function to_ascii(str) { | |
return str.replace(/[\ud800-\udbff][\udc00-\udfff]|[\u0000-\u001f\u007f-\uffff]/g, function (ch) { | |
var code = get_full_char_code(ch, 0).toString(16); | |
if (code.length <= 2) { | |
while (code.length < 2) code = "0" + code; | |
return "\\x" + code; | |
} else { | |
while (code.length < 4) code = "0" + code; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from: https://jsperf.com/deep-copy-vs-json-stringify-json-parse/15 | |
function recursiveDeepCopy(o) { | |
var newO, | |
i; | |
if (typeof o !== 'object') { | |
return o; | |
} | |
if (!o) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple JavaScript Templating | |
// John Resig - http://ejohn.org/ - MIT Licensed | |
(function(){ | |
var cache = {}; | |
this.tmpl = function tmpl(str, data){ | |
// Figure out if we're getting a template, or if we need to | |
// load the template - and be sure to cache the result. | |
var fn = !/\W/.test(str) ? | |
cache[str] = cache[str] || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
# use optipng to optimize png | |
if type -q optipng | |
set pngs (command find . -name "*.png") | |
for i in $pngs | |
# echo $i | |
optipng -strip all $i | |
end | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import requests | |
import bs4 | |
import re | |
import os | |
import sys | |
from multiprocessing import Pool, cpu_count | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git rev-parse --abbrev-ref HEAD |