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
var express = require('express'); | |
var app = express.createServer(); | |
// User validation | |
var auth = express.basicAuth(function(user, pass) { | |
return (user==pass) ? true : false; | |
},'Admin Area'); | |
app.get('/hello', auth, function(req,res) { | |
res.writeHead("200"); |
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
// fs.copy(src,dst) && fs.copySync(src,dst) | |
var copy = function copy(src, dst, callback) { | |
var self = this; | |
if(!callback) { | |
callback = function(){}; | |
} | |
self.on('error', function(err) { |
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
curl http://crop.io/v1/c/?lurl=http%3A//www.example.org |
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
(function($) { | |
var tmpl = ''; | |
tmpl += '<div class="ui-grid-b">'; | |
tmpl += '<div class="ui-block-a" id=""><div class="ui-bar ui-bar-c" style="height:120px"><a href="#overview" data-role="button" class="ui-btn-right" data-icon="delete">Overview</a></div></div>'; | |
tmpl += '<div class="ui-block-b"><div class="ui-bar ui-bar-c" style="height:120px"><a href="#device" data-role="button" class="ui-btn-right" data-icon="delete">Device</a></div></div>'; | |
tmpl += '<div class="ui-block-c"><div class="ui-bar ui-bar-c" style="height:120px"><a href="#mapview" data-role="button" class="ui-btn-right" data-icon="delete">Map View</a></div></div>'; | |
tmpl += '<div class="ui-block-a"><div class="ui-bar ui-bar-c" style="height:120px">A</div></div>'; | |
tmpl += '<div class="ui-block-b"><div class="ui-bar ui-bar-c" style="height:120px">B</div></div>'; |
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
#define ASYNC_CALL(func, callback, ...) \ | |
FSReqWrap* req_wrap = new FSReqWrap(); \ | |
int r = uv_fs_##func(uv_default_loop(), &req_wrap->req_, \ | |
__VA_ARGS__, After); \ | |
assert(r == 0); \ | |
req_wrap->object_->Set(oncomplete_sym, callback); \ | |
req_wrap->Dispatched(); \ | |
return scope.Close(req_wrap->object_); |
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
#include <v8.h> | |
#include <node.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
using namespace node; | |
using namespace v8; | |
struct Test_req | |
{ |
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
for t in $(mysql --batch --column-names=false -e "show tables" dbname |grep -v "exclude_this"); | |
do | |
mysql -e "alter table $t engine=InnoDB" dbname; | |
done |
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
var a = { a: { b: 1 } }; | |
var b = ['a','b']; | |
var hashKeyExists = function(obj,path){ | |
var keys = path.split('.'); | |
var keyExists = function(obj,keyList){ | |
var cur = keyList.shift(); |
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
/** | |
* hasKeyExists | |
* | |
* Searches for a hierarchical combination of keys in a json object | |
* | |
* @{Object} JSON Object | |
* @{String} path seperated with "." for example level1.level2.foo | |
* @return {Boolean} | |
*/ | |
var hashKeyExists = function(obj,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
/** | |
* Small regular expression to match ASCII-chars between 32-126 | |
* | |
* For a conversion table for ASCII chars see: | |
* http://de.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange | |
*/ | |
var expr = /([\x20-\x7E]{1,})/gi; | |
var testString = "Foo Bar Barz"; | |
var testString2 = "Foo Bar\tBarz"; |
OlderNewer