Skip to content

Instantly share code, notes, and snippets.

View devinrsmith's full-sized avatar

Devin Smith devinrsmith

  • Deephaven Data Labs
View GitHub Profile
@devinrsmith
devinrsmith / capn-proto-java.md
Created October 19, 2023 19:19
Cap'n Proto code generation and reflection for java

Cap’n Proto to Java

Note: this guide assumes Fedora, steps may be different for other OSes.

Install capnproto

sudo dnf install capnproto
#
# Copyright 2022 Deephaven Data Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
import sys
import jpyutil
jpy_properties = {
'jpy.pythonPrefix': sys.prefix,
'jpy.programName': sys.executable,
'jpy.pythonLib': jpyutil._find_python_dll_file(fail=True),
'jpy.jpyLib': jpyutil._get_module_path('jpy', fail=True),
'jpy.jdlLib': jpyutil._get_module_path('jdl', fail=True)
}
@devinrsmith
devinrsmith / r_place_uncontested_pixels.py
Last active April 9, 2022 19:23
Script to create r/place uncontested pixels
# https://deephaven.io
from deephaven import agg, parquet, empty_table, merge
# Everything pre-whiteout
# https://www.reddit.com/r/place/comments/tzboys/the_rplace_parquet_dataset/
place = parquet.read('2022_place_deephaven.parquet')\
.where("k<155926002")
# 2000 x 2000 grid
all_pixels = empty_table(2000).view(["x1=(short)i"])\
@devinrsmith
devinrsmith / BracketOrdering.java
Last active March 21, 2022 21:25
Optimal single-elimination bracket ordering
/*
* Copyright 2022 Deephaven Data Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

Keybase proof

I hereby claim:

  • I am devinrsmith on github.
  • I am thundza (https://keybase.io/thundza) on keybase.
  • I have a public key ASAlSaR_IWYFj5wrQStDmkdbokcE2XRud33tT8jBjO-npgo

To claim this, I am signing this object:

@devinrsmith
devinrsmith / DoubleCheckedSupplier.java
Last active June 29, 2020 03:45
Double Checked Locking made easy with Java 8 Suppliers
import java.util.function.Supplier;
/**
* Created by dsmith on 2/16/15.
*
* https://en.wikipedia.org/wiki/Double-checked_locking
*
*/
public class DoubleCheckedSupplier<T> implements Supplier<T> {
public static <T> Supplier<T> of(Supplier<T> supplier) {
@devinrsmith
devinrsmith / classgraph-benchmark-1.md
Last active November 6, 2019 01:30
classgraph-benchmark-1
$ ./build/install/classgraph-benchmark/invoke.sh
Running a classgraph benchmark focused on startup speed
For more information, see https://github.com/devinrsmith/classgraph-benchmark

classloader META-INF/maven/com.google.guava/guava/pom.xml 2 84a3ee12 17 56
real 0.10
user 0.13
sys 0.03
classgraph META-INF/maven/com.google.guava/guava/pom.xml 2 84a3ee12 122 162
@devinrsmith
devinrsmith / elgamal_test_vectors.csv
Last active May 24, 2019 09:29
Randomly generated elgamal test vectors
p g x k m a b
11 3 2 2 0 9 0
23 6 7 6 9 12 6
47 24 6 16 0 34 0
83 28 29 11 34 10 76
167 88 21 69 82 42 135
359 292 11 3 272 79 79
983 368 39 253 457 489 239
1283 269 375 604 1260 940 334
2903 1697 762 133 311 2339 826
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
/**
* Created by dsmith on 4/8/15.
*/
public class UrlTest {
public static void main(String[] args) throws IOException {
final HttpURLConnection urlConnection = (HttpURLConnection)