Skip to content

Instantly share code, notes, and snippets.

View MikulasZelinka's full-sized avatar
🐯

myke MikulasZelinka

🐯
View GitHub Profile
@MikulasZelinka
MikulasZelinka / coingame.py
Created September 20, 2017 20:46
Infinitely many people gather to wrap their heads around a coin-flipping game
# Game: n people, each person flips a coin until they get heads
# Question: what is the ratio of heads after the game ends?
n = 1024
heads = 0
tails = 0
# how many rounds does each game last on average (just for fun):
iterations = 0
@MikulasZelinka
MikulasZelinka / th_before_last_fr.txt
Created June 29, 2020 21:56
The Thursday before the last Friday in each month
# https://jakubroztocil.github.io/rrule/
RRULE:FREQ=MONTHLY;BYDAY=TH;BYMONTHDAY=-8,-7,-6,-5,-4,-3,-2
{
freq: RRule.MONTHLY,
byweekday: [RRule.TH],
bymonthday: [-8, -7, -6, -5, -4, -3, -2]
}
@MikulasZelinka
MikulasZelinka / marching_band.py
Created August 5, 2020 21:50
MPMP: The Marching Band Problem
# python one-liner solution to https://www.youtube.com/watch?v=5GZ5IqxAt30
print(next(x for x in range(1_000_000) if len([y for y in range(1, x + 1) if x % y == 0]) == 64))
@MikulasZelinka
MikulasZelinka / cz_nouns_normalized.txt
Created April 17, 2022 09:43
Česká podstatná jména bez diakritiky, kombinace openoffice slovníku a podstatných jmen ze SYN2020
This file has been truncated, but you can view the full file.
clovek
muz
zena
vetsina
otec
praha
cena
jan
matka
// ==UserScript==
// @name Auto best quality for videos in Google Photos
// @namespace mikulas.zelinka.dev
// @version 0.1
// @description Tampermonkey script that selects the best quality for all embedded youtube videos when the page/player is loaded (at least those that are served with the same URL as those in Google Photos).
// @author Mikuláš Zelinka
// @match https://youtube.googleapis.com/embed/*
// @grant none
// ==/UserScript==
@MikulasZelinka
MikulasZelinka / pytorch_pad_pack_minimal.py
Last active August 2, 2023 07:51
pytorch: handling sentences of arbitrary length (dataset, data_loader, padding, embedding, packing, lstm, unpacking)
"""
sort-of minimal end-to-end example of handling input sequences (sentences) of variable length in pytorch
the sequences are considered to be sentences of words, meaning we then want to use embeddings and an RNN
using pytorch stuff for basically everything in the pipeline of:
dataset -> data_loader -> padding -> embedding -> packing -> lstm -> unpacking (~padding)
based mostly on: https://github.com/HarshTrivedi/packing-unpacking-pytorch-minimal-tutorial
pytorch version 1.4.0
gist url: https://gist.github.com/MikulasZelinka/9fce4ed47ae74fca454e88a39f8d911a
"""
@MikulasZelinka
MikulasZelinka / README.md
Last active October 19, 2023 20:58
Celery Python – minimal example (app is started from Python, task is also sent from Python)

Execute in the following order:

docker run -d -p 6379:6379 redis
python celery_app.py
@MikulasZelinka
MikulasZelinka / sort_google_doc_by_headings.gs
Created December 21, 2023 21:13
Sort a Google Doc by Headings (sections) while preserving contents (paragraphs) of each section
function onOpen() {
var ui = DocumentApp.getUi();
// Create custom menu
ui.createMenu('Sort and Write')
.addItem('Sort and Write Ascending', 'sortAndWriteAscending')
.addItem('Sort and Write Descending', 'sortAndWriteDescending')
.addToUi();
}
function sortAndWriteAscending() {