Skip to content

Instantly share code, notes, and snippets.

/**
* Small utility script to use JavaFX 2 from scala REPL
* To use ':l fxutil.scala' in REPL.
* Recent java7 JDK contains javafx runtime at $JAVA_HOME/jre/lib/jfxrt.jar
* Scala 2.9 takes -cp or CLASSPATH, so specify the jfxrt.jar path using
* either way.
* Scala 2.10 does not work in the same way. Its startup script passes
* -classpath "", thus -cp does not work. Instead, it has -toolcp option,
* so specify the jfxrt.jar using the option.
*
import java.io.InputStream;
import java.net.*;
// import java.util.concurrent.Phaser;
// Try mutex/condvar style.
// If it didn't work, try semaphore
// test for JDK-8006395
// Racey test, will not always fail, but if it does then we have a problem.
public class Race15 {
@ytoshima
ytoshima / initial-error-message
Created August 14, 2013 10:32
jdk8 b102 build error on OSX lion
/Users/yoshi/local/openjdk/jdk8-b102-hs25-b45/hotspot/src/os/bsd/vm/attachListener_bsd.cpp: In static member function ‘static void AttachListener::vm_start()’:
/Users/yoshi/local/openjdk/jdk8-b102-hs25-b45/hotspot/src/os/bsd/vm/attachListener_bsd.cpp:455: warning: ‘stat64’ is deprecated (declared at /usr/include/sys/stat.h:466)
/Users/yoshi/local/openjdk/jdk8-b102-hs25-b45/hotspot/src/os/bsd/vm/attachListener_bsd.cpp:455: warning: ‘stat64’ is deprecated (declared at /usr/include/sys/stat.h:466)
make[8]: *** [attachListener_bsd.o] Error 1
make[8]: *** Waiting for unfinished jobs....
make[7]: *** [the_vm] Error 2
make[6]: *** [product] Error 2
make[5]: *** [generic_build2] Error 2
make[4]: *** [product] Error 2
make[3]: *** [all_product_universal] Error 2
@ytoshima
ytoshima / First.scala
Created January 31, 2014 07:10
A simple jfreechart sample
import org.jfree.chart.ChartFactory
import org.jfree.chart.ChartFrame
import org.jfree.chart.JFreeChart
import org.jfree.data.general.DefaultPieDataset
object First extends App {
val data = new DefaultPieDataset
List(("Category 1", 43.2), ("Category 2", 27.9), ("Category 3", 79.5)).
foreach(e => data.setValue(e._1, e._2))
val chart = ChartFactory.createPieChart("Simple Pie Chart",
@ytoshima
ytoshima / FindJar.scala
Created February 21, 2014 14:38
FindJar
import java.io._
import collection.JavaConversions._
case class MatchedEnt(path: String, names: List[String])
class FindJar(path: String, patternStr: String) {
import scala.util.matching.Regex
val pattern = patternStr.r
#!/usr/bin/env python
#
# windows batch file example
# c:\Python27\python %UserProfile%\local\bin\mypg.py %*
#
import sys
import os.path
DEFAULT_CHAR = ':'
@ytoshima
ytoshima / ParamEx.java
Created April 23, 2014 08:54
JDK8 Parameter Names sample
/*
* JDK 8 javac has a new option -parameters.
* If this option was used, parameter name is stored in class file.
* The parameter name can be obtained via reflection. New class
* Parameter and a new method Method#getParameters() was added.
* $ ~/local/jdk1.8.0/bin/java ParamEx
* method: main
* param: java.lang.String[] arg0
* method: doit
* param: java.lang.String arg0
@ytoshima
ytoshima / Schedule.java
Created April 23, 2014 08:58
JDK8 Repeating Annotations sample
import java.lang.annotation.Target;
import java.lang.annotation.Repeatable;
import static java.lang.annotation.ElementType.*;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.*;
@Target(METHOD)
@Retention(RUNTIME)
@Repeatable(Schedules.class)
public @interface Schedule {
@ytoshima
ytoshima / dumpba.js
Created June 5, 2014 14:44
OQL snippets
/* dump big byte arrays in ascii */
select [ba, ba.length, String.fromCharCode.apply(String,
toArray(ba))] from [B ba where ba.length > 1000000
@ytoshima
ytoshima / fontsmoothing.cpp
Created June 26, 2014 07:24
Show or flip font smoothing setting using SystemParameterInfo API
/*
* shows font smoothing setting, which is true by default.
* flips font smoothing setting if "flip" was specified on command line.
* compilation: cl fontsmoothing.cpp user32.lib
*/
#include <windows.h>
#include <stdio.h>
BOOL fontSmoothingStatus()
{