Skip to content

Instantly share code, notes, and snippets.

View DracoBlue's full-sized avatar

DracoBlue

View GitHub Profile
function a(b, c, callback) {
mysql_query("insert into magic_table pseudocode query (...)", function(status, data) {
if (status) {
callback(false, "Cannot add item!");
return ;
}
// do custom code
callback(true);
});
}
<?php
protected $module_folders = null;
/**
* Extended initializeModule for Agavi, allowing multiple modules-folders. *
*/
public function initializeModule($moduleName)
{
$lowerModuleName = strtolower($moduleName);
/*
* NodeJS Test Case for the blog post:
* "What's faster: JSON.parse+stringify or extend/mixin?"
* http://dracoblue.net/dev/whats-faster-jsonparsestringify-or-extendmixin/166/
*/
extend = process.mixin;
extend(true, {}, {})
var sys = require("sys");
fs.readFile(this.files[uri], "binary", function(err, content) {
if (err) {
res.sendHeader(404, {
});
} else {
res.sendHeader(200, {
"Content-Type": mime_type,
"Cache-Control": "public, max-age=300"
});
res.write(content, "binary");
res.writeHead(200, {
"Content-Type": mime_type,
"Cache-Control": "public, max-age=300",
'Content-Length': content.length
});
// a) works in 0.1.94:
var content_length = content.length;
var i = 0;
while (i<content_length) {
// picard_sample/app.js
require('./config/env')
get('/', function(){
return { text: '<h1>Hello to TestApp!</h1>' }
})
// express_sample.js
// Launched with this command:
// $ EXPRESS_ENV="production" node express_sample.js
var app = require('express').createServer();
app.get('/', function(req, res){
res.send('<h1>Welcome To Testapp</h1>');
});
app.listen(8080);
var one = 'http://blah'
, two = '/asdf/asdf/af'
;
function regexTest () {
var start = new Date();
var i = 0;
while (i<1000000) {
if ( !/^http?:/.test(one) ) true
if ( !/^http?:/.test(two) ) true
<?php
/**
* Reconstruct an array, for small task at: http://www.phpgangsta.de/kleine-aufgabe-ein-array-umbauen
* Contribution by DracoBlue
*/
function compress($in)
{
$in_length = count($in);
/**
* @module UserService
*
* @extends Logging
*/
extend(true, exports, Logging.prototype);
exports.logging_prefix = 'UserService';
var assert = require('assert');