Skip to content

Instantly share code, notes, and snippets.

@rednaxelafx
rednaxelafx / PrintThreadIds.java
Created February 25, 2011 10:31
find out the correspondence between the tid/nid of Java threads as shown from jstack/JMX, on HotSpot/Linux
package fx.jvm.hotspot.tools;
import java.util.List;
import sun.jvm.hotspot.tools.Tool;
public class PrintThreadIds extends Tool {
public static void main(String[] args) {
PrintThreadIds tool = new PrintThreadIds();
tool.start(args);
package my.elasticsearch;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@katta
katta / gitdiff-svnpatch.sh
Created June 16, 2011 08:10
Converts git diff to svn patch format
git diff --no-prefix | sed -e "s/^diff --git [^[:space:]]*/Index:/" -e "s/^index.*/===================================================================/" --ignore-space-at-eol > changes.patch
@ebruchez
ebruchez / gist:1222695
Created September 16, 2011 17:55
Example of Scala continuations used with asynchronous programming
scala -P:continuations:enable
// Simulate a callback handled by the "system"
var myCallback: Int => Unit = null
// Simulate a non-blocking system read function. It returns directly after registering the callback.
def read(callback: Int => Unit): Unit = myCallback = callback
// First, without continuations, you must write things in a funny style, even with Scala's lightweight syntax.
// Note how each callback typically causes a new level of indentation.
@surjikal
surjikal / monitoring-stack-ubuntu-precise.md
Created May 23, 2012 21:18
Installing a complete monitoring stack on Ubuntu 12.04

Follow these steps to install Graphite on a fresh Ubuntu 12.04 instance. Make sure you read and understand the commands because by the time you read this, things could be outdated.

Graphite

Installing dependencies

# apt-get install libpq-dev
# apt-get install python-dev python-pip python-cairo python-psycopg2
# apt-get install python-django python-django-tagging
@jboner
jboner / latency.txt
Last active May 17, 2024 01:05
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@cbeams
cbeams / links.md
Last active January 28, 2019 18:02
Links from "Spring Framework 3.2 – Themes and Trends" webinar on January 16th, 2013
@fclairamb
fclairamb / log4j2.rolling.xml
Last active April 6, 2023 16:45
log4j2.xml sample setup files: * rolling: To enable rolling logging. * setup file to log on file (rotation should be handled by logrote), syslog (to collect all the logs from the different services) and console...
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<properties>
<property name="name">app</property>
<property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5.5p | %-10.10t | %-20.20C:%-5.5L | %msg%n</property>
<!--
It will look like that:
2013-04-03 07:37:51.993 | WARN | main | lnetgateway.Server:56 | My app is logging stuff
-->
</properties>
@aslakknutsen
aslakknutsen / Asciidoctor.py
Last active December 16, 2015 04:19
Sublime AsciiDoctor Plugin
import re
import sublime
import sublime_plugin
import webbrowser
REG_RENAME = re.compile("\.(asciidoc|adoc|asc|ad)$")
EXT = re.compile(".*\.(asciidoc|adoc|asc|ad)$")
COMMAND = "asciidoctor -b html5"
@mattn
mattn / upload.go
Last active August 3, 2021 05:26
package main
import (
"crypto/sha1"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
"path/filepath"