Skip to content

Instantly share code, notes, and snippets.

@AoJ
AoJ / proxy.js
Created December 1, 2011 21:06 — forked from steadicat/proxy.js
A reverse-proxy for CouchDB written in Node.js
#!/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;
@AoJ
AoJ / Connection.php
Created December 20, 2011 21:30 — forked from paranoiq/Connection.php
radostnější řazení paremetrů v Nette\Database\Connection
<?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);
@AoJ
AoJ / index.css
Created January 16, 2012 01:14 — forked from machal/index.css
CSS gallery with rounded corners on images and enlargement on hover. More at www.vzhurudolu.cz/test/image-gallery-enlarge-on-hover/
/* --------------------------------------------------------------------------------
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 */
@AoJ
AoJ / pubsub-demo.js
Created February 12, 2012 13:34 — forked from rmurphey/pubsub-demo.js
JS for pubsub screencast
/* traditional way */
(function($) {
$(document).ready(function() {
$('#searchForm').submit(function(e) {
var term = $.trim($(this).find('input[name="q"]').val());
if (!term) { return; }
$.getJSON(
@AoJ
AoJ / reqUrl.js
Created February 12, 2012 21:19 — forked from wilsonpage/reqUrl.js
A function I made that wraps the node http.request function to make it a little more friendly. In my case I am using it for API route testing.
// 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)
@AoJ
AoJ / bootstrap.php
Created March 20, 2012 19:52
Redirect from old domain to new domain
<?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;
@AoJ
AoJ / output
Created March 30, 2012 14:12 — forked from isaacs/output
This is working in node 0.7.7
$ 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]= 💩
@AoJ
AoJ / props.js
Created March 30, 2012 14:16 — forked from isaacs/props.js
// 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"
// 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;
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 ];