Skip to content

Instantly share code, notes, and snippets.

dbieber /
Created Feb 15, 2021
A simple Python Fire CLI using a shebang line
#!/usr/bin/env -S python3 -m fire
def hello(name):
return f'Hello {name}!'
View roam-blocks.js
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
function getPage(page) {
// returns the uid of a specific page in your graph.
// _page_: the title of the page.
let results = window.roamAlphaAPI.q(`
[:find ?uid
:in $ ?title
dbieber /
Created Jan 5, 2021
Automatic distraction detection. Detects visits to distraction websites on your phone from your computer.
"""Automatic distraction detection. Work in progress.
python main
import fire
import subprocess
import plyvel
import re
dbieber / roam-unlinked-references-query.js
Last active Jan 3, 2021
Roam Research datalog query for references not already placed on a specific page
View roam-unlinked-references-query.js
let container = "Tree of knowledge";
let tag = "zettel";
let ancestorrule=`[
[(ancestor ?child ?parent)
[?parent :block/children ?child]]
[(ancestor ?child ?a)
[?parent :block/children ?child]
(ancestor ?parent ?a)]
dbieber /
Last active Mar 23, 2021
fastbook speeds up the silence in audiobooks, and can speed up the non-silence too
"""Performs automatic speed edits to audio books.
Example usage:
Assuming you have an audiobook book.aax on your Desktop:
1. Convert it to wav:
ffmpeg -i ~/Desktop/book.aax ~/Desktop/book.wav
2. Adjust the speed:
dbieber /
Created Dec 29, 2019
Code used for archiving past events in the daily activity log spreadsheet.
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Activity Log')
.addItem('Archive Past Events', 'archivePastEvents')
function archivePastEvents() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName("Activities");
dbieber /
Created Oct 21, 2018
The source of SpreadsheetDB used in the "Writing a Mail Merge in Google Apps Script" post on
function getColumnIndexes(columns) {
// Returns a map from column name to column index.
var container = {};
for (var i = 0; i < columns.length; i++) {
var value = columns[i];
container[value] = i;
return container;
dbieber / dksnake.js
Created Jan 5, 2017
Plays Snake game at
View dksnake.js
// Computer assisted snake!
// Paste this into the JS console at to play and win!
function getX() {
var head = gSnake.getHead();
var x = head.x / 20;
return x;
function getY() {
dbieber /
Created Nov 9, 2014
Uses Firefox with Selenium to take a picture of kittens on Google Images
from selenium import webdriver
driver = webdriver.Firefox()
driver.set_window_size(800, 600)
driver.set_window_position(0, 0)
searchbar = driver.find_elements_by_css_selector("#lst-ib")[0]
searchbar.send_keys("cute kittens")
dbieber /
Last active Jan 2, 2016
Creates a markov model and implements viterbi. Given a sequence of local belief states (observations), finds the most likely sequence of states.
def get_probabilities(corpus, alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
corpus = ''.join([c for c in corpus if c in alpha])
counts = [corpus.count(c) for c in alpha]
start_probs = np.array(counts, dtype=float) / sum(counts)
trans_counts = [[0.1 + corpus.count("%s%s" % (a,b)) for b in alpha] for a in alpha]
trans_probs = np.array([np.array(x, dtype=float)/sum(x) for x in trans_counts])
return (start_probs, trans_probs)