Skip to content

Instantly share code, notes, and snippets.

View gartenfeld's full-sized avatar

David Rosson gartenfeld

View GitHub Profile
@gartenfeld
gartenfeld / download_section_metadata.sh
Last active September 29, 2023 23:49
Downloading section JSON data
# First, set up ssh for Puhti
# Use ssh-copy-id to add your key
ssh-copy-id yourcscusername@puhti.csc.fi
# This way, you don't have to type your password for every command
# Make a .txt file with one file name (relative) per line
# Copy this file to remote
scp ./download_list.txt yourcscusername@puhti.csc.fi:.
# Log in
@gartenfeld
gartenfeld / mac_dictionary.sh
Created July 12, 2020 12:56
Search for word patterns
egrep ".*word$" /usr/share/dict/words
@gartenfeld
gartenfeld / jwt_user.js
Last active May 3, 2020 15:09
User decoder
const server = {}; // ...
const cookieParser = require('cookie-parser');
const jwt = require('jsonwebtoken');
server.express.use(cookieParser());
server.express.use((req, res, next) => {
const { token } = req.cookies;
if (token) {
const { userId } = jwt.verify(token, process.env.APP_JWT_SECRET);
req.userId = userId;
@gartenfeld
gartenfeld / de_word_final_ngrams.csv
Last active October 5, 2019 12:57
German Word-Final N-Grams
We can't make this file beautiful and searchable because it's too large.
reverse, ending, length, is_word, ngram_weight, m_raw, f_raw, n_raw, m_freq, f_freq, n_freq, highest, predicted, correct, top
e, e, 1, 0, 473.2622, 306, 3562, 175, 0.0652, 0.8713, 0.0635, 0.8713, f, 3562, Woche, Seite, Frage
t, t, 1, 0, 416.4539, 1178, 1573, 873, 0.3479, 0.4234, 0.2287, 0.4234, f, 1573, Stadt, Arbeit, Welt
g, g, 1, 0, 369.4735, 727, 2307, 94, 0.3026, 0.676, 0.0214, 0.676, f, 2307, Regierung, Entscheidung, Zeitung
r, r, 1, 0, 362.7837, 2421, 336, 394, 0.7634, 0.1102, 0.1264, 0.7634, m, 2421, September, Oktober, November
re, er, 2, 0, 283.5243, 2063, 146, 280, 0.8272, 0.0535, 0.1193, 0.8272, m, 2063, September, Oktober, November
gn, ng, 2, 0, 278.8847, 197, 2301, 57, 0.0941, 0.8921, 0.0138, 0.8921, f, 2301, Regierung, Entscheidung, Zeitung
gnu, ung, 3, 0, 250.8859, 18, 2299, 0, 0.0093, 0.9907, 0, 0.9907, f, 2299, Regierung, Entscheidung, Zeitung
n, n, 1, 0, 234.9137, 671, 1019, 590, 0.297, 0.4714, 0.2316, 0.4714, f, 1019, Million, Information, Region
l, l, 1, 0, 136.552, 585, 175, 445, 0.4508,
@gartenfeld
gartenfeld / ffmpeg_timelapse.sh
Created May 31, 2019 10:04
Generate time-lapse
# 0.1 makes it 10x as fast
ffmpeg -i input.mp4 -filter:v "setpts=0.1*PTS" output.mp4
@gartenfeld
gartenfeld / ffmpeg_gif.sh
Created May 29, 2019 11:36
Video to GIF
# https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
ffmpeg -y -ss 0 -t 12 -i input.mp4 -vf fps=10,scale=320:-1:flags=lanczos,palettegen palette.png
ffmpeg -ss 0 -t 12 -i input.mp4 -i palette.png -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
@gartenfeld
gartenfeld / ffmpeg_cut_video.sh
Last active May 29, 2019 11:24
Cut video with ffmpeg
# -i Input
# -ss Starting timestamp HH:MM:SS.xxx
# -t duration
# https://superuser.com/questions/138331/using-ffmpeg-to-cut-up-video
# https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg
# -c copy
ffmpeg -ss 00:00:05 -i input.mp4 -t 00:00:15 output.mp4
@gartenfeld
gartenfeld / remove_paragon.txt
Created March 9, 2019 13:07
Remove Paragon NTFS suckerware
launchctl remove com.paragon-software.ntfs.notification-agent
sudo launchctl unload -w /Library/LaunchDaemons/com.paragon-software.installer.plist
sudo launchctl unload -w /Library/LaunchDaemons/com.paragon-software.ntfsd.plist
sudo launchctl unload -w /Library/LaunchDaemons/com.paragon-software.ntfs.loader.plist
@gartenfeld
gartenfeld / show_ntfs
Created November 8, 2018 09:42
Enable NTFS drives on Mac
# Append to /etc/fstab
LABEL=DRIVENAME none ntfs rw,auto,nobrowse
@gartenfeld
gartenfeld / wrap_text_nodes.js
Created September 27, 2018 17:20
Recipe for wrapping dangling text nodes with Cheerio
var $head = $('.entry h2.orth');
var $placeholder = $('<div></div>');
var nodes = $head[0].children; // Raw children nodes
// Strange enough this is an object!
// To iterate correctly without dropping nodes
// It must be converted to an array
_.toArray(nodes).forEach(child => {
if (child.type === 'text') {