Skip to content

Instantly share code, notes, and snippets.

@cadadr
cadadr / scrcpy_webcam.markdown
Last active Apr 26, 2021
Use android phone as webcam using scrcpy, OpenCamera, and v4l2-loopback
View scrcpy_webcam.markdown

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
@cadadr
cadadr / NaturalClasses.org
Last active Mar 18, 2021
Natural Classes Cheat Sheet (phonology)
View Youtube to OPML.js
// 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.
//
View emacsconf2020.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cadadr
cadadr / Readme.markdown
Last active Apr 27, 2020
Comparison of `while` and `for i in np.arange(...)` in loops of various length
View Readme.markdown

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.

@cadadr
cadadr / install-doc-packages.sh
Created Mar 23, 2020
Install (almost) all relevant -doc packages on a Debian / Ubuntu based system
View install-doc-packages.sh
#/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 / nopl.js
Created Feb 27, 2020
Non-playlist links in YouTube playlists
View nopl.js
// ==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(