Skip to content

Instantly share code, notes, and snippets.

View haohello's full-sized avatar
🎯
Focusing

haohello

🎯
Focusing
View GitHub Profile
@haohello
haohello / gist:5497340
Created May 1, 2013 18:44
Extensible UMD Plugins
;(function ( name, definition ){
var theModule = definition(),
// this is considered "safe":
hasDefine = typeof define === 'function' && define.amd,
// hasDefine = typeof define === 'function',
hasExports = typeof module !== 'undefined' && module.exports;
if ( hasDefine ){ // AMD Module
define(theModule);
} else if ( hasExports ) { // Node.js Module
@haohello
haohello / gist:5351668
Last active December 16, 2015 00:59
Uploading a file using asp.net mvc web api [please refer to this url] (http://blogs.msdn.com/b/henrikn/archive/2012/03/01/file-upload-and-asp-net-web-api.aspx)
<!DOCTYPE HTML>
<html>
<head>
<title>HTML5 Multiple File Upload Sample</title>
</head>
<body>
<form action="http://localhost:8080/api/upload" enctype="multipart/form-data" method="POST">
What is your name?
<input name="submitter" size="40" type="text"><br>
What files are you uploading?
if [[ "$PATH" == *"/usr/local/mips-2012.09/bin"* ]]; then
echo codesourcery toolchain path is already in PATH var
else
export PATH="/usr/local/mips-2012.09/bin:$PATH"
echo added codesourcery toolchain path to PATH var
fi
export AR=mips-linux-gnu-ar
export CC='mips-linux-gnu-gcc -EL'
export CXX='mips-linux-gnu-g++ -EL'
app.get('/help', function(req, res){
res.send('some help');
});
app.get('/search/:query/p:page', function(req, res){
var query = req.params.query
, page = req.params.page;
res.send('search "' + query + '", page ' + (page || 1));
});
@haohello
haohello / general-patterns-function-declarations
Created April 4, 2012 08:29
创建匿名函数并将其赋值于一个变量
/* 标题: 函数声明
* 描述: 创建匿名函数并将该函数赋值于一个变量
*/
// 反模式
function getData() {
}
// 建议的模式