GistID: 5018623
GistURL: <https://gist.github.com/allex/5018623>
Author: Allex Wang (http://iallex.com)
This file contains hidden or 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
/* Inspired by Python's useful re.findall method */ | |
function findall(regex, str) { | |
var matches = [], m; | |
regex.lastIndex = 0; | |
while (m = regex.exec(str, regex.lastIndex)) { | |
matches[matches.length] = m; | |
} | |
return matches; | |
} |
This file contains hidden or 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
// vim: set ft=javascript | |
// removing c-styled comments using javascript | |
function removeComments(str) { | |
// Remove all C-style slash comments | |
str = str.replace(/(?:^|[^\\])\/\/.*$/gm, ''); | |
// Remove all C-style star comments | |
str = str.replace(/\/\*[\s\S]*?\*\//gm, ''); | |
return str; | |
} |
This file contains hidden or 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
# this can be put in [repo]/.git/config for local settings | |
# or ~/.gitconfig for global settings | |
# create a difftool "nodiff" that just returns true | |
# this path is for Mac. On linux it's /bin/true i guess | |
[diff "nodiff"] | |
command = /usr/bin/true | |
# make git ignore white space differences, many different possibilites here |
This file contains hidden or 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
// http://en.wikipedia.org/wiki/Linear_congruential_generator | |
var LCG = function(seed) { | |
return function () { | |
seed = (214013 * seed + 2531011) % 0x100000000; | |
return seed * (1.0 / 4294967296.0); | |
}; | |
}; | |
var random = LCG(10); |
This file contains hidden or 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
<!DOCTYPE html> | |
<meta charset=utf-8> | |
<meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1"> | |
<meta name=apple-mobile-web-app-capable content=yes> | |
<meta name=apple-mobile-web-app-status-bar-style content=black> | |
<title>Test fullscreen</title> | |
<style> | |
html, body { | |
margin: 0; | |
padding: 0; |
This file contains hidden or 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
# see also http://www.freehao123.com/htaccess-godaddy/ | |
# root .htaccess | |
<IfModule mod_rewrite.c> | |
# 关闭目录列表 | |
Options -Indexes | |
RewriteEngine on | |
# 预设页面 | |
DirectoryIndex default.html index.html default.html index.htm default.php index.php | |
# 统一网址,去掉www。如果你想保留www,自己在第二行添加 |
This file contains hidden or 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
var util = exports || {}; | |
util.mergeDeep = function(A, B, depth) { | |
var forever = depth == null; | |
for (var p in B) { | |
if (B[p] != null && B[p].constructor == Object && (forever || depth > 0)) { | |
A[p] = util.mergeDeep(A.hasOwnProperty(p) ? A[p] : {}, B[p], forever ? null : depth - 1); | |
} else { | |
A[p] = B[p]; | |
} |
This file contains hidden or 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
@echo off | |
REM ===================================== | |
REM Auto mount host server user directory | |
REM By allex ([email protected]) | |
REM ===================================== | |
if exist Z:\ goto :eof | |
echo Connecting host server, please wait . . . | |
ping HOST -n 5 >nul |
This file contains hidden or 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
// Author: Allex Wang ([email protected]) | |
// GistID: 5098339 | |
// GistURL: <https://gist.github.com/allex/5098339> | |
/** | |
* Generate a thumbnail by scaling images with canvas | |
* @method getThumbnail | |
* @param {String} str The original image src. | |
*/ | |
var getThumbnail = function(src, opts, callback) { |