Skip to content

Instantly share code, notes, and snippets.

View nikosavola's full-sized avatar
🎮

Niko Savola nikosavola

🎮
  • X (Google)
  • Helsinki, Finland
  • 09:05 (UTC +03:00)
  • LinkedIn in/nikosavola
View GitHub Profile
@nikosavola
nikosavola / run_scspell.sh
Last active May 27, 2022 06:11
Run `scspell` on globbed files
#!/bin/bash
# Glob all .py files and concatenate to string with spaces
SCSPELL_FILES=$(find . -name "*.py" -o -name "*.ipynb" | tr '\n' ' ')
# Run spell checker
scspell $SCSPELL_FILES
@nikosavola
nikosavola / speed_up.sh
Last active October 20, 2023 04:34
Speed up mp3 files in a folder (for example, an audiobook)
#!/bin/bash
# Run in a folder with desired mp3s
mkdir sped_up
mkdir sped_up_louder
find . -name "*.mp3" -exec bash -c 'ffmpeg -i "$0" -filter:a "atempo=1.12, dynaudnorm" -vn "sped_up/${0%.mp3}_sped_up.mp3"' {} ;
cd sped_up || exit
find . -name "*_sped_up.mp3" -exec bash -c 'ffmpeg -i "$0" -filter_complex "compand=attacks=0:points=-80/-900|-45/-15|-27/-9|0/-7|20/-7:gain=6" -vn "../sped_up_louder/${0%.mp3}_louder.mp3"' {} \;
cd ..
#!/bin/bash
sed -i -e 's/\(^ *month\) *= *["{]{*jan}*[}"]/\1 = "1"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*feb}*[}"]/\1 = "2"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*mar}*[}"]/\1 = "3"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*apr}*[}"]/\1 = "4"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*may}*[}"]/\1 = "5"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*jun}*[}"]/\1 = "6"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*jul}*[}"]/\1 = "7"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*aug}*[}"]/\1 = "8"/i' references.bib
sed -i -e 's/\(^ *month\) *= *["{]{*sep}*[}"]/\1 = "9"/i' references.bib
@nikosavola
nikosavola / lint.m
Created January 10, 2022 07:30
Lint all MATLAB files recursively
% This code lints all the .m files under working directory recursively
files = ls("./**/*.m");
files = strsplit(string(files))';
% First gather all errors
msgs = {};
for i = 1:length(files(1:end-1))
msgs{i} = checkcode(files{i},'-string');
if ~isempty(msgs{i})
msgs{i} = append(files{i},':',newline, msgs{i});
@nikosavola
nikosavola / Extensions.md
Created November 22, 2021 13:19
JupyterLab settings

Recommended extensions

  • @jupyterlab/katex-extension
  • @arbennett/base16-mexico-light
@nikosavola
nikosavola / AutoHotkey
Last active November 18, 2021 12:19
Ok AutoHotkey config
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SwitchToWindowsTerminal()
{
windowHandleId := WinExist("ahk_exe WindowsTerminal.exe")
windowExistsAlready := windowHandleId > 0
; If the Windows Terminal is already open, determine if we should put it in focus or minimize it.
@nikosavola
nikosavola / HexColorsToImages.md
Created August 26, 2021 10:16
Hex colors to images

Get Markdown embeddable images from hex color tags.

Example output:

80a8ff 01ff6b ff8000 000000 00ffff

@nikosavola
nikosavola / dfHeatmap.md
Last active June 1, 2023 08:57
2D heatmap from DataFrame

Select two parameters and dependent variable from a DataFrame and plot an ´imshow´-style heatmap with isocontours.

Remember to:

import seaborn as sns
@nikosavola
nikosavola / 🎵 My last week in music
Last active October 4, 2023 04:12
🎶🤘 Last week in music
Phil Collins ████░░░░░░░░░░░░░ 22 plays
Bad Bunny ██▌░░░░░░░░░░░░░░ 14 plays
Knife Party █▊░░░░░░░░░░░░░░░ 10 plays
Olavi Uusivirta █▋░░░░░░░░░░░░░░░ 9 plays
Deftones █▍░░░░░░░░░░░░░░░ 8 plays
King Gizzard & The Lizard █▍░░░░░░░░░░░░░░░ 8 plays
Amaranthe █░░░░░░░░░░░░░░░░ 6 plays
Reem █░░░░░░░░░░░░░░░░ 6 plays
Battle Beast ▉░░░░░░░░░░░░░░░░ 5 plays
Poppy ▋░░░░░░░░░░░░░░░░ 4 plays
@nikosavola
nikosavola / niko.mplstyle
Last active January 23, 2023 12:46
Style configuration for Matplotlib. Save to ~/.matplotlib/stylelib
## https://matplotlib.org/3.3.3/tutorials/introductory/customizing.html
axes.prop_cycle : cycler('color', ['008fd5', 'fc4f30', '68dc9b', 'ffdf54', '8b8b8b', '810f7c']) # Modified fivethirtyeight
axes.xmargin : 0 # axis tight
axes.facecolor : white # background colour
axes.linewidth : 1.2
font.family : serif
font.sans-serif : Arial
font.serif : Adobe Text Pro