Skip to content

Instantly share code, notes, and snippets.

@dcapwell
dcapwell / jvm.monitor
Last active June 22, 2020 23:47
Java JVM monitor
# https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html
# eden (free), old (free), young GC time, # full GC, full GC time, total GC time
jstat -gc -h10 $(jps -m | grep <process name here> | awk '{print $1}') 1000 0 | awk '/^[0-9]/ {printf "%-10s %-10s %-10s %-10s %-10s %-10s\n", int((100*$6)/$5), int((100*$8)/$7), $(NF-3), $(NF-2), $(NF-1), $NF}'
# OR
pid=42
jstat -gc -h10 $pid 1000 0 | awk '/^ [0-9]/ {printf "%-10s %-10s %-10s %-10s %-10s %-10s\n", int((100*$6)/$5), int((100*$8)/$7), $(NF-3), $(NF-2), $(NF-1), $NF}'
#!/usr/bin/env bash
#set -o xtrace
set -o errexit
set -o pipefail
set -o nounset
bin="$(cd "$(dirname "$0")" > /dev/null; pwd)"
longrunning() {
@dcapwell
dcapwell / use.sh
Last active January 12, 2018 02:23
Usage, Saturation, Errors checklist script
#!/usr/bin/env bash
##
## Script is a automation for collecting metrics that represent (U)sage, (S)aturation, and (E)rrors (USE).
## This script is mostly automating [1], so more details can be found there
##
## References
## * [1] http://www.brendangregg.com/USEmethod/use-linux.html
##
@dcapwell
dcapwell / git-remove.sh
Created October 23, 2017 23:21
Git remove file from history
git filter-branch --index-filter 'git update-index --remove path/to/file/in/git'
// pre-create nodes so its easier to link them together
// add n to first nodes just to make the loop simple
Node[] nodes = new Node[targetLevel + 1];
nodes[0] = n;
for (int i = 1; i <= targetLevel; i++)
nodes[i] = new Node(value, null, nodes[i - 1]);
Classfile /home/dcapwell/src/github/prototypes/kotlin-collections/build/kotlin-classes/main/com/github/dcapwell/kotlin/collections/ConsList$size$1.class
Last modified Sep 17, 2016; size 1976 bytes
MD5 checksum fe97807c3d0ade285d2790eb907e3b39
Compiled from "ConsList.kt"
final class com.github.dcapwell.kotlin.collections.ConsList$size$1 extends kotlin.jvm.internal.Lambda implements kotlin.jvm.functions.Function2<com.github.dcapwell.kotlin.collections.ConsList<A>, java.lang.Integer, java.lang.Integer>
minor version: 0
major version: 50
flags: ACC_FINAL, ACC_SUPER
Constant pool:
#1 = Utf8 com/github/dcapwell/kotlin/collections/ConsList$size$1
//fun <A> nil(): ConsList<A> {
// return ConsList.Nil<A>
//}
sealed class ConsList<A> : Iterable<A> {
fun cons(value: A): ConsList<A> {
return Cons(value, this);
}
module Tracker where
---- MODEL ----
type alias Dashboard =
{ name : String
, active : Bucket
, pending : Bucket
, icebox : Bucket }
@dcapwell
dcapwell / ScalaHibernate
Last active January 1, 2016 20:49
Dropwizard + Scala + JDBI + Validation
/**
* Removes boilerplate when working with Hibernate. History behind this:
*
* In scala, if you add an annotation to a var or case class param, it will put it on the field/getter/and setter.
*
* Many java annotations frameworks work with field OR getter/setter, but don't allow both
*
* Hibernate is an example of this. Some annotations are expected on fields but not methods, and vica-versa
*/
object ScalaHibernate {
@dcapwell
dcapwell / init.pp
Last active December 30, 2015 02:09
centos64-2 : Error: Could not apply complete catalog: Found 1 dependency cycle:
centos64-2 : (Exec[wget zookeeper-3.4.5.tar.gz] => Exec[zookeeper_untar] => File[zookeeper-reown-build] => File[/opt/apache/zookeeper/zookeeper-current] => Class[Zookeeper::Setup_envo] => Class[Zookeeper::Install] => Exec[wget zookeeper-3.4.5.tar.gz])
centos64-2 : Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz