This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fixed length password finder from salted-hash | |
// with standard `cluster` module | |
var cluster = require("cluster"); | |
// `cluster.isMaster` as the only master process, otherwise worker process | |
if (cluster.isMaster) { | |
var spec = { | |
alg: "md5", | |
enc: "hex", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="mahjong-calc.js"></script> | |
</head> | |
<body> | |
<h1>Mahjong Calc</h1> | |
<div> | |
Han: <input id="han" type="number" value="3" min="1" max="55" step="1" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// S/Key style One-time Password system | |
var crypto = require("crypto"); | |
// [functions for OTP system] | |
// generate server info of one time password | |
var initAccount = function (passphrase) { | |
var alg = "sha256"; | |
var enc = "hex"; | |
var times = 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paxos network consensus protocols | |
// Promise of ECMAScript6 used. | |
// Promise utilities | |
var Utils = { | |
moreThanHalf: function (promises) { | |
return new Promise(function (fulfill, reject) { | |
var success = 0; | |
var failure = 0; | |
var half = (promises.length / 2)|0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>screen capture on chrome</title> | |
<script> | |
(navigator.getUserMedia || navigator.webkitGetUserMedia).bind(navigator)({ | |
video: { | |
mandatory: { | |
chromeMediaSource: "screen" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"); | |
// see: http://tools.ietf.org/html/rfc7238 | |
if (!http.STATUS_CODES["308"]) http.STATUS_CODES["308"] = "Permanent Redirect"; | |
var server = http.createServer(function (req, res) { | |
if (req.url === "/redirect") { | |
var uri = "http://" + req.headers["host"] + "/result"; | |
res.statusCode = 308; | |
res.setHeader("Location", uri); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fizzbuzz on rust 0.11 | |
// rustc fizzbuzz.rs | |
// ./fizzbuzz | |
fn main() { | |
for i in range(1u, 101) { | |
// xxx! denotes xxx is defined as macro | |
println!("{}", fizzbuzz(i)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func fizzbuzz(n int) string { | |
switch f, b := n % 5 == 0, n % 3 == 0; { | |
case f && b: return "FizzBuzz" | |
case f: return "Fizz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [ES5][nodejs] g()()()()('al') -> "gooooal" | |
// see: https://github.com/eatnumber1/goal | |
var g = function g(al) { | |
"use strict"; | |
var go = this ? this : "g"; | |
return al ? go + al: g.bind(go + "o"); | |
}; | |
console.log(g('al')); // => "gal" | |
console.log(g()('al')); // => "goal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script> | |
window.addEventListener("load", function () { | |
"use strict"; | |
var canvas = document.createElement("canvas"); | |
document.body.appendChild(canvas); |
OlderNewer