Skip to content

Instantly share code, notes, and snippets.

View 19h's full-sized avatar
This is a verified account.

Kenan Sulayman 19h

This is a verified account.
View GitHub Profile
@19h
19h / mtwister.js
Created July 19, 2013 12:10
Mersenne Twister
/*
__ ___
/\ \ __ /'___\
\ \ \ __ __ /\_\/\ \__/ __ __
\ \ \ __ /'__`\ /'_ `\/\ \ \ ,__\/\ \/\ \
\ \ \L\ \/\ __//\ \L\ \ \ \ \ \_/\ \ \_\ \
\ \____/\ \____\ \____ \ \_\ \_\ \/`____ \
\/___/ \/____/\/___L\ \/_/\/_/ `/___/> \
/\____/ /\___/
\_/__/ \/__/
@19h
19h / NDLevenshtein.js
Last active December 20, 2015 00:19
Normalized Damerau–Levenshtein-Distance for String Comparision
/*
__ ___
/\ \ __ /'___\
\ \ \ __ __ /\_\/\ \__/ __ __
\ \ \ __ /'__`\ /'_ `\/\ \ \ ,__\/\ \/\ \
\ \ \L\ \/\ __//\ \L\ \ \ \ \ \_/\ \ \_\ \
\ \____/\ \____\ \____ \ \_\ \_\ \/`____ \
\/___/ \/____/\/___L\ \/_/\/_/ `/___/> \
/\____/ /\___/
\_/__/ \/__/
@19h
19h / duplifinder.js
Last active December 20, 2015 01:09
Spotify-Duplifinder based on idea of thoseannoyingdupes.com (Node/V8). Fully working web-server.
var http = require("http"), https = require("https");
var commands = {
"mono": function ( args, response ) {
var r = args[0];
return https.get("https://embed.spotify.com/?uri=" + r, function(res) {
var data = ""; res.on("data", function (v) { data += v; })
res.on("end", function () {
var v = data
.split('<ul id="content" class="content">')[1]
@19h
19h / package.json
Last active December 20, 2015 11:18
Legify GSP BizInz. Google Site-Relation Reflection Toolkit. Outputs Mathematica Code. Example: http://data.sly.mn/QZQ3. (depth=3).
{
"name": "GSPBizInt",
"version": "0.0.1",
"author": "Legify",
"description": "Legify GSP BizInz.",
"contributors": [
{ "name": "Kenan Sulayman", "email": "kenan@legify.com" }
],
"bin": {
"GSPBizInt": "./pull.js"
@19h
19h / readDictionary.js
Last active December 20, 2015 20:08 — forked from AndrewRayCode/gist:825583
Recursive directory walker / indexer / lister with array, object-stat hashmap and joint-mode support. For V8/Node.js, in Javascript.
/*
__ ___
/\ \ __ /'___\
\ \ \ __ __ /\_\/\ \__/ __ __
\ \ \ __ /'__`\ /'_ `\/\ \ \ ,__\/\ \/\ \
\ \ \L\ \/\ __//\ \L\ \ \ \ \ \_/\ \ \_\ \
\ \____/\ \____\ \____ \ \_\ \_\ \/`____ \
\/___/ \/____/\/___L\ \/_/\/_/ `/___/> \
/\____/ /\___/
\_/__/ \/__/
@19h
19h / apstatic.js
Last active December 20, 2015 21:09
Sophisticated static server with inline stream caching (does only read the disk once!), security sanity and only-once check for existence.
#!/usr/local/bin/node
// Server, see https://gist.github.com/KenanSulayman/6195554
// readDirectory.js, see https://gist.github.com/KenanSulayman/6187951
/*
__ ___
/\ \ __ /'___\
\ \ \ __ __ /\_\/\ \__/ __ __
\ \ \ __ /'__`\ /'_ `\/\ \ \ ,__\/\ \/\ \
@19h
19h / nname.js
Last active December 22, 2015 20:09
Implicit number naming
var nname = function (n) {
var e = ((n/10) - ~~(n/10)) * 10;
e = ( e - ~~e ) < .5 && ~~e || ( ~~e + 1 );
return n + (e === 1 && "st" || e === 2 && "nd" || e === 3 && "rd" || "th");
}
@19h
19h / http.js
Last active December 29, 2015 05:19
Saturday-Evening-Hack: a dump HTTP server on plain TCP sockets. Beware turning off file caching will crash your server when the OS runs out of file descriptors.
var net = require("net");
var fs = require("fs");
// turns off file caching
var isFileServer = true;
var nop = new Function;
var http_ref = {
100: "Continue",
@19h
19h / pairingfunction.js
Last active November 12, 2018 20:08
Pairing Function for Javascript. Combines two numbers into one; used for compression of analytics data where two coordinates of mouse-clicks are combined into a single integer.
var pair = function (x, y) {
return x << 16 & 0xffff0000 | y & 0x0000ffff;
};
var depair = function (p) {
return [p >> 16 & 0xFFFF, p & 0xFFFF]
};
@19h
19h / presenterr800.js
Last active December 30, 2015 05:09
Logitech Presenter r800 — API implementation on top of node-hid.
// controller code
var HID = require('node-hid');
var nop = new Function;
var lru, op = {
0x4E: nop,
0x4B: nop,
0x3E: nop,
0x37: nop,