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
#!/usr/local/bin/node | |
var sys = require('sys'); | |
var http = require('http'); | |
var url = require('url'); | |
var PREFIX = '/db/'; | |
var TARGET = 'http://example.cloudant.com'; | |
var PORT = 8001; |
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
<?php | |
namespace Dogma\Database; | |
/** | |
* query(), fetch?(), exec(): | |
* New preprocesor makes dibi-like syntax possible. | |
* Question mark (?) is not required and *not allowed* in alternative syntax. | |
* eg. $db->exec("UPDATE x SET y = ", $y, "WHERE z = ", $z); |
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
/* -------------------------------------------------------------------------------- | |
Photo gallery | |
Find "-->" symbol and change image thumbnail/full size and urls. | |
CSS author: Martin Michalek, [email protected] | |
More: www.vzhurudolu.cz/test/image-gallery-enlarge-on-hover/ | |
*/ | |
/* Photo wrapper */ | |
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
/* traditional way */ | |
(function($) { | |
$(document).ready(function() { | |
$('#searchForm').submit(function(e) { | |
var term = $.trim($(this).find('input[name="q"]').val()); | |
if (!term) { return; } | |
$.getJSON( |
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
// module dependencies | |
var http = require('http'), | |
url = require('url'); | |
/** | |
* UrlReq - Wraps the http.request function making it nice for unit testing APIs. | |
* | |
* @param {string} reqUrl The required url in any form | |
* @param {object} options An options object (this is optional) |
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
<?php | |
$container->router[] = new Route('//old.nette.local/<path>', array( | |
'path' => array( | |
Route::PATTERN => '.*', | |
Route::FILTER_OUT => NULL, | |
), | |
'presenter' => 'Nette:Micro', | |
'callback' => function() use($container) { | |
$url = clone $container->httpRequest->url; |
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
$ node unicode.js | |
buf= <Buffer 5b 22 f0 9f 92 a9 22 0a 2c 22 f0 9f 98 81 22 0a 2c 22 5c 75 64 38 33 64 5c 75 64 63 61 39 22 0a 2c 22 5c 75 64 38 33 64 5c 75 64 65 30 31 22 0a 5d 0a> | |
str= ["💩" | |
,"😁" | |
,"\ud83d\udca9" | |
,"\ud83d\ude01" | |
] | |
obj= [ '💩', '😁', '💩', '😁' ] | |
obj[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
// minimal vertical spread | |
w = { foo : "bar" | |
, foo2 : { hello : "world" } | |
, foo3 : { wow : "this", is : "really", getting : "long" } } | |
// some more vertical spread | |
x = { foo : "bar" | |
, foo2 : { hello : "world" } | |
, foo3 : { wow : "this" | |
, is : "really" |
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
// first start node http_simple.js | |
var http = require('http'); | |
var latency = []; | |
var numRequests = parseInt(process.argv[2], 10) || 100; | |
var maxSockets = parseInt(process.argv[3], 10) || 100; | |
var runs = parseInt(process.argv[4], 10) || 100; | |
var r = 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
function getLine () { | |
var orig = Error.prepareStackTrace; | |
Error.prepareStackTrace = function(_, stack){ return stack; }; | |
var err = new Error; | |
Error.captureStackTrace(err, arguments.callee); | |
var stack = err.stack; | |
Error.prepareStackTrace = orig; | |
var s = stack[0]; | |
var l = s.getLineNumber(); | |
return s.fun.toString().split(/\r?\n/)[ l - 1 ]; |