Skip to content

Instantly share code, notes, and snippets.

@bjconlan
bjconlan / build.sh
Created July 9, 2024 11:54
userver/service_template build for fedora 40
# https://userver.tech/d3/da9/md_en_2userver_2tutorial_2build.html
# NOTE libatomic comes with gcc (included in g++) so might not be needed below
dnf install -y git g++ cmake python3-devel boost-devel openssl-devel yaml-cpp-devel libzstd-devel jemalloc-devel zlib-devel libnghttp2-devel libev-devel libatomic
git clone --depth 1 https://github.com/userver-framework/service_template.git \
&& git clone --depth 1 https://github.com/userver-framework/userver.git service_template/third_party/userver \
&& cd service_template
echo "CMAKE_COMMON_FLAGS += -DUSERVER_FEATURE_STACKTRACE=0" > Makefile.local
@bjconlan
bjconlan / Containerfile
Created January 27, 2024 05:02
Running .net6 applications via wine/podman (specifically this was for https://github.com/tooll3/t3)
# podman run -it -e DISPLAY -v $XAUTHORITY:$XAUTHORITY:ro -v /tmp/.X11-unix:/tmp/.X11-unix:ro --security-opt label=type:container_runtime_t --rm --net=host --ipc=host dotnet6
FROM alpine
RUN apk update\
&& apk add wine mesa-dri-gallium vulkan-loader\
&& wget https://dl.winehq.org/wine/wine-mono/8.1.0/wine-mono-8.1.0-x86.tar.xz\
&& tar -xJf wine-mono-8.1.0-x86.tar.xz\
&& mkdir -p /root/.wine/drive_c/windows/mono\
&& mv wine-mono-8.1.0 /root/.wine/drive_c/windows/mono/mono-2.0\
&& rm wine-mono-8.1.0-x86.tar.xz
@bjconlan
bjconlan / c_cpp_properties.json
Created December 14, 2023 03:30
Cosmopolitan VSCode C/C++ Extension configuration
// Magic forcedInclude thanks to the author (https://github.com/jart/cosmopolitan/blob/master/.vscode/c_cpp_properties.json)
{
"env": {
"cosmoccPath": "${HOME}/.local/opt/cosmocc"
},
"configurations": [
{
"name": "Cosmopolitan",
"compilerPath": "${cosmoccPath}/bin/x86_64-unknown-cosmo-cc",
"forcedInclude": [
@bjconlan
bjconlan / README.md
Last active July 30, 2023 13:55
local-cluster

Update libvirt default network configuration to allow DHCP clients on network to resolve the gists netboot.ipxe configuration file via `sudo virsh net-edit default:

<network xmlns:dnsmasq='http://libvirt.org/schemas/network/dnsmasq/1.0'>
  <name>default</name>
  <uuid>38632f35-0edb-48e5-8a2c-b6b159c1938f</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
 
@bjconlan
bjconlan / merge.js
Last active February 2, 2022 16:10
Additive merge
const merge = (l, r) => Array.isArray(l) ? [...l, ...r]
: l?.constructor === Object ? [...Object.entries(l), ...Object.entries(r)].reduce((r, [k, v]) => {
r[k] = r[k] == null ? v : merge(r[k], v);
return r;
}, {})
: r;
@bjconlan
bjconlan / sort.js
Created January 31, 2022 11:48
JSON sort
const c = (x) => x?.name ?? x.alias ?? x.username ?? x;
const qs = ([p, ...rest]) => p ? [...qs(rest.filter(x => c(x) < c(p))), traverse(p), ...qs(rest.filter(x => c(x) >= c(p)))] : []
const traverse = (x) => x?.constructor === Object
? Object.entries(x).sort().reduce((r, [k, v]) => { r[k] = traverse(v); return r; }, {})
: Array.isArray(x) ? qs(x): x;
console.log(JSON.stringify(traverse(require(`${process.argv[2]}`)), null, 2));
@bjconlan
bjconlan / Dockerfile
Last active March 9, 2024 21:44
zig devcontainer
FROM mcr.microsoft.com/vscode/devcontainers/base:0-bullseye
RUN echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-15 main" >> /etc/apt/sources.list\
&& curl -sL https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -\
&& apt-get update\
&& apt-get -y install --no-install-recommends\
llvm-15-dev\
libclang-15-dev\
clang-15\
liblld-15-dev\
@bjconlan
bjconlan / WebIDL.g4
Last active September 4, 2020 12:43
WebIDL antlr grammar - W3C Editor's Draft 17 August 2020
grammar WebIDL;
file
: definitions* EOF
;
definitions
: extendedAttributeList? definition
;
@bjconlan
bjconlan / steam-information.txt
Last active February 27, 2024 13:38
steam information report - Desktop - 2024-02-27
Computer Information:
Manufacturer: Gigabyte Technology Co., Ltd.
Model: B550I AORUS PRO AX
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: AuthenticAMD
CPU Brand: AMD Ryzen 7 5800X 8-Core Processor
CPU Family: 0x19
@bjconlan
bjconlan / gf.sh
Last active September 13, 2018 06:08
Simple util function for working with multiple git repositories using the same parent folder
#!/usr/bin/env bash
# To have this work on windows (without extension) nicely its easiest
# just to create a bat file which calls `@echo off & bash -c "gf.sh %*"`
REPOS=*/
if [[ -r .gf ]]; then
REPOS=(`cat .gf`)
fi
for REPO in $REPOS; do