Skip to content

Instantly share code, notes, and snippets.

View avborup's full-sized avatar
Converting caffeine into code

Adrian Borup avborup

Converting caffeine into code
View GitHub Profile
@avborup
avborup / docAsObject.js
Last active August 28, 2023 10:19
A utility for obtaining a JS object representation of a Firestore object based on the currently focused document in the Firebase console UI. It's an IIFE that can be pasted into the browser console.
(() => {
const result = {};
const panels = document.querySelectorAll("f7e-fields-subpanel");
const panel = panels[panels.length - 1];
const topLevel = panel.querySelectorAll("f7e-panel > div > f7e-data-tree");
const addEntry = (node, result) => {
const dbNode = node.querySelector('.database-node');
@avborup
avborup / 0-example-run.md
Last active March 19, 2023 14:34
Small example showing potential overwrite bug in flan

flan/test_overwrite.c: Test that shows the problem

I have added a new test for flan which should show the issue on a clean, mkfs.flexalloc'd loopback device. Below I have shown the test being run three times.

  1. First test shows that there is no object data once the object is initially opened, this is expected. You can also see that the second "Before" print still shows "salad" instead of "pizza".
  2. Second test shows that there is already data in the object containing "My favourite food is salad!". This, I would expect, should say chocolate and not salad since that was the last write.
  3. Third test shows the same issue.
$ sudo FLAN_TEST_DEV=/dev/loop16 ./build/flan/flan_test_overwrite 512
sudo apt update
# fetch dotfiles - https://github.com/avborup/dotfiles
cd $HOME && git clone https://github.com/avborup/dotfiles.git
# zsh - https://gist.github.com/derhuerst/12a1558a4b408b3b2b6e
sudo apt install zsh
# ohmyzsh - https://github.com/ohmyzsh/ohmyzsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Set .zshrc
@avborup
avborup / Dockerfile
Last active September 15, 2020 18:01
My personal Visual Studio Code config for using LaTeX Workshop with Docker to compile LaTeX. The image must be built with the tag `mytex` in order to work.
FROM blang/latex:ctanfull
RUN apt-get update
RUN apt-get install python3 python3-pip -y;
RUN ln -s /usr/bin/python3 /usr/bin/python; \
ln -s /usr/bin/pip3 /usr/bin/pip; \
python --version; \
pip --version
@avborup
avborup / calculate_distance.R
Created October 27, 2018 14:28
A program to calculate the distance between two locations on planet Earth, based on the longitude and latitude of those two points.
library(stringr)
# Radius of the Earth
R <- 6378
read_coord <- function(str) {
# Use regular expressions for extracting values
degs <- as.numeric(str_extract(str, "\\d+"))
mins <- as.numeric(str_extract(str, "\\s\\d+"))