Skip to content

Instantly share code, notes, and snippets.

@quickredfox
quickredfox / run.js
Created March 31, 2011 01:55
Runs a bunch of connect apps according to some private specs
var fs = require('fs');
var connect = require('connect');
var VHOSTS_DIR = '/srv/connect/apps';
var VHOSTS = {};
var hostsDirectory = function( req, res) {
res.writeHead( 200, {"Content-Type":"text/html"} );
names = [];
for( var vhost in VHOSTS ){
{
hose_name => [
{
title: 'Atlanta twitter content search',
entries_samples: [1,...],
polls_samples: [1,...],
entries_total : 345211,
polls_total : 44556
},
{
###
This file changes for every book, could be stored in database
###
BOOK.THEME = 1
BOOK.SECTION = 4
###
Here we declare the image files for the toy chest.
###
###
This file changes for every book, could be stored in database
###
BOOK.THEME = 1
BOOK.SECTION = 3
###
Here we declare the image files for the toy chest.
###
###
This file changes for every book, could be stored in database
###
BOOK.THEME = 1
BOOK.SECTION = 1
###
Here we declare the image files for the toy chest.
###
var fs = require('fs');
/**
* Offers functionality similar to mkdir -p
*
* Asynchronous operation. No arguments other than a possible exception
* are given to the completion callback.
*/
function mkdir_p(path, mode, callback, position) {
mode = mode || 0777;
@quickredfox
quickredfox / $.post.js
Created January 21, 2011 00:33
Un POST AJAX en jQuery
/* Je prétends que ton POST est pas Cross-Domain.. */
var tonCallback = function(textOrHTML){
// si textOrHTML est du JSON
var json = JSON.parse(textOrHTML);
// sinon
var resultDocument = $(textOrHTML);
};
// tu peut en plus de l'option "data" mettre des variables GET dans ton url...
function element(value, context) {
var ret = $([]); // $(context) ?
if (value.jquery) {
ret = value;
} else if (value == 'parent') {
ret = $(context).parent();
} else if (value == 'clone') {
ret = $(context).clone().removeAttr('id');
} else if (value == 'window') {
defineImportCallback = (script, callback) ->
unless script.readyState?
script.onload = -> callback()
return
# IE case
script.onreadystatechange = ->
if script.readyState is "loaded" or script.readyState is "complete"
script.onreadystatechange = null
callback()
@quickredfox
quickredfox / node-tiny-repl.js
Created November 7, 2010 22:14
Dangerously interesting.
var stdin = process.openStdin();
stdin.setEncoding('utf8');
stdin.on('data', logeval );
function logeval(chunk){
if(chunk) console.log( eval( chunk ) );
}