Skip to content

Instantly share code, notes, and snippets.

@zakki
zakki / gist:3174911
Created July 25, 2012 07:25
drawString & AffineTransform
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.applet.*;
public class Text extends Applet {
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
AffineTransform affine = new AffineTransform();
g2.setColor(Color.BLACK);
@zakki
zakki / gist:3377337
Created August 17, 2012 09:19
js_of_ocaml ReferenceError?
let _ =
for i = 0 to 6 do
let result = try Some (List.find (fun s -> s = 1049) [1; 2; 5]) with Not_found -> None in
result
done
let window = Dom_html.window;;
let foo i =
let result = try Some (List.find (fun s -> s = i) [0; 1; 5]) with Not_found -> None in
match result with
Some(n) -> window##alert(Js.string (Printf.sprintf "foo Some(%d)" n))
| None -> window##alert(Js.string "foo None");;
for i = 0 to 3 do
foo i
@zakki
zakki / debug_info.diff
Created September 5, 2012 10:06
js_of_ocaml debug info
diff -rN -u old-js_of_ocaml/compiler/driver.ml new-js_of_ocaml/compiler/driver.ml
--- old-js_of_ocaml/compiler/driver.ml 2012-09-05 19:02:07.000000000 +0900
+++ new-js_of_ocaml/compiler/driver.ml 2012-09-05 19:02:07.000000000 +0900
@@ -20,7 +20,7 @@
let debug = Util.debug "main"
-let f ?standalone p =
+let f ?standalone (p, d) =
if debug () then Code.print_program (fun _ _ -> "") p;
let _ =
<?php
for ($i = 1; $i <= 100; $i++) {
if ($i % 3 == 0) {
?>
print_string "Fizz";
<?php
}
if ($i % 5 == 0) {
?>
open Batteries_uni
let (>>=) = Lwt.bind
let http_get url =
Printf.printf "sleep\n";
Lwt_unix.sleep 2.0 >>= (fun () ->
Printf.printf "wake up\n";
Lwt.return ("data '" ^ url ^ ""));;
///<reference path='..\typescript\src\harness\harness.ts'/>
///<reference path='..\typescript\src\harness\baselining.ts'/>
///<reference path='..\typescript\src\harness\external\json2.ts'/>
///<reference path='..\typescript\src\compiler\optionsParser.ts'/>
class Dumper {
constructor (public ioHost: IIO) {
}
@zakki
zakki / AO.h
Created November 9, 2012 09:30
j2objc aobench
//
// Generated by the J2ObjC translator. DO NOT EDIT!
// source: AO.java
//
// Created by mac on 12/11/09.
//
@class IOSIntArray;
@class IOSObjectArray;
@class Intersection;
(defun fix-ocaml-cursor-position (byte-pos)
(let ((len (lambda (p)
(length (encode-coding-string
(buffer-substring 1 p) buffer-file-coding-system)))))
(let* ((pos (/ byte-pos 4))
(b (funcall len pos)))
(while (< b (- byte-pos 1))
(setq pos (+ pos 1))
(setq b (funcall len pos)))
pos)))
@zakki
zakki / gist:5531852
Last active December 17, 2015 01:58
module and localvariable
module a{
export module b{
export var hoge;
export function f() {
hoge = 0;
var b = 0;
return b;
}
}
}