Skip to content

Instantly share code, notes, and snippets.

@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()
{
import java.io._
import collection.JavaConversions._
import java.util.jar.JarFile
import scala.concurrent._
import ExecutionContext.Implicits.global
import scala.util.{Success, Failure}
import scala.concurrent.duration._
case class MatchedEnt(path: String, names: List[String])
@ytoshima
ytoshima / mvts.py
Created January 16, 2015 22:15
mvts
#!/usr/bin/env python
def renamets(path):
import os, stat, time
ts = os.stat(path)[stat.ST_MTIME]
src = path
ext = time.strftime("%Y-%m-%d_%H%M%S", time.localtime(ts))
dst = src + "." + ext
@ytoshima
ytoshima / interp.dump.txt
Created October 22, 2011 01:06
A gdb macro which dumps java7 HotSpot JVM linux/32-bit interpreter codelets and an output
AbstractInterpreter::_code : StubQueue * = 0xb49150c0
_stub_buffer : 0xb6f7a6c0
_number_of_stubs: 0x103
Codelet @ 0xb6f7a6c0 128 -1 0xffffffff 0x10c81a1: "slow signature handler"
Dump of assembler code from 0xb6f7a6e0 to 0xb6f7a740:
0xb6f7a6e0: mov %esp,%ecx
0xb6f7a6e2: call 0xb6f7a6ec
0xb6f7a6e7: jmp 0xb6f7a73f
0xb6f7a6ec: push %ecx
0xb6f7a6ed: push %edi