Skip to content

Instantly share code, notes, and snippets.

@ytoshima
ytoshima / baobab-unable-to-parse-option-err.md
Created July 8, 2024 04:58
Workaround for baobab error CRITICAL **: Unable to parse option: Cannot open display

If I run baobab after sudo su -, I see following message on the terminal and baobab does not run.

** (baobab:4596): CRITICAL **: Unable to parse option: Cannot open display:

DISPLAY is set to something like ":1" or "localhost:1". I also tried --display= option, but it didn't help.

But If I run xhost + in gnome in the terminal as a user before doing su, the error is not shown and baobab worked without proboem.

@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