Skip to content

Instantly share code, notes, and snippets.

View oxc's full-sized avatar

Bernhard Frauendienst oxc

  • Munich, Germany
  • 00:49 (UTC +02:00)
View GitHub Profile
@oxc
oxc / node-execv.ts
Last active February 20, 2024 14:57
Call execv (works similar for execvp, execve) on Node 20
import ref from "ref-napi";
import ffi from "ffi-napi";
import ref_array_di from "ref-array-di";
const ArrayType = ref_array_di(ref);
const StringArray = ArrayType("string");
// from fcntl.h
const F_GETFD = 1; /* get close_on_exec */
@oxc
oxc / NodeModulesLayerPlugin.mjs
Created April 27, 2023 13:54
esbuild plugin to mark only (some) top-level node_modules as external
/**
* @typedef {Object} NodeModulesLayerPluginOptions
* @property {string[]} [layerModules]
*/
const recursionFlag = Symbol.for('$NodeModulesLayerPlugin_recursion')
/**
* This is an esbuild plugin which marks all imports that are included in a NodeModulesLayer as external.
*
@oxc
oxc / pattern.py
Created June 29, 2020 12:13
pattern.py
#!/usr/bin/env python
import sys
PATTERNS = [
("19,28 1 5","18,12 2 3","19,5 1 2","18,1 4 3","18,22 1 2","18,4 3 2","18,6 1 3"),
("19,2 4 1","18,1 4 3","19,5 1 2","19,12 1 3","19,6 11 1","18,22 1 2","18,15 1 2","19,12 1 3"),
("19,28 1 5","19,5 1 2","18,22 1 2","18,22 1 2","18,10 22 1","18,36 2 4","19,5 1 2","18,20 19 2"),
("19,5 1 2","18,20 19 2","19,6 11 1","18,1 4 3","18,10 22 1","18,20 19 2","18,1 3 1"),
("18,12 2 3","18,10 22 1","18,10 22 1","19,6 11 1","18,4 3 2","18,1 4 3"),
@oxc
oxc / HashSet.java
Last active March 19, 2020 16:48
OpenJDK snippet demonstrating correct HashMap constructor usage
/**
* Constructs a new set containing the elements in the specified collection.
* The {@code HashMap} is created with default load factor (0.75) and an initial
* capacity sufficient to contain the elements in the specified collection.
*/
public HashSet(Collection<? extends E> c) {
map = new HashMap<>(Math.max((int) (c.size()/.75f) + 1, 16));
addAll(c);
}
package de.classyfi.session;
import java.time.Duration;
import java.time.Instant;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
@oxc
oxc / ipmi-updater.py
Last active November 30, 2023 09:21 — forked from dmerner/ipmi-updater.py
Supermicro IPMI certificate updater
#!/usr/bin/env python3
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=python
# This file is part of Supermicro IPMI certificate updater.
# Supermicro IPMI certificate updater is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@oxc
oxc / README
Last active December 12, 2018 16:37
Demo: IDEA reads multiplatform module dependencies as jars
If a (java) project depends on two kotlin-multiplatform libraries that depend on each other,
this causes strange behaviour when importing the project in IntelliJ IDEA: the java-project
classpath gets a compile entry containing two jar files, pointing to the gradle build path
of the two libraries' jars (see `issue-jar-dependency.png`).
If the transitive dependency is comment out in the java-project dependencies, it gets imported
correctly, even though the transitive dependency is marked as "implementation" in the other
libary (see `issue-module-dependencies.png`).
@oxc
oxc / dhparams.pp
Created November 23, 2017 13:09
Puppet defined type for regular dhparams re-generation
# create and refresh dh params
define profile::security::dhparams(
String $path = $name,
Integer $length,
$recreate_after = null,
Boolean $selinux = false,
$owner = 'root',
$group = 0,
) {
$tmpfile = "${dirname($path)}/.puppet-${basename($path)}"
@oxc
oxc / keybase.txt
Last active December 7, 2015 22:21
keybase.io verification gist
### Keybase proof
I hereby claim:
* I am oxc on github.
* I am oxc (https://keybase.io/oxc) on keybase.
* I have a public key whose fingerprint is 40AE 603D C8D7 AD42 4A99 74DC FCD4 D949 FB8E 2709
To claim this, I am signing this object:
/**
* given super-class from a 3rd-party library
*/
abstract class AbstractSuperClass<T extends AbstractParamClass> {
// ...
abstract static class AbstractParamClass {
// ...
}
}