Skip to content

Instantly share code, notes, and snippets.

View dkorolev's full-sized avatar
💭
Live long and prosper.

Dima dkorolev

💭
Live long and prosper.
View GitHub Profile
@dkorolev
dkorolev / Dockerfile
Created December 26, 2024 03:08
A `Dockerfile` to build FoundationDB from source.
FROM ubuntu:latest
RUN apt update
RUN apt-get upgrade -y
RUN apt-get install -y autoconf build-essential git libjemalloc-dev mono-complete liblz4-dev cmake libssl-dev ninja-build zlib1g-dev
RUN git clone https://github.com/apple/foundationdb
# Yes, I've tried `7.3` too, including the `-clean` one.
RUN (cd foundationdb; git switch release-7.2)
@dkorolev
dkorolev / Dockerfile
Created December 26, 2024 03:08
A `Dockerfile` to build YugabyteDB from source.
FROM ubuntu:latest
RUN apt update
RUN apt upgrade -y
RUN apt install -y autoconf build-essential ccache curl file g++ gcc gettext git golang libffi-dev locales maven ninja-build npm patchelf pkg-config python3 python3-dev python3-venv rsync
# Somehow, the repo contains files with names longer than 255 characters.
# I bypassed this locally with a virtual filesystem.
# The build problem is the same though, so I assume it's OK to just ignore those files for this Dockerfile-based test.
RUN git clone https://github.com/yugabyte/yugabyte-db && echo OK || echo "Long file names, but sigh, proceeding."
@dkorolev
dkorolev / echo.c
Created August 12, 2024 09:21
The `echo.c` using the `connection_context` ref. https://github.com/Theldus/wsServer/pull/93
/*
* Copyright (C) 2016-2023 Davidson Francis <davidsondfgl@gmail.com>
*
* This program 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, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
function memoizer(fn) {
if (typeof fn !== 'function') {
console.error('Need a function.');
return () => {};
} else {
return (() => {
const cache = {};
eval(`
function memoized(...args) {
const impl = ${fn.toString().replace('{', `{ const ${fn.name} = memoized; `)}
// To run: `g++ -O3 calc.cc && ./a.out`.
// Example values to run on are commented out in lines 8..10.
#include <cmath>
#include <iostream>
#include <iomanip>
long double const range = std::pow(2.0, 64); // std::pow(1.0, 32); // 1e6;
long double const desired_p_of_collision = 0.01; // 1e-5; 1e-2; // 0.5;
long double const desired_log_p = logl(1.0 - desired_p_of_collision);
@dkorolev
dkorolev / sum.rego.ir.js
Created June 12, 2022 18:03
Example Rego => JavaScript transpiled code for `dkorolev/jsopa` README.
let function_bodies = {};
let plans = {};
const opa_builtins = {
plus: (args) => { return { t: 'number', v: args[0].v + args[1].v }; },
minus: (args) => { return { t: 'number', v: args[0].v - args[1].v }; },
mul: (args) => { return { t: 'number', v: args[0].v * args[1].v }; },
numbers: {
range: (args) => {
let v = [];
for (let i = args[0].v; i <= args[1].v; ++i) {
@dkorolev
dkorolev / sum.rego.ir.json
Created June 12, 2022 18:03
Example Rego IR JSON for `dkorolev/jsopa` README.
{
"static": {
"strings": [
{
"value": "result"
},
{
"value": "a"
},
{
al = 0
si = 0x500
ram[si] = al
++si;
++al;
ram[si] = al
cx = ram[0]
cx -= 2;
while (cx) {
al = ram[si - 1]
N = 8;
ram = [];
for (let i = 0; i < N; ++i) {
ram[0x500 + i] = 0;
}
ram[0] = N;
al = 0
si = 0x500
ram[si] = al
digraph test_setup {
rankdir = LR;
node [ shape = cylinder; label = "DB" ];
db_indexer;
db_forwarder;
node [ shape = box3d ];
{ rank = same; indexer; db_indexer; }
{ rank = same; forwarder; db_forwarder; }
generator [ label = "Generator"; ];
indexer [ label = "Indexer"; ];