Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
PS C:\nodecode\temp> node debug .\temp.js
< debugger listening on port 5858
connecting... ok
debug> c
< node.js:201
< throw e; // process.nextTick error, or 'error' event on first tick
< ^
< bar
program terminated
debug>
var Module = require("module");
function asyncrequire(name, callback) {
fs.readFile(name, "utf8", handleFileRead);
function handleFileRead(err, file) {
if (err) {
return callback(err);
}
var m = new Module(name, {
var http = require('http'),
url = require('url');
var server = http.createServer(onRequest)
server.listen(8888);
function onRequest(request, response) {
var parsedUrl = url.parse(request.url, true),
urlToExpand = parsedUrl.query.url;
typedef struct {
double* matrix;
double* left_edge;
double* right_edge;
int dim;
double precision;
int rank;
int nproc;
int* change_flags;
} RELAX_DATA;
@Raynos
Raynos / klass.js
Created December 20, 2011 19:56
klass
// https://github.com/Raynos/pd
var pd = typeof window === "undefined" ? require("pd") : window.pd;
var klass = (function() {
// meta data name
var meta = pd.Name();
return klass;
function klass(parent, child) {
/*
@emit 'controller.home' req req - Controller event is emitted whenever a request
comes in that matches the home route
@on 'server.express' - Listen on the server express event as to attach
the home route to the app.
*/
module.exports = {
attach: function attach() {
this.mediator.on('server.express', this.attachRoutes);
},
@Raynos
Raynos / after.js
Created January 6, 2012 15:23
EDA Y U CODE BLOAT
module.exports = {
attach: function attach() {
this.mediator.on("server.express", this.setVariables);
this.mediator.on("server.express", this.addMiddleware);
},
detach: function detach() {
this.mediator.removeListener('server.express', this.setVariables);
this.mediator.removeListener('server.express', this.addMiddleware);
},
destroy: function destroy() {
var fs = require("fs"),
path = require("path");
/*
@on 'moduleLoader.load' path - loader listens on the module loading command
This will load all the js files in the folder (or the file path) as
ncore modules
@on 'moduleLoader.autoload' path - same as load except it automatically
attaches the module to the core
@emit 'moduleLoader.loaded' module uri - every time a module is loaded
Publishing documentation to github...
Switched to branch 'gh-pages'
! rm: cannot remove `node_modules/express'
! : Is a directory
! rm: cannot remove `node_modules/groc/node_modules/glob/build/.wafpickle-7': Permission denied
rm: cannot remove `node_modules/groc/node_modules/glob/build/Release/deps/fnmatch/fnmatch_2.o': Permission denied
rm: cannot remove `node_modules/groc/node_modules/glob/build/Release/deps/fnmatch/fnmatch_5.o': Permission denied
! rm: cannot remove `node_modules/groc/node_modules/glob/build/Release/deps/glob/glob_1.o': Permission denied
rm: cannot remove `node_modules/groc/node_modules/glob/build/Release/deps/glob/glob_4.o': Permission denied
rm: cannot remove `node_modules/groc/node_modules/glob/build/Release/glob.node': Permission denied
@Raynos
Raynos / x.js
Created January 13, 2012 18:34
// NodeList
toArray(foos).forEach(function (el) {
el.style.color = 'red'
});
// NodeSet
foos.style.color = 'red';