Skip to content

Instantly share code, notes, and snippets.

@Raynos
Raynos / SomeKlass.js
Created November 9, 2011 20:07
OO utilities
var SomeKlass = (function () {
var privates = Name();
return {
public_method: public_method,
public_prop: 42,
constructor: constructor
};
function public_method() {
@Raynos
Raynos / a.md
Created January 23, 2012 19:48
Shim status of ES6

ES6 what can be shimmed and what not.

Currently only lists things that can be shimmed or are experimentally implemented

Note that for any kind of decent ES6 support we need an ES6 transpiler. A few projects are attempting this [Reference SO question][3]

  • [traceur][4]
  • [Caja][5]
  • [ES transpiler][6]
@mkristian
mkristian / pom-compass.xml
Last active August 2, 2016 14:28
using gem-maven-plugin to compass compile or execute sass. sass with gem dependency within plugin and compass with global compile dependency (which is also added to the java-classpath and not so nice)
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>0.0.36</version>
function foo() {
bar({|x|
return 10;
});
}
function bar(block) {
block();
block(); // we should never get here. how?
}
foo();
1. Port http_parser.c to JS so we can not keep parsers around forever.
This will be a one-month time-boxed experiment. If it's not acceptable, then
we just have to live with it the way it is now.
2. Clean up lib/http.js. Split into http_client.js and http_server.js
API must remain stable, but code should be separated and organized more clearly.
3. process.nextTick semantics change. Clear the queue after every V8 invocation.
See how rough this is for starvation issues, maybe keep track of the depth, and
do a setTimeout(fn,0) if it's > 10000 or something.
@dominictarr
dominictarr / stream.markdown
Created July 15, 2012 14:32
Stream tweaks proposal

Stream tweaks proposal

The stream is a powerful tool, not just for IO, -- but, in the best Unix tradition -- for composition of modules. I've been connecting streams into quite long chains.

Some streams I have written do not alter the data in the stream, but affect it is some way, such as buffering when the stream is paused. pause-stream

Also, I've been writing high level abstractions that communicate via streams, and do some interesting high level stuff, Such as by replicating data, snob and crdt, or multiplexing mux-demux. Another good example is dnode.

These abstractions expose a stream on their interface, and so can be used over any io channel which supports pipe.

@ritch
ritch / domain-example.js
Created October 4, 2012 14:38
How to do domains...
// based on an example by @mikeal
var http = require('http')
, domain = require('domain')
;
module.exports = function (handler) {
var server = http.createServer(function (req, resp) {
var d = domain.create()
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@lukehoban
lukehoban / gist:3900992
Created October 16, 2012 18:11
ES6 module syntax alternatives
Things I want to be able to do:
a) Bind a name to a remote module
b) Alias a name for a module
c) Alias a name for a member of a remote module
d) Put all names from inside a module in lexical scope
e) Put all names from inside a remote module in lexical scope
f) Put a few names from inside a module in lexical scope
g) Define a local module
h) Export names from lexical scope
i) Re-export names from other modules

ES6 -> CJS Tranpilation for UMD

ES6 and AMD require paths are raw, you can make them mean whatever you want, but by default mean baseUrl+path. In npm the paths are relative to the file calling require if the path starts with a directory separater, if there is no separator it looks in node_modules. For example:

// looks in node_modules
// we'll call this a "vendor require"
var handlebars = require('handlebars');
// looks relative to this file