Skip to content

Instantly share code, notes, and snippets.

View jbosboom's full-sized avatar

Jeffrey Bosboom jbosboom

  • 03:40 (UTC -07:00)
View GitHub Profile
REFINER RECIPES:
Carbon (Unrefined Organic Element) used by 21
1 Condensed Carbon -> 2 Carbon
1 Oxygen -> 1 Carbon
1 Fungal Mould -> 2 Carbon
1 Gamma Root -> 2 Carbon
1 Cactus Flesh -> 2 Carbon
1 Solanium -> 2 Carbon
1 Star Bulb -> 2 Carbon
@jbosboom
jbosboom / sqlite-doc-dark.user.css
Last active June 24, 2021 07:46
SQLite documentation dark mode user CSS
/* ==UserStyle==
@name SQLite documentation dark mode
@namespace jeffreybosboom.com
@version 1.0.0
@description SQLite documentation dark mode
@author Jeffrey Bosboom
==/UserStyle== */
@-moz-document domain("sqlite.org") {
:root {
// ==UserScript==
// @name Arch Linux Manpages Sidebar TOC
// @namespace jeffreybosboom.com
// @author Jeffrey Bosboom
// @description Makes the sidebar about the table of contents (best used with some user CSS)
// @version 1
// @match https://man.archlinux.org/man/*
// @grant none
// @inject-into content
// ==/UserScript==
@jbosboom
jbosboom / partial-clone-sparse-checkout-bare-repository.md
Last active May 29, 2021 08:17
Simulating sparse checkout in a partial clone bare repository

Simulating sparse checkout in a partial clone bare repository

Background

Partial clone is a git feature allowing a local repository to contain only a subset of a remote repository's trees and blobs, fetching missing objects lazily. Sparse checkout is a separate git feature allowing a working tree to contain only a subset of the files tracked by the repository. Used together, partial clone and sparse checkout allow working with large multi-project repositories ("monorepos") and repositories containing large binary files without having to download and store a full copy of the data in the repository. (Shallow clone is a distinct git feature that limits the commits stored in the local repository.)

For example, consider jbosboom/test-partial-clone-sparse-checkout, which tracks a few text files and some large images. If we want to work on the text files, but don't need the images, we can avoid downloading and storing them in our local rep

#!/usr/bin/env python3
import pickle, io, collections, sys
x = collections.deque()
x.append(10)
x.append(3.14)
x.append(10000000000000)
x.append((1, 2, 3))
x.append([1, 2, 3])
#!/usr/bin/env python3
import sys, os
samples = 100
sample_size = 25 * 1024 * 1024
with open(sys.argv[1], 'rb') as input, open(sys.argv[2], 'w+b') as output:
total_size = os.fstat(input.fileno()).st_size
sampled_size = samples * sample_size
@jbosboom
jbosboom / lmdb-bench.cpp
Created August 30, 2020 21:48
LMDB benchmark testing sorted vs unsorted insert order for a hashtable
#include "precompiled.hpp"
#include "stopwatch.hpp"
#include "lmdb++.h"
int main() { //genbuild {'entrypoint': True, 'ldflags': '-llmdb'}
lmdb::env env = lmdb::env::create();
env.set_mapsize(1UL * 1024 * 1024 * 1024 * 1024);
env.set_max_dbs(64);
env.open(std::string("/home/jbosboom/scratch/benchmark.mdb").c_str(), MDB_NORDAHEAD); //TODO: flags?
@jbosboom
jbosboom / approx-rename.py
Created August 30, 2020 21:46
Approximate file renaming script
#!/usr/bin/env python2
import sys, os, shutil, argparse, string, readline
from fuzzywuzzy import process
parser = argparse.ArgumentParser()
parser.add_argument('directory', type=str)
parser.add_argument('namelist', type=argparse.FileType(mode='r'))
# TODO: option to include extension in renaming?
args = parser.parse_args()
@jbosboom
jbosboom / papergen.py
Created August 30, 2020 21:45
Generates landscape ruled paper
#!/usr/bin/env python2
margin = 0.375
lineheight = (8.5 - 2*margin)/25
linewidth = 11 - 2*margin
midgutter = 11.0/2
ypts = [(margin, midgutter-(margin/2)), (midgutter+(margin/2), 11.0 - margin)]
color = '#A4DDED'
thickness = 1.0/64
@jbosboom
jbosboom / gtest-to-doctest.py
Created August 30, 2020 21:44
Convert gtest macros to doctest macros
#!/usr/bin/env python2
import sys, os, re
conversions = [
('<gtest/gtest.h>', '<doctest.h>'),
(r'TEST\(([a-zA-Z0-9]+), ([a-zA-Z0-9]+)\)', r'TEST_CASE("\1_\2")')
]
severity_map = {'ASSERT': 'REQUIRE', 'EXPECT': 'CHECK'}