Skip to content

Instantly share code, notes, and snippets.

View SimonBrandner's full-sized avatar
🎉
Improving Element and [matrix]

Šimon Brandner SimonBrandner

🎉
Improving Element and [matrix]
View GitHub Profile
@SimonBrandner
SimonBrandner / main.js
Created February 20, 2022 12:07
Text stats
const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
let currentSentence = "";
let longestSentence = "";
let numberOfSentences = 0;
let numberOfWords = 0;
const numberOfLettersInSentence = (sentence) => Array.from(sentence).reduce((acc, curr) => {
if (curr !== " ") return acc + 1;
return acc;
@SimonBrandner
SimonBrandner / ngram_creator.ts
Created January 30, 2024 18:01
Creates all possible n-grams from a string
const MAX_NGRAM_LENGTH = 5;
const inputString = "Hello Alice how are you doing at the moment";
const findNgram = (
words: String[],
length: number,
startIndex: number
): String | undefined => {
if (startIndex + length > words.length) return;
@SimonBrandner
SimonBrandner / hat_check_problem.py
Created March 3, 2024 09:28
The hat-check problem solution calculator
import math
n = int(input())
def some_sum():
s = 0
for m in range(1, n+1):
s += ((-1)**(m-1)) * (1/math.factorial(m))
@SimonBrandner
SimonBrandner / journalctl
Created June 18, 2024 14:45
Suspend right after wake up bug logs
čen 18 09:24:24 Simon-s-Tuxedo-InfinityBook-14-Gen8 systemd-logind[1668]: Lid closed.
čen 18 09:24:24 Simon-s-Tuxedo-InfinityBook-14-Gen8 systemd-logind[1668]: Suspending...
čen 18 09:24:24 Simon-s-Tuxedo-InfinityBook-14-Gen8 tailord[1678]: INFO tailord::suspend: Suspended, sleeping until wake up.
čen 18 09:24:24 Simon-s-Tuxedo-InfinityBook-14-Gen8 ModemManager[68914]: <msg> [sleep-monitor-systemd] system is about to suspend
čen 18 09:24:24 Simon-s-Tuxedo-InfinityBook-14-Gen8 dbus-daemon[1599]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.6' (uid=0 pid=1713 comm="/nix/store/mlwlbq4cgi28h4j69s3brqql9d7rlcqm-networ" label="kernel")
čen 18 09:24:24 Simon-s-Tuxedo-InfinityBook-14-Gen8 systemd[1]: Starting Network Manager Script Dispatcher Service...
čen 18 09:24:24 Simon-s-Tuxedo-InfinityBook-14-Gen8 dbus-daemon[1599]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
čen 18 09:24:24 Simon-s-