Skip to content

Instantly share code, notes, and snippets.

Avatar

Göktuğ Kayaalp cadadr

View GitHub Profile
@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(
You can’t perform that action at this time.