Skip to content

Instantly share code, notes, and snippets.

@cadadr
cadadr / nopl.js
Created February 27, 2020 22:16
Non-playlist links in YouTube playlists
// ==UserScript==
// @name youtube-non-playlist-links
// @version 1
// @grant none
// @namespace youtube.com/playlist
// @include https://www.youtube.com/playlist*
// @include https://youtube.com/playlist*
// ==/UserScript==
document.querySelectorAll(
@cadadr
cadadr / install-doc-packages.sh
Created March 23, 2020 19:30
Install (almost) all relevant -doc packages on a Debian / Ubuntu based system
#/bin/sh
# install-doc-packages.sh --- find and install ‘-doc’ packages related to installed packages
preferred_lang='en'
tmpfil="$(mktemp --tmpdir install-doc-packagesXXXXXXXXXXXXXXXXXXX)"
qfmt='${db:Status-Abbrev}${binary:Package}\n'
# This works as such:
@cadadr
cadadr / Readme.markdown
Last active April 27, 2020 17:42
Comparison of `while` and `for i in np.arange(...)` in loops of various length

for loops with np.arange seem to be quicker than manual while loops for certain powers of 10. The inverse is true for some other numbers and interestingly, 10 million loops. I got this pattern fairly consistently with

  • Python 3.6.9
  • Linux Mint 19.3 (Linux g-X551CA 5.3.0-46-generic #38~18.04.1-Ubuntu SMP Tue Mar 31 04:17:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux)
  • Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
  • Numpy 1.18.2

The benchmark function is a dice roller that rolls a positive number of dice each with a positive number of sides 2+ times a batch, and calculates means for each batch. It does this by allocating nBatch * nRolls random integers between 1 and nSides * nDice (inclusive), so the run time of the function is probably consistent between runs.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cadadr
cadadr / NaturalClasses.org
Last active March 18, 2021 08:02
Natural Classes Cheat Sheet (phonology)

Natural Classes

@cadadr
cadadr / Readme.markdown
Created October 14, 2021 08:06
OPML-to-sexp converter for elfeed

This will convert your OPML to an sexp that can be used to set up feeds for elfeed. It'll convert categories (likely, folders, in your feed reader) to tags.

You will need to keep gk-elfeed-feeds-with-category around after doing the conversion.

A nice way to use this is to run it with C-u M-x pp-eval-last-sexp RET C-M-b C-j C-j and manually reformat the resulting output.

You'll want to have something like paredir or smartparens set up to work with that sort of large sexp.

@cadadr
cadadr / optfuck.c
Created May 21, 2022 02:31
Brainfuck with input as command line arguments
/* optfuck.c --- Brainfuck with input as command line arguments.
Copyright (C) 2016, 2017 Göktuğ Kayaalp <self |at| gkayaalp {dot} com>.
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
@cadadr
cadadr / 00-notes.markdown
Created June 12, 2022 14:24
Capture template for annotated research photographs with Emacs and Org mode

Code snippet to accompany the fediverse post: https://scholar.social/@cadxdr/108464579108516573

This is a simple system based on Emacs, Org mode, and it's Capture feature to annotate images. Or any other file really, but I'm making this workflow to annotate images, as an alternative to using Tropy.

Tropy is nice but for my purposes, for whom pictures aren't the centre of my research, it is a bit too much. I need to know about stuff, like Dublin Core, or specific metadata practices, which likely won't come up in my work. So I don't want that barrier to get in my way when I'm organising and annotating photographs.

The below snippet assumes there's a file at the path ~/Notes/Photos.org and that you have used org-store-link to collect links for the file or the files you would like to annotate. The template creates a toplevel entry in the file,

// This script will generate an OPML from your YouTube subscriptions
// and write it to clipboard, or failing that, to the browser console.
// In order to use it, navigate to <https://www.youtube.com/feed/channels>,
// open the browser developer console, and copy-paste the following
// javascript into the prompt.
//
// In order to grab the resulting script in Firefox, if copying
// to clipboard fails, right-click on the output message in the
// console and select "Copy object" from the menu.
//
@cadadr
cadadr / scrcpy_webcam.markdown
Last active March 26, 2024 06:41
Use android phone as webcam using scrcpy, OpenCamera, and v4l2-loopback

Download Android SDK and put it under a known location. Get the appropriate commandlinetools package from this page. Then, extract it under ~/Android/.

mkdir -p ~/Android/Sdk
cd ~/Android
cp ~/Downloads/commandlinetools-linux-6858069_latest.zip .
unzip commandlinetools-linux-6858069_latest.zip