Skip to content

Instantly share code, notes, and snippets.

@dbieber
dbieber / fastbook.py
Last active August 10, 2023 18:13
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:
// ==UserScript==
// @name Arxiv PDF Title Updater for Hypothesis Pages
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Update Arxiv PDF links titles on Hypothesis pages
// @author David Bieber + GPT-4
// @match *://*.hypothes.is/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
@dbieber
dbieber / roam-unlinked-references-query.js
Last active July 23, 2022 03:04
Roam Research datalog query for references not already placed on a specific page
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
dbieber / cannydemo.py
Last active May 14, 2022 10:40 — forked from burnto/gist:1266515
opencv python demonstration of grayscale, canny edge detection, and blurring.
import cv
cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
camera_index = 0
capture = cv.CaptureFromCAM(camera_index)
gx = gy = 1
grayscale = blur = canny = False
def repeat():
@dbieber
dbieber / detect.py
Created January 5, 2021 02:47
Automatic distraction detection. Detects visits to distraction websites on your phone from your computer.
"""Automatic distraction detection. Work in progress.
Usage:
python detect.py main
"""
import fire
import subprocess
import plyvel
import re
@dbieber
dbieber / roam-blocks.js
Last active October 3, 2021 11:59
JavaScript Functions for Inserting Blocks in Roam. Documentation at https://davidbieber.com/snippets/2021-02-12-javascript-functions-for-inserting-blocks-in-roam/
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
dbieber / shebang.py
Created February 15, 2021 00:45
A simple Python Fire CLI using a shebang line
#!/usr/bin/env -S python3 -m fire
def hello(name):
return f'Hello {name}!'
@dbieber
dbieber / mailer.py
Last active January 22, 2021 02:56
Send an email through Gmail programmatically using Python's smtplib. Code modified from http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-with-python.html
#!/usr/bin/python
# Adapted from http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-with-python.html
import getpass
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
@dbieber
dbieber / collapse.css
Created September 4, 2012 04:43
Collapsible Blog Posts
/* CSS for Collapsible Blog Posts */
[id^=_] {
display: none;
}
@dbieber
dbieber / archivePastEvents.gs
Created December 29, 2019 23:44
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')
.addToUi();
}
function archivePastEvents() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName("Activities");