Skip to content

Instantly share code, notes, and snippets.

mscdex mscdex

Block or report user

Report or block mscdex

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mscdex / encoder.js
Created Jun 12, 2016
Encode text into a PNG
View encoder.js
const kCRCTable = new Int32Array([
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
mscdex / bitCount.js
Created Mar 13, 2016
Fastest bit counting for 32-bit numbers in javascript
View bitCount.js
function bitCount(u) {
const uCount = u - ((u >> 1) & 0o33333333333) - ((u >> 2) & 0o11111111111);
return ((uCount + (uCount >> 3)) & 0o30707070707) % 63;
mscdex /
Last active Apr 9, 2020
ssh shell session from the browser


  1. npm install express faye-websocket ssh2 term.js
  2. Create a public subdirectory
  3. Place client.htm in public
  4. Edit the ssh connection details in server.js. See the documentation for the connect() method in the ssh2 readme for more information.
  5. Start the server with node server.js
  6. Visit http://localhost:8000/client.htm in a WebSocket-capable browser
mscdex / gcc-5.2.0-musl.diff
Created Oct 13, 2015
Fixed MIPS patch for gcc 5.2.0 with musl
View gcc-5.2.0-musl.diff
# HG changeset patch
# Parent 9b5795e98965ab4820a65ceeae0de644d0c5a9bb
Use the generic implementation of libstdc++ primitives when we're on musl, not the glibc one.
diff -r 9b5795e98965 libstdc++-v3/
--- a/libstdc++-v3/ Sun Jul 26 15:42:47 2015 -0400
+++ b/libstdc++-v3/ Sun Jul 26 15:46:09 2015 -0400
@@ -274,6 +274,13 @@
mscdex /
Created Aug 30, 2015 — forked from thlorenz/
Script to update Node.js addons to work with nan 2.0.x and thus with iojs v3.x (gets you 90% there)
View loc_parser.go
// loc_parser: functions to parse the textual part of a LOC record
// stored in our DNS. The key function here is parseLOCString which
// should be passed a dns.LOC and a string containing the latitude,
// longitude etc.
// This is an implementation of RFC 1876. Read it for background as
// the format in a dns.LOC is slightly unusual.
// Copyright (c) 2014 CloudFlare, Inc.
mscdex / isoagent.js
Created Nov 10, 2014
Http.Agent instance for response headers with latin1 characters
View isoagent.js
// First: `npm install agent-base streamsearch iconv-lite`
var http = require('http'),
net = require('net'),
EventEmitter = require('events').EventEmitter,
HTTPParser = process.binding('http_parser').HTTPParser,
parsers = http.parsers;
var agentBase = require('agent-base'),
StreamSearch = require('streamsearch'),
mscdex / gist:c1a7199af2af9d3ceb1c
Created Jun 3, 2014
transfer a directory over ssh with node.js/ssh2
View gist:c1a7199af2af9d3ceb1c
var tar = require('tar-fs');
var zlib = require('zlib');
function transferDir(conn, remotePath, localPath, compression, cb) {
var cmd = 'tar cf - "' + remotePath + '" 2>/dev/null';
if (typeof compression === 'function')
cb = compression;
else if (compression === true)
compression = 6;
mscdex / test.js
Last active Apr 30, 2020
sharing sessions between node.js and php using redis
View test.js
var express = require('express'),
app = express(),
cookieParser = require('cookie-parser'),
session = require('express-session'),
RedisStore = require('connect-redis')(session);
app.use(express.static(__dirname + '/public'));
app.use(function(req, res, next) {
if (~req.url.indexOf('favicon'))
return res.send(404);
mscdex / gist:de646d2bf676c23014ce
Last active Aug 29, 2015
Monkey patches Express's res.render() to support a layout
View gist:de646d2bf676c23014ce
Set a global/default layout with:
app.set('view layout', 'foo');
Set a layout per-render (overrides global layout) with:
res.render('foo', { layout: 'bar' });
Or disable a layout if a global layout is set with:
res.render('foo', { layout: false });
If no layout is provided using either of the above methods,
then the view will be rendered as-is like normal.
You can’t perform that action at this time.