Skip to content

Instantly share code, notes, and snippets.

@bellbind
bellbind / pure-iojs-features.js
Last active August 29, 2015 14:15
[iojs][es6]ES6 features in iojs-1.1.0
console.log("<<ES6 features in iojs default runtime>>");
console.log(process.versions);
(function letVariable() {
"use strict";
// "let" only allow in strict mode
var i = 0;
{
let i = 10;
console.log("[let]let i:", i);
@bellbind
bellbind / classes.js
Created February 10, 2015 05:50
[es6][iojs] ES6 class and its structure
// ES6 class and structure
// iojs --es_staging classes.js
"use strict";
class A {
constructor () {
this.a = true;
}
isSuper() {
@bellbind
bellbind / server-with-push.js
Last active August 29, 2015 14:15
[iojs][http2]HTTP/2 server with ECDSA cert
// $ npm install http2
// $ iojs server-with-push.js
// open "https://localhost:8080/" with FirefoxDeveloperEdition (37.0a2)
var fs = require("fs");
// openssl ecparam -genkey -name secp3841r1 -out ecdsa.key
// openssl req -new -key ecdsa.key -out ecdsa.req
// openssl req -x509 -key ecdsa.key -in ecdsa.req -out ecdsa.cer
var options = {
key: fs.readFileSync("./ecdsa.key"),
@bellbind
bellbind / example.js
Last active August 29, 2015 14:16
[es6][ecmascript][iojs]Tiny Implementation for ES6 Promise API
var TinyPromise = require("./promise");
//var TinyPromise = Promise;
// utilities
var wait = function (ms) {
return function waiting(v) {
return new TinyPromise(function (f, r) {setTimeout(f, ms, v);});
};
};
var timeout = function (ms) {
@bellbind
bellbind / Procfile
Last active August 29, 2015 14:16
[websocket][iojs]Basic Usage of raw W3C WebSocket API (with iojs server)
web: npm start
@bellbind
bellbind / index.html
Last active August 29, 2015 14:16
[html5][mediastream]getUserMedia
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>User Media</title>
<script src="script.js"></script>
</head>
<body>
<div id="camera"></div>
<div id="shot"></div>
@bellbind
bellbind / table-a4.js
Last active August 29, 2015 14:17
[iojs][python][sympy]Alternating Group(A4, A5) multiplication table (generator)
"use strict";
var A4 = {
E: [0,1,2,3], I: [1,0,3,2], J: [2,3,0,1], K: [3,2,1,0],
S: [2,0,1,3], T: [],U: [],V: [],
W: [1,2,0,3], X: [],Y: [],Z: [],
};
var mul = function(a, b) {
return [a[b[0]], a[b[1]], a[b[2]], a[b[3]]];
@bellbind
bellbind / HelloWorld.java
Last active August 29, 2015 14:17
[java8][javafx]HelloWorlds in javafx
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
public class HelloWorld extends Application {
@Override
public void start(Stage stage) throws Exception {
@bellbind
bellbind / Procfile
Last active August 29, 2015 14:17
[webcrypto][websocket][iojs] RSA crypted message chat
web: npm start
@bellbind
bellbind / Procfile
Last active August 29, 2015 14:18
[webcrypto][websocket][usermedia]captured photo sending with specified with pubkey
web: npm start