Skip to content

Instantly share code, notes, and snippets.

Avatar

David Rosson gartenfeld

View GitHub Profile
@gartenfeld
gartenfeld / mac_dictionary.sh
Created Jul 12, 2020
Search for word patterns
View mac_dictionary.sh
egrep ".*word$" /usr/share/dict/words
View jwt_user.js
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 Oct 5, 2019
German Word-Final N-Grams
View de_word_final_ngrams.csv
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
View ffmpeg_timelapse.sh
# 0.1 makes it 10x as fast
ffmpeg -i input.mp4 -filter:v "setpts=0.1*PTS" output.mp4
View ffmpeg_gif.sh
# 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
Cut video with ffmpeg
View ffmpeg_cut_video.sh
# -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 Mar 9, 2019
Remove Paragon NTFS suckerware
View remove_paragon.txt
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 Nov 8, 2018
Enable NTFS drives on Mac
View show_ntfs
# Append to /etc/fstab
LABEL=DRIVENAME none ntfs rw,auto,nobrowse
@gartenfeld
gartenfeld / wrap_text_nodes.js
Created Sep 27, 2018
Recipe for wrapping dangling text nodes with Cheerio
View wrap_text_nodes.js
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') {
@gartenfeld
gartenfeld / readline.js
Created Nov 26, 2017
Read a file one line at a time
View readline.js
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const FILE_PATH = path.resolve(__dirname, '../data/ingest_test.txt');
const stream = fs.createReadStream(FILE_PATH);
const interface = readline.createInterface({ input: stream });
interface.on('line', processLine);
interface.on('close', () => console.log("\nDone!"));