Skip to content

Instantly share code, notes, and snippets.

@klshxsh
klshxsh / .psqlrc
Created February 14, 2020 14:45
postgres psqlrc file for pretty-printed output
# Copied from https://www.citusdata.com/blog/2019/07/17/postgres-tips-for-average-and-power-user/
\timing on
\pset linestyle unicode
\pset border 2
\setenv PAGER 'pspg --no-mouse -bX --no-commandbar --no-topbar'
\set HISTSIZE 100000
@klshxsh
klshxsh / H2DatabaseTest.java
Last active February 20, 2018 17:01
Start h2 server; connect to DB; load schema file before each test; drop schema after each test
package klshxsh;
/*
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
<scope>test</scope>
</dependency>
*/
@klshxsh
klshxsh / ParseXML.java
Created February 2, 2018 14:07
Parse an XML string, returning an org.w3c.dom.Element
/*
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
*/
private Element parseXML(String xml) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
@klshxsh
klshxsh / Compile mtail .md
Created August 19, 2016 11:03
Compiling mtail in a docker container and then running it locally

Assume that you've cloned mtail into /space/gitrepos/github/mtail Start up the container:

docker run --rm -it -v /space/gitrepos/github/mtail:/go/src/github.com/google/mtail golang bash

Then compile inside the container:

@klshxsh
klshxsh / CertTest.java
Created September 16, 2015 10:19
Debugging java ssl cert
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.InputStream;
import java.io.IOException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertPath;
import java.security.cert.Certificate;
import javax.net.ssl.HttpsURLConnection;
@klshxsh
klshxsh / Create an RPM-based chroot on an ubuntu host .md
Last active November 29, 2023 16:07
Create an RPM-based chroot on an ubuntu host - one very simply command - rinse
$ sudo apt-get install schroot rinse

The preconfigured setups are in /etc/rinse/rinse.conf:

$ grep "\[" /etc/rinse/rinse.conf
[rhel-5]
[centos-4]

Compile as follows:

$ make
gcc -g -o mythreads -pthread threads.c

See below for the source files and an example session in gdb.

Use ps -eLf | grep mythreads to see the threads.