Skip to content

Instantly share code, notes, and snippets.

View dmail's full-sized avatar
🍒

Damien Maillard dmail

🍒
  • Datadog
  • Antibes
View GitHub Profile
@TooTallNate
TooTallNate / mouse.js
Created January 30, 2012 05:55
Enable "mouse reporting" with Node.js
// Based on:
// http://groups.google.com/group/nodejs-dev/browse_thread/thread/a0c23008029e5fa7
process.stdin.resume();
process.stdin.on('data', function (b) {
var s = b.toString('utf8');
if (s === '\u0003') {
console.error('Ctrl+C');
process.stdin.pause();
@domenic
domenic / README.md
Created March 29, 2012 16:01
Cross-platform git hooks for Node.js

Here's how this works:

  • Include a git_hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Add "npm" to your devDependencies in package.json, so that the pre-commit hook can do its magic.
  • Add test and lint scripts to your package.json, e.g.
    "scripts": {
        "test": "mocha",
 "lint": "jshint ./lib --show-non-errors"
@cowboy
cowboy / child-test.js
Created August 22, 2012 16:19
Node.js: I can't seem to capture a child process's stdout and stderr in Windows.
var parent = function() {
var spawn = require('child_process').spawn;
var child = spawn(process.execPath, [process.argv[1], 123]);
var stdout = '';
var stderr = '';
child.stdout.on('data', function(buf) {
console.log('[STR] stdout "%s"', String(buf));
stdout += buf;
});
child.stderr.on('data', function(buf) {
@dherman
dherman / loader-api.md
Last active January 31, 2019 03:02
Complete ES6 Loader API

Notational Conventions

This section describes the conventions used here to describe type signatures.

A [T] is an array-like value (only ever used read-only in this API), i.e., one with an integer length and whose indexed properties from 0 to length - 1 are of type T.

A type T? should be read as T | undefined -- that is, an optional value that may be undefined.

Loaders

@petsel
petsel / The-many-Talents-of-JavaScript.md
Last active February 21, 2017 11:33
The-many-Talents-of-JavaScript.md

#The many »Talents« of JavaScript

[TOC]

##The many talents of JavaScript for generalizing Role Oriented Programming approaches like Traits and Mixins

###TL;DR / Summary

@jdx
jdx / boot.js
Last active March 16, 2023 18:08
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@petsel
petsel / Array.flatten.js
Last active October 10, 2016 09:45
"Math.average", "Math.sum", "Array.flatten", "Array.shuffle", "Enumerable.shuffle", "Array.unique", "Enumerable.unique"
composable("composites.Array_flatten", function (require, global) {
"use strict";
var
environment = require("environment_extended_introspective_core"),
environment_introspective = environment.introspective,
@brigand
brigand / babel-ast-literal.js
Last active March 16, 2017 00:19
babel ast literals
var proxyIdentCounter = 0;
// matches ast`anything here`
var IDENTIFIER_NAME = "ast";
module.exports = function (babel) {
var babelParse = require('babel-core').parse;
// temporary
@dchowitz
dchowitz / es6-debugging-in-vscode.md
Last active August 30, 2023 06:23
Debugging ES6 in VS Code

Debugging ES6 in VS Code

My current editor of choice for all things related to Javascript and Node is VS Code, which I highly recommend. The other day I needed to hunt down a bug in one of my tests written in ES6, which at time of writing is not fully supported in Node. Shortly after, I found myself down the rabbit hole of debugging in VS Code and realized this isn't as straightforward as I thought initially. This short post summarizes the steps I took to make debugging ES6 in VS Code frictionless.

What doesn't work

My first approach was a launch configuration in launch.json mimicking tape -r babel-register ./path/to/testfile.js with babel configured to create inline sourcemaps in my package.json. The debugging started but breakpoints and stepping through the code in VS Code were a complete mess. Apparently, ad-hoc transpilation via babel-require-hook and inline sourcemaps do not work in VS Code. The same result for attaching (instead of launch) to `babel-node

composable("composites.Range", function (require, global) {
"use strict";
require("environment_extended_introspective_core");