Skip to content

Instantly share code, notes, and snippets.

@garethahealy
garethahealy / jcmd.sh
Created January 5, 2017 18:03
java heapdump for docker
#!/bin/bash
docker exec $1 ps -deaf
echo -n "PID for Java: "
read pid
docker exec $1 jcmd $pid GC.heap_dump /tmp/docker.hprof
docker cp $1:/tmp/docker.hprof .
docker exec $1 rm /tmp/docker.hprof
@achmadns
achmadns / activate-rabbitmqadmin.sh
Created March 7, 2016 07:26
Activate rabbitmqadmin
#/bin/bash
# these action should be run with sudo level
# activate management plugin first
rabbitmq-plugins enable rabbitmq_management
# restart the rabbitmq-server
service rabbitmq-server restart
# download the rabbitmqadmin script locally
@pcan
pcan / SelfExpiringHashMap.java
Last active July 4, 2024 23:51
SelfExpiringHashMap - a Java Map which entries expire automatically after a given time; it uses a DelayQueue internally.
/*
* Copyright (c) 2019 Pierantonio Cangianiello
*
* MIT License
*
* 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
@yangzhe1991
yangzhe1991 / example.java
Created April 10, 2014 06:50
example code of QueryBuilder in Cassandra Java driver
Session session = getSession();
//update
Statement exampleQuery = QueryBuilder.update("keyspace","table").with(QueryBuilder.set("height", 180))
.and(QueryBuilder.set("width", 300)).where(QueryBuilder.eq("id", 5145924587302797538L));
session.execute(exampleQuery);
//insert
exampleQuery= QueryBuilder.insertInto("keyspace","table").value("id",12245L)
.value("data",ByteBuffer.wrap(new byte[]{0x11})).ifNotExists();
@uklimaschewski
uklimaschewski / UnescapeJavaString
Created September 28, 2013 12:50
Unescapes a string that contains standard Java escape sequences: - \b \f \n \r \t \" \' : BS, FF, NL, CR, TAB, single and double quote - \X \XX \XXX : Octal character from 0 to 377 (that is in Hex: 0x00 to 0xFF) - \uXXXX : Hexadecimal based Unicode character
/**
* Unescapes a string that contains standard Java escape sequences.
* <ul>
* <li><strong>&#92;b &#92;f &#92;n &#92;r &#92;t &#92;" &#92;'</strong> :
* BS, FF, NL, CR, TAB, double and single quote.</li>
* <li><strong>&#92;X &#92;XX &#92;XXX</strong> : Octal character
* specification (0 - 377, 0x00 - 0xFF).</li>
* <li><strong>&#92;uXXXX</strong> : Hexadecimal based Unicode character.</li>
* </ul>