Skip to content

Instantly share code, notes, and snippets.

Document doc = new Document();
doc.setFile(url);
BufferredImage image = doc.getPageImage(pageNo,
GraphicsRenderingHints.PRINT,
Page.BOUNDARY_CROPBOX,
0f, // rotation
1.0f); // scale
RenderedImage r = image;
ImageIO.write(r, "png", file);
@chanwit
chanwit / ScoreHelper.bas
Created December 17, 2010 03:51
OpenOffice Macro to help scoring
REM ***** BASIC *****
sub Main
dim std_id as String
dim std_score as String
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
// Class
class Book {
static hasMany = [:authors => Author]
Author author
String name
String email
static constraints = {
@chanwit
chanwit / vm.go
Created January 31, 2011 15:41
JVM Classfile Parser written in Go lang
package main
import "fmt"
import "os"
import "io"
import "encoding/binary"
const (
ACC_PUBLIC = 0x0001
ACC_FINAL = 0x0010
//
// Actually, its filename is Test.gpp
//
class Test {
static class Expr<T> {
}
static class Bin<T> extends Expr<T> {
Expr<T> op1
@chanwit
chanwit / SomeNode.groovy
Created March 6, 2011 14:33
A Type-safe Monad that combines Node and List<Node> written in Groovy++
package org.korat.ast
class SomeNode {
List<Node> data
String getText() { data[0].text }
String getType() { data[0].type }
List<Node> getChild() { data[0].child }
#!/usr/bin/env gorun
package main
import "fmt"
func g() (a, b int) {
return 1,2
}
package main
import "fmt"
func sum(x []int) int {
s := 0
for _,i := range x {
s += i
}
return s
#!/usr/bin/env gonrun
package main
import "fmt"
type Cmd struct {
Text string
Key string
Data []byte
public static void g(char ch, boolean big) {
System.out.printf("g('%c',%s) = ", ch, big);
if (big == true) {
int d = ch - 'A';
for (int i = 0; i <= 25; i++) {
int k = (d + i) % 26;
System.out.printf("%c", 'A' + k);
}
System.out.println();
} else {