Skip to content

Instantly share code, notes, and snippets.

@cobratbq
cobratbq / openpgp.md
Created July 22, 2023 19:51
Keyoxide/Ariadne proof

openpgp4fpr:341C10EB7FD6648F30AFBC32D049DB6CD0B0C436

@cobratbq
cobratbq / dnscrypt-proxy.service.hardened
Last active April 7, 2022 20:13
dnscrypt-proxy.service file (hardened, requiring systemd-sockets)
[Unit]
Description=DNSCrypt client proxy
Documentation=https://github.com/DNSCrypt/dnscrypt-proxy/wiki
Requires=dnscrypt-proxy.socket
After=network.target
Before=nss-lookup.target
Wants=nss-lookup.target
[Install]
Also=dnscrypt-proxy.socket
@cobratbq
cobratbq / keybase.md
Created November 26, 2019 20:47
Keybase.io proof of ownership

Keybase proof

I hereby claim:

  • I am cobratbq on github.
  • I am dannyvanheumen (https://keybase.io/dannyvanheumen) on keybase.
  • I have a public key whose fingerprint is 341C 10EB 7FD6 648F 30AF BC32 D049 DB6C D0B0 C436

To claim this, I am signing this object:

@cobratbq
cobratbq / Test.java
Created April 29, 2016 19:55
More flexible implementation of summing-method
public class Test {
public static void main(String[] args) {
final ArrayList<Double> list = new ArrayList<>();
list.add(1.3);
list.add(1.4);
list.add(1.7);
list.add(2.3);
flexibleSum(list);
}
@cobratbq
cobratbq / Test.java
Created April 29, 2016 19:53
Naive implementation of summing-method
public class Test {
public static void main(String[] args) {
final ArrayList<Double> list = new ArrayList<>();
list.add(1.3);
list.add(1.4);
list.add(1.7);
list.add(2.3);
naiveSum(list);
}
@cobratbq
cobratbq / Representable.java
Last active March 23, 2016 22:28
Example of default method in Java.
public interface Representable {
String representation();
default String reverse() {
final StringBuilder builder = new StringBuilder(this.representation());
return builder.reverse().toString();
}
}
@cobratbq
cobratbq / CollectionUtils.java
Created March 23, 2016 22:27
An example of a utility method that uses short-cuts for known types.
public class CollectionUtils {
public static <E extends Object> E getLast(final Collection<E> col) {
if (col.isEmpty()) {
throw new IllegalArgumentException("cannot retrieve last element from empty collection");
}
if (col instanceof LinkedList) {
return ((LinkedList<E>) col).getLast();
} else if (col instanceof List) {
return ((List<E>) col).get(col.size() - 1);
@cobratbq
cobratbq / ExpectationsExample.java
Last active December 21, 2015 14:26
Example 3: Third component using expectations
package thirdcomponent;
import java.math.BigDecimal;
import java.math.MathContext;
public class ExpectationsExample {
public static void main(String[] args) {
final BigDecimal one = BigDecimal.ONE;
final BigDecimal three = BigDecimal.valueOf(3L);
@cobratbq
cobratbq / UtilWithStatics.java
Last active December 21, 2015 14:23
Example 2: Object with statically defined requirement
package thirdcomponent;
import java.math.BigDecimal;
import java.math.MathContext;
public class UtilWithStatics {
// Predefined math context for use in calculation.
private final static MathContext C = MathContext.DECIMAL32;
@cobratbq
cobratbq / UtilNoState.java
Created December 21, 2015 14:21
Example 1: Util without state
package thirdcomponent;
import java.math.BigDecimal;
import java.math.MathContext;
public class UtilNoState {
public static void main(String[] args) {
System.out.println(calculate(BigDecimal.ONE,
BigDecimal.valueOf(3L), MathContext.DECIMAL32));