Skip to content

Instantly share code, notes, and snippets.

View tim-smart's full-sized avatar

Tim tim-smart

View GitHub Profile
@tim-smart
tim-smart / ctags definitions for Javascript
Created October 2, 2009 00:07
CTags Definitions for Javascript
--langdef=js
--langmap=js:.js
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*[ \t]*([,;]|$)/\5/,variable/
exports.AutoLoader = function() {};
AutoLoader.prototype.autoload = function(type, filePath, includeAsType) {
var obj = undefined;
if(includeAsType === undefined) includeAsType = true;
this.__defineGetter__(type, function(){
if(!obj){
obj = require(filePath);
if(includeAsType) obj = obj[type];
}
tim@tim-laptop ~ $ ab -c 100 -n 1000 http://localhost:8000/fostle/static/images/fade_bg.gif
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
exports.hotRequire = function(variable, path, prop = null) {
if ("string" === typeof prop)
module.parent.exports.scope[variable] = require(path)[prop];
else
module.parent.exports.scope[variable] = require(path);
(function(variable, path, prop) {
process.watchFile(path, function() {
if ("string" === typeof prop)
module.parent.exports.scope[variable] = require(path)[prop];
// Automatic parse querystrings. If "^/home" is specified,
// it will also check for "^/home?somedata=test"
Get(["^/(home)(.*)", "^/(news)(.*)"], function(details, regexMatch) {
details.params["help"];
...
}
Post(..., function(details, regexMatch) {
details.params["username"];
...
var http = require('http'),
sys = require('sys'),
path = require('path'),
posix = require('posix'),
events = require('events');
var Walker = function() {
this._counter = 0;
};
Walker.prototype = {
var Walker = require('./walker').Walker;
var walker = new Walker();
walker.walk('/home/test/', function(structure) {
// structure now contains dir tree
// The directory / filename
structure.name;
var sys, path, file, random;
require({
"sys": sys,
"path": path,
"file": file,
"./module": random
}, function() {
//Call main function etc
main();
// exports defined out here.
exports.foo = "bar"
require(
"sys", "file", "persistence/sqlite3"
)(function (sys, file, sqlite) {
sys.p(File);
// Rest of program here
});
var vars = {};
exports.hot = function(path) {
vars = require(path);
process.watchFile(path + ".js", function() {
process.mixin(vars, require.unCache(path));
});
return vars;