Skip to content

Instantly share code, notes, and snippets.

View Dgiffone's full-sized avatar

Domenico Giffone Dgiffone

View GitHub Profile
public class Cons<A> implements IList<A> {
/**
* リストの先頭要素
*/
private A x;
/**
* リストの残りの要素
*/
private IList<A> xs; // 型変数を忘れないように!
@szegedi
szegedi / memoryPoolsHotSpot
Created December 13, 2011 23:03
names of MemoryManagerMXBean and MemoryPoolMXBean instances in HotSpot JVM
Table of names of MemoryManagerMXBean and MemoryPoolMXBean instances under
different GC algorithms in Oracle HotSpot VM. Memory managers list the pools
they manage in square brackets; memory pools show their maximum sizes for -Xmx200M setting.
$ java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
SerialGC:
@bonifaido
bonifaido / oql_recipes.js
Last active January 21, 2022 08:00
VisualVM OQL Recipes
// The MIT License (MIT)
//
// Copyright (c) 2015 Nandor Kracser
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@jettro
jettro / ChatMessageInbound.java
Created July 14, 2013 17:38
This gist describes a web project that makes use of Tomcat features to create a WebSocket sample
package wsapp;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.WsOutbound;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
/**
@thaJeztah
thaJeztah / docker-examples.md
Last active January 14, 2024 02:00
Some docker examples

Commit, clone a container

To 'clone' a container, you'll have to make an image of that container first, you can do so by "committing" the container. Docker will (by default) pause all processes running in the container during commit to preserve data-consistency.

For example;

docker commit --message="Snapshot of my container" my_container my_container_snapshot:yymmdd
@apangin
apangin / HotSpot JVM intrinsics
Last active July 20, 2024 10:43
HotSpot JVM intrinsics
_hashCode java/lang/Object.hashCode()I
_getClass java/lang/Object.getClass()Ljava/lang/Class;
_clone java/lang/Object.clone()Ljava/lang/Object;
_dabs java/lang/Math.abs(D)D
_dsin java/lang/Math.sin(D)D
_dcos java/lang/Math.cos(D)D
_dtan java/lang/Math.tan(D)D
_datan2 java/lang/Math.atan2(DD)D
_dsqrt java/lang/Math.sqrt(D)D
_dlog java/lang/Math.log(D)D
@0x263b
0x263b / colors.md
Last active July 13, 2024 19:15
Random color from string in javascript

Random color from string in javascript

Consider a list of strings you need to permanently assign a random color.

First you should turn the string into a hash.

var string = "string"
var hash = 0
@mosheeshel
mosheeshel / ConsumeHeap.java
Last active August 28, 2023 12:20
Function to fill JVM/Java Heap, Java options to automatically create a Heapdump on that event and a companion script to upload resulting files to S3
import java.io.IOException;
import java.util.Vector;
/**
* Created by moshee
* on: 07/06/17
* to compile in place: `javac ConsumeHeap.java`
* Execute: `java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/app-`date +%s`-pid$$.hprof -XX:OnOutOfMemoryError=/opt/app/bin/upload_dump_s3.sh -Xmx2m ConsumeHeap`
* HeapDumpOnOutOfMemoryError specifies to automatically create a dump when OOM occures
* HeapDumpPath supplies a path to put that file

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@miguno
miguno / gist:548cd72eaec017c475448cb9b2ced258
Last active April 7, 2023 19:24
Taking Java JVM memory snapshots with gdb and jmap (for YourKit)

Notes

  • Good: very quick snapshotting even for large heap spaces (e.g. works if your JVM process would otherwise timeout and die)
  • Bad: such a memory snapshot contains significantly less useful information than YourKit's "enhanced" memory snapshots.

Usage

# 1. Find the relevant JVM pid on the target machine
$ ps ...