Skip to content

Instantly share code, notes, and snippets.

@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
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 {
/**
* 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.
*
@ytoshima
ytoshima / DBLEx.scala
Created June 17, 2013 02:56
Berkley-DB Java Edition examples in scala...
package persist.gettingStarted
import com.sleepycat.persist.model.{Entity, PrimaryKey, SecondaryKey}
import com.sleepycat.persist.model.Relationship._
@Entity
class Vendor {
var address: String = _
var bizPhoneNumber: String = _
var city: String = _
@ytoshima
ytoshima / trapex.c
Created May 31, 2013 01:10
A simple program to verify si_code=128 behaviour .
/* Simple test program to verify si_code=SI_KERNEL(128) for address
* above TASK_SIZE64 or TASK_SIZE_MAX (0x800000000000 - 4096 = 0x7ffffffff000)
* See do_page_fault(k).
*/
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
@ytoshima
ytoshima / build.bat
Created March 23, 2013 05:04
ps like command for windows
cl /Zi -D_UNICODE ps2.cpp Psapi.lib
@ytoshima
ytoshima / ck-runtime.c
Created February 21, 2013 09:18
Check whether the specified command line completed in the specified duration in seconds.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <signal.h>
#include <string.h>
@ytoshima
ytoshima / gist:4747954
Created February 10, 2013 01:46
A simple script to show screen resolution
#!/bin/sh
exec ~/local/scala-2.10.0/bin/scala "$0" "$@"
!#
val ge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment
val mode = ge.getDefaultScreenDevice.getDisplayMode
println("%dx%d".format(mode.getWidth, mode.getHeight))
@ytoshima
ytoshima / StackUse.scala
Last active October 7, 2015 03:18
Print process' stack use on modern Linux
/**
* Print thread stack use for each thread.
* This is for linux which has /proc/<pid>/smaps and /proc/<pid>/task/<tid>/stat.
*/
object StackUse extends App {
import scala.util.control.Exception._
import scala.io.Source
import java.io.File
/**
* Parse (pid, task stat string) tuple and returns (pid, sp) tuple.
@ytoshima
ytoshima / cpumem.cpp
Created May 23, 2012 09:05
Simple stress program
/*
* A small cpu and memory stress program
* compile: CC cpumem.cpp -o cpumem -lpthread
* or: make LDFLAGS=-lpthread cpumem
*/
#include <pthread.h>
#include <iostream>
#include <vector>
#include <sys/types.h>
#include <assert.h>