Skip to content

Instantly share code, notes, and snippets.

Avatar

Bradley Farias bmeck

View GitHub Profile
View gist:432045
var sys=require("sys");
//and so the evil begins...
function Interface() {
//BE SURE TO UPDATE compile -> var a = ...
var $this={}
, _tags = {}
, _properties = {}
, _arguments = []
//adds an argument, higher priority than a private variable
$this.addArgument=function(argumentName,position,defaultValue) {
View [] accessor
require("overload").Watchable(
function(argInfo){
return typeof(argInfo.property)=='number'
? proxiedObj.item(argInfo.property)
: proxiedObj[argInfo.property];
}
,function(argInfo){return proxiedObj[argInfo.property]=argInfo.value}
,function(){return Object.getPropertyNames(proxiedObj)}
,function(argInfo){return argInfo.property in proxiedObj}
,function(argInfo){proxiedObj[delete argInfo.property]}
View gist:433642
Handle<Value> Compile(const Arguments& args) {
HandleScope scope;
Handle<String> src=args[0]->ToString();
Handle<Buffer> src_buffer=Handle<Buffer>(Buffer::New(src->Length()));
src->WriteUtf8(src_buffer->data());
ScriptData* scriptdata = ScriptData::PreCompile(src_buffer->data(),src->Length());
if(scriptdata->HasError()) {
return scope.Close(ThrowException(Exception::Error(String::New("Error in script"))));
}
View npm-list.md

npm list [filters]

display list of packages in a format (default is terse)

Filters

Filters take may subfilter with the syntax subfilter=pattern, if you need multiple subfilters separate them by commas, by default all filters must be matched to return a package. For filters on a set of data such as authors the filter only needs to match 1 entry out of the set.

Syntax

View async_test.js
module.exports = {a: 'async'}
console.log('in >> '+__filename)
View async template for jade
function compile(template, locals, callback | stream)
View switch use.js
switch(protocol) {
//first set it to secure
case "https:":
stream.setSecure(true)
case "http:":
stream.write(text)
stream.end()
break
case "ftp:":
...
View bundle.js
var static_scripts = {}
, require
;(function(){
var _require = require
var path = _require("path")
var Script = process.binding("evals").Script
var path_chain = ['.']
require = function(script_path) {
var file = path.join(path.dirname(path_chain[path_chain.length-1]),script_path)
function evaluate() {
View gist:499910
script loads via
resources.queue(type="script",url="...",blocks=["script","css"])
holds on script get a +1, holds on css +1
script handled via
resources.on("script")
default handler(stream,data=element,flush)
script.readyState = "loading"
buffer till ready to eval
You can’t perform that action at this time.