Skip to content

Instantly share code, notes, and snippets.

View Sejmou's full-sized avatar

Samo Kolter Sejmou

  • Vienna, Austria
View GitHub Profile
@Sejmou
Sejmou / genius-lyrics-copier.js
Last active April 27, 2023 23:36
Tampermonkey userscript for extracting lyrics from the Genius website
// ==UserScript==
// @name Genius Lyrics Copier
// @namespace genius-lyrics-copier
// @version 1
// @description Adds a button to copy lyrics from Genius website to clipboard
// @match https://genius.com/*
// @grant GM_setClipboard
// @noframes
// ==/UserScript==
@Sejmou
Sejmou / extract-code-from-notebook.sh
Last active January 6, 2023 14:19
Simple one-liner for printing notebook code without any lines containing only single variable or accessed prop on its own (caution: only works in Unix systems, doesn't detect expressions like 3+4 or tuples containing variables/expressions at end of cell)
jupyter nbconvert --stdout --no-prompt --to script notebook.ipynb | grep -Ev '^\s*\(*[a-zA-Z0-9_\.,\s]+\)*\s*$'
@Sejmou
Sejmou / reverse-obj-keys-and-vals.js
Last active September 2, 2022 14:33
Random JS helper functions
// https://stackoverflow.com/a/23013726/13727176
function swap(obj) {
const ret = {};
for (const key in obj) {
ret[json[key]] = key;
}
return ret;
}
@Sejmou
Sejmou / markdown.snippets
Created June 8, 2022 18:57
R Studio snippets (to use, copy into respective snippet file accessible via "Tools -> Edit Code Snippets...")
snippet imfn
```{r, echo=F}
# This is a custom function I wrote for showing images
# It is more robust than embedding images in R markdown directly
# With imgs embedded in R markdown, compilation of whole document fails if img missing
# This function also displays the image if possible and just logs an error otherwise
# Under the hood, knitr::include_graphics() is used, which also accepts multiple image paths as parameter
# Therefore, with this function, side-by-side images are also supported
# We then need to pass a vector of paths in the function call and add fig.show='hold' to the code cell
@Sejmou
Sejmou / pdf-pattern-search.sh
Last active January 6, 2023 13:56
Useful Unix commands
# Search for pattern in PDFs inside current folder (and subfolders, recursively)
pdfgrep pattern $(find -name '*.pdf' | sort)
@Sejmou
Sejmou / markdown.snippets
Created April 23, 2022 14:15
RStudio code snippets
snippet imfn
```{r, echo=F}
# This is a custom function I wrote for showing images
# It is more robust than embedding images in R markdown directly
# With imgs embedded in R markdown, compilation of whole document fails if img missing
# This function also displays the image if possible and just logs an error otherwise
# Under the hood, knitr::include_graphics() is used, which also accepts multiple image paths as parameter
# Therefore, with this function, side-by-side images are also supported
# We then need to pass a vector of paths in the function call and add fig.show='hold' to the code cell
@Sejmou
Sejmou / cloudSettings
Last active March 24, 2021 16:57 — forked from bradtraversy/mongodb_cheat_sheet.md
MongoDB Cheat Sheet
{"lastUpload":"2021-03-24T16:57:43.413Z","extensionVersion":"v3.4.3"}