Skip to content

Instantly share code, notes, and snippets.

View GavinRay97's full-sized avatar

Gavin Ray GavinRay97

View GitHub Profile
@GavinRay97
GavinRay97 / docker-compose.yaml
Created October 28, 2022 17:34
Docker Compose single-file volume (IE, set Postgres seed data)
version: "3.6"
services:
postgres:
image: postgres:15
restart: always
volumes:
- db_data:/var/lib/postgresql/data
- type: bind
source: ./docker/postgres/chinook.sql
@GavinRay97
GavinRay97 / coroutines.cpp
Created October 28, 2022 17:11
Seastar Coroutine comparison
int main(int argc, char** argv)
{
seastar::sharded<buffer_pool_service> buffer_pool_service;
seastar::app_template app;
app.add_options()(
"db-file", boost::program_options::value<std::string>()->default_value("db.dat"), "Database file");
return app.run(argc, argv, [&] -> seastar::future<int> {
seastar::engine().at_exit([&buffer_pool_service] { return buffer_pool_service.stop(); });
@GavinRay97
GavinRay97 / .clang-format
Created October 26, 2022 02:26
clang-format and clang-tidy config
BasedOnStyle: Microsoft
ColumnLimit: 120
PointerAlignment: Left
AlwaysBreakTemplateDeclarations: Yes
SortIncludes: CaseSensitive
AlignArrayOfStructures: Right
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: Consecutive
@GavinRay97
GavinRay97 / main.zig
Created October 15, 2022 20:21
Zig Buffer Pool Manager [Blogpost]
const std = @import("std");
const PAGE_SIZE = 4096;
const BUFFER_POOL_NUM_PAGES = 1000;
/////////////////////////
// DISK MANAGER
/////////////////////////
const IoUringDiskManager = struct {
@GavinRay97
GavinRay97 / code.java
Last active October 7, 2022 22:30
Quarkus v2.13.0-Final benchmarks, Loom vs Standard, Reactive SQL vs JDBC
@ApplicationScoped
public class PersonRepositoryAsyncAwait {
@Inject
PgPool pgPool;
public Person findById(Long id) {
RowSet<Row> rowSet = pgPool
.preparedQuery("SELECT id, name, age, gender FROM person WHERE id = $1")
.executeAndAwait(Tuple.of(id));
@GavinRay97
GavinRay97 / io_uring.java
Last active September 23, 2022 20:08
io_uring Panama draft
class IoUringExample {
private static int QUEUE_DEPTH = 8;
private static MemorySession session = MemorySession.global();
private static GroupLayout myStructLayout = MemoryLayout.structLayout(
Constants.C_INT.withName("foo"),
Constants.C_INT.withName("bar"));
private static VarHandle myStruct$foo = myStructLayout.varHandle(MemoryLayout.PathElement.groupElement("foo"));
private static VarHandle myStruct$bar = myStructLayout.varHandle(MemoryLayout.PathElement.groupElement("bar"));
@GavinRay97
GavinRay97 / example.sh
Created September 21, 2022 16:51
Use ctags to extract names of all functions in a C header
$ ctags --language-force=C -x --_xformat="%N:%{typeref}:%{signature}" --kinds-C=p libfoo.h
@GavinRay97
GavinRay97 / Dockerfile
Created September 21, 2022 15:00
OpenJDK build environment
FROM quay.io/fedora/fedora:38
# Install requirements for building OpenJDK from source
RUN dnf install -y \
file \
diffutils \
alsa-lib-devel \
cups-devel \
fontconfig-devel \
freetype-devel \
@GavinRay97
GavinRay97 / Dockerfile
Created September 21, 2022 03:52
jextract Dockerfile, builds from source into CLI
FROM ubuntu:22.10 AS builder
# Allow configuring LLVM download URL
ARG LLVM_DOWNLOAD_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
ARG LLVM_EXTRACTED_FILE_NAME=clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04
# Install dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
git \
curl \
@GavinRay97
GavinRay97 / allocator.h
Created September 6, 2022 00:10
C++ Simple Fixed-Size Allocator
// From https://github.com/L-v-M/async/blob/main/cppcoro/include/cppcoro/allocator.hpp
#pragma once
#include <cstdint>
#include <iostream>
#include <memory>
#include <vector>
class FixedAllocator
{