Skip to content

Instantly share code, notes, and snippets.

@mping
mping / page.html
Created October 14, 2010 14:37
xhtmlrenderer (Flying Saucer) with css3 header/footer
<link href="print.css" rel="stylesheet" type="text/css" media="screen,print"/>
...
<div style="-fs-page-sequence: start; page-break-before: always">
<div style="position: running(current);">
<div id="page-header" class="small">
<span class="align-left">some stuff here</span>
<span class="align-right">some other stuff here</span>
<div class="line">&#160;</div>
@mping
mping / B64ImgReplacedElementFactory.java
Created April 12, 2011 11:21
Enables Flying Saucer (xhtmlrendered java lib) to process <img> tags with b64 data
import java.io.IOException;
import org.w3c.dom.Element;
import org.xhtmlrenderer.extend.FSImage;
import org.xhtmlrenderer.extend.ReplacedElement;
import org.xhtmlrenderer.extend.ReplacedElementFactory;
import org.xhtmlrenderer.extend.UserAgentCallback;
import org.xhtmlrenderer.layout.LayoutContext;
import org.xhtmlrenderer.pdf.ITextFSImage;
import org.xhtmlrenderer.pdf.ITextImageElement;
@mping
mping / ca-openssl.cnf
Last active September 25, 2023 15:34
Generate certificates for mTLS with subjectAltNames
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
[req_distinguished_name]
countryName = Country Name (2 letter code)
countryName_default = AU
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Some-State
organizationName = Organization Name (eg, company)
@mping
mping / ducky.md
Created September 19, 2023 10:59 — forked from schmich/ducky.md
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2 Skyline

To use media keys on the Ducky One 2 RGB TKL, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

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.

@mping
mping / object_define_property.js
Created June 24, 2015 17:00
Object.defineProperty and debugger
// Nice trick when you don't know where a change comes from
// rewrites a property, and sets a debugger when the property changes
console = console || {}; // just in case
console.watch = function(oObj, sProp) {
var sPrivateProp = "$_"+sProp+"_$"; // to minimize the name clash risk
oObj[sPrivateProp] = oObj[sProp];
// overwrite with accessor
@mping
mping / ducky.md
Created July 4, 2022 12:49 — forked from rizalgowandy/ducky.md
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2

To use media keys on the Ducky One 2, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

@mping
mping / README.md
Last active October 1, 2021 16:43
Certs
@mping
mping / example.sh
Created February 23, 2021 09:48
jvisualvm with logging
bin/jvisualvm --jdkhome /home/mping/.asdf/installs/java/adopt-openjdk-11.0.1+13 -J-Djava.util.logging.config.file=vvm.properties --openjmx localhost:10101
❯ cat /home/mping/Devel/visualvm_204/vvm.properties
handlers=java.util.logging.ConsoleHandler
.level=INFO
java.util.logging.ConsoleHandler.level=FINEST
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
javax.management.level=FINEST
javax.management.remote.level=FINEST
@mping
mping / either.clj
Created February 15, 2021 19:19 — forked from mping-exo/either.clj
(require '[clojure.spec.alpha :as s])
(s/def ::test (s/and (s/keys :req-un [(or ::key1 ::key2)])
(fn [{:keys [key1 key2]}]
(not (and key1 key2)))))
;; s/or validates some of the keys
;; the (fn..) ensures that both keys CANNOT be present