Skip to content

Instantly share code, notes, and snippets.

View StreetStrider's full-sized avatar

Strider StreetStrider

  • Rostov-on-Don
  • 21:37 (UTC +03:00)
View GitHub Profile
@StreetStrider
StreetStrider / deepEqual.js
Created May 16, 2013 17:49
Weird deepEqual for Node.js.
module.exports = deepEqual;
var assert = require('assert');
function deepEqual ($1, $2)
{
try
{
assert.deepEqual($1, $2);
return true;
@StreetStrider
StreetStrider / repl.js
Last active December 17, 2015 12:09
Node.js REPL with custom prompt string and possibility to load-in scripts on start.
// see full package: https://github.com/StreetStrider/repl.js
#lang racket
(define (@map fn L)
(foldl
(lambda (i A)
(append A (list (fn i)))
)
empty
L
)
#lang racket
(define (@filter fn L)
(foldl
(lambda (i A)
(if (fn i)
(append A (list i))
A
)
)
@StreetStrider
StreetStrider / codes.c
Last active April 2, 2020 02:37
libuv error codes
XX( -1, UNKNOWN, "unknown error") \
XX( 0, OK, "success") \
XX( 1, EOF, "end of file") \
XX( 2, EADDRINFO, "getaddrinfo error") \
XX( 3, EACCES, "permission denied") \
XX( 4, EAGAIN, "resource temporarily unavailable") \
XX( 5, EADDRINUSE, "address already in use") \
XX( 6, EADDRNOTAVAIL, "address not available") \
XX( 7, EAFNOSUPPORT, "address family not supported") \
XX( 8, EALREADY, "connection already in progress") \
@StreetStrider
StreetStrider / locale.js
Created October 30, 2014 15:33
locale object
function Locale ()
{
var locale = Object.create(Locale.prototype);
locale.ns = {};
return locale;
}
var isArray = Array.isArray;
module.exports = function strip (ast)
{
ast = ast.filter(filterOnlyLeaves(like));
ast = ast.map(mapOnlyBranches(strip));
return ast;
}
#!/usr/bin/env node
var
exec = require('child_process').exec,
path = require('path');
var
is_reverse = ~ process.argv.indexOf('reverse');
sync = require('./sync.list'),
LEFT_PREFIX = '~',
function Ensure (check, action)
{
return function ensurer (data)
{
return capture(() => check(data))
.then(so =>
{
if (! so)
{
if (! action)
@StreetStrider
StreetStrider / compress.js
Created October 23, 2020 21:58
compress-decompress
var log = console.log
var input = 'LLLAABBBBBEE'
log(input)
var c = compress(input)
log(c)
var d = decompress(c)