This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prints address map with gap size between segment | |
* within a core file. This program uses readelf | |
* command and expects the output is same as the | |
* readelf on Linux. | |
*/ | |
object CoreAmap { | |
def main(args: Array[String]) { | |
for (a <- args) doAmapCore(a) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object PmapFilter { | |
case class Mr(start: Long, end: Long, desc: String) { | |
override def toString = | |
"%08x-%08x %6dk %s".format(start, end, (end-start)/1024, desc) | |
} | |
def process(path: String) : String = { | |
import scala.io.Source | |
def procMr(current: Mr, prevEnd: Long) = prevEnd match { | |
case 0 => current.toString | |
case x if prevEnd == current.start => current.toString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collection.JavaConversions._ | |
import java.lang.management._ | |
val MB = (1024*1024).toFloat | |
def b2mb(bval: Long): Float = bval / MB | |
def mpoolSum(mp: MemoryPoolMXBean) = "%s: use %.2f comm %.2f max %.2f".format(mp.getName, b2mb(mp.getUsage.getUsed), b2mb(mp.getUsage.getCommitted), b2mb(mp.getUsage.getMax)) | |
def minfo = ManagementFactory.getMemoryPoolMXBeans.filter(_.getType == MemoryType.HEAP).map(mpoolSum).mkString("\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cl /Zi -D_UNICODE ps2.cpp Psapi.lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = _ |