Skip to content

Instantly share code, notes, and snippets.

We've received various questions on Ed and during hours about `ECONN...` errors. We've put together a short tips and tricks doc to help you debug these. These errors often come from subtle race-conditions.
### ECONNREFUSED
The message's recipient's HTTP server is not running at all at the time the message was sent. Examine whether you check for the recipient to start, then have the sender send a message. In other words, you are (a) starting the recipient node too late or (b) closing it too early.
### ECONNRESET
The message's recipient shut down during communication. This indicates that you are shutting down the recipient node too early. Typically, this error appears in tests because the done is misused. If done is called too early, you will get a `ECONNRESET`.
@nvasilakis
nvasilakis / screen.md
Last active June 2, 2020 20:34 — forked from fredrick/screen.md
GNU Screen Cheat Sheet

GNU Screen Cheat Sheet

Basics

Remember: in screen, all screen-related commands are prefixed by ctr-a (which means pressing ctrl and a together, and then pressing the followup character).

The 4 most basic commands (if you're new to screen, learn only these):

  • ctrl-a c -> create­ate new window
  • ctrl-a ctrl-a -> toggle between latest windows
  • ctrl-a " -> show all windows and choose using up/down arrows
  • ctrl-a d -> detach window
@nvasilakis
nvasilakis / partial-package.json
Created September 19, 2017 20:33 — forked from brianloveswords/partial-package.json
TypeScript autobuild and copy to clipboard. Useful for developing stuff where you can't actually access the content directly in a text editor (e.g. tampermonkey)
{
"scripts": {
"build": "tsc && npm run post-build",
"watch": "tsc-watch --onSuccess 'npm run post-build'",
"post-build": "rollup build/index.js --o build/bundle.js --f iife && cat src/prelude.js build/bundle.js | (pbcopy && osascript -e 'display notification \"Script copied to clipboard\" with title \"Script Builder\"' || echo 'copied script to clipboard')"
}
}
@nvasilakis
nvasilakis / 0.unsafe.js
Last active August 29, 2017 00:18
A minimal "vuln" example
x = "thisIsASecret";
function unsafeMain () {
var v = require('./0.vuln.js');
v.f()
}
unsafeMain();
@nvasilakis
nvasilakis / cc.js
Created July 31, 2017 00:05
color-console.js
// http://stackoverflow.com/questions/7505623/colors-in-javascript-console
// https://github.com/adamschwartz/log
// color-console
(function() {
var exportedLog, ffSupport, formats, getOrderedMatches, hasMatches, isFF,
isIE, isOpera, isSafari, log, makeArray, operaSupport, safariSupport,
stringToArgs, _log;
if (!(window.console && window.console.log)) {
return;
@nvasilakis
nvasilakis / memoize.js
Last active February 26, 2017 00:23
Cool prototype patching
function memoize(fun) {
// memoize a function with arbitrary arguments
var memo = {}
var name = fun.name || "anonymous";
return function memoize_fun() {
this.name = this.name + "__" + name;
var args = arguments;
var sargs = JSON.stringify(args);
if (memo[sargs]) {
return memo[sargs];
@nvasilakis
nvasilakis / Dockerfile
Created January 10, 2017 05:49 — forked from christianberg/Dockerfile
Sharing a unix socket between a Docker container and it's host
FROM ubuntu
RUN apt-get update
RUN apt-get install -y socat
VOLUME /foo
CMD socat UNIX-LISTEN:/foo/bar.sock -
/*
A simple new-line delimited JSON protocol with upgrades.
Receiving Usage:
protocol = require('./frame-protocol');
// parsing data
parser = protocol.Parser();
@nvasilakis
nvasilakis / object.js
Created July 18, 2015 20:14
A mini tutorial on JavaScript objects and inheritance
/**
* A mini tutorial on JavaScript Object Inheritance
*
* API myPerson = person.create() creates a person object
* myPerson.id set/get ID
* myPerson.name set/get name
* myPerson.age set/get age
* myPerson.salute() return a salute (incl. name)
* person.staticSalute() returns a static salute (no name)
*
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;