Skip to content

Instantly share code, notes, and snippets.


@zakki
zakki / read.js
Created December 27, 2016 09:30
emscripten readFile
var buf = FS.readFile('/foo/bar');
var blob = new Blob([buf], {"type" : "application/octet-stream" });
var url = URL.createObjectURL(blob);
$('#result').attr("href", url);
import java.awt.*;
import java.applet.*;
public class MyApplet extends Applet {
public void paint(Graphics g) {
g.drawString("A Simple Applet",0,10);
int b = 0, applet = 0;
String code;
int width;
boolean height;
@zakki
zakki / spiretest.scala
Created August 6, 2016 06:42
spire toDouble
(r"6120758542842770990422519315113/12241517085685542430359819778729").toDouble
(r"6120758542842771439937300463616/12241517085685542430359819778729").toDouble
class A {
static String S = "a:" + B.S;
}
class B {
static String S = A.S;
}
class Test {
public static void main(String[] args) {
if (Math.random() > 0.5) {
import java.util.Random;
import org.eclipse.collections.api.map.primitive.MutableIntIntMap;
import org.eclipse.collections.impl.factory.primitive.IntIntMaps;
public class Main {
public static void time(String name, Runnable f) {
long s = System.nanoTime();
$ time node fib.asm.js
102334155
node fib.asm.js 0.00s user 0.01s system 0% cpu 1.723 total
$ time node fib.js
102334155
node fib.js 0.00s user 0.01s system 0% cpu 2.025 total
$ cat fib.asm.js
@zakki
zakki / jetzt-solid.js
Created October 28, 2015 08:59
jetzt + TinySegmenter
/*! jetzt 2015-10-28
* https://ds300.github.io/jetzt/
* Copyright (c) 2015 David Sheldrick and contributors; Licensed Apache 2.0 */
// TinySegmenter 0.1 -- Super compact Japanese tokenizer in Javascript
// (c) 2008 Taku Kudo <taku@chasen.org>
// TinySegmenter is freely distributable under the terms of a new BSD licence.
// For details, see http://chasen.org/~taku/software/TinySegmenter/LICENCE.txt
module.exports = function(grunt) {
// require("time-grunt")(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
opt: {
client: {
"tsMain": "src",
"tsMainLib": "typings",
//http://codemonkeyism.com/how-to-improve-programming-with-interfaces/
case class Person(n:String) { def name():String = n }
type Nameable = { def name():String }
def printName(n:Nameable) { println(n.name) }
printName(new Person("Codemonkey"))