Skip to content

Instantly share code, notes, and snippets.

@ytoshima
ytoshima / classloaders.js
Created February 17, 2016 02:59
OQL samples
//----------------- class looader and loaded classes
select map(heap.objects('java.lang.ClassLoader'), function (it) {
var res = '';
res += "<br/>ClassLoader " + toHtml(it) + "<br/>";
res += listLoadedClasses(it);
return res + "<br>";
function listLoadedClasses(cl) {
var res = "";
if (cl.classes != null) {
if (cl.classes.elementData != null) {
@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
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 / 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()
{
@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 / 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 / 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
#!/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 / 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
@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",