Skip to content

Instantly share code, notes, and snippets.

View ahwayakchih's full-sized avatar
🏠
Working from home

Marcin Konicki ahwayakchih

🏠
Working from home
View GitHub Profile
@ahwayakchih
ahwayakchih / nodebb-import-custom-pre-parse-conversion.js
Created February 17, 2021 17:47
Custom function for converting posts content from IPBoard to NodeBB using nodebb-plugin-import module
// Custom convert function for nodebb import plugin
content = content && encoding.convert(content, 'utf8', 'ISO-8859-2');
content = content && content.toString('utf8');
// This depends on changes implemented in https://github.com/ahwayakchih/nodebb-plugin-import/tree/feat-pass-type-and-id-to-custom-js
// It also assumes that HTML-to-Markdown conversion will be enabled too
// This is quite slow. Regexes probably could be optimized a bit, but it's a one-time-use-and-forget operation, so not much point i guess
if (type == 'post') {
content = content && content
.replace(/<!--quoteo\(post=(\d+)[^)]+name=([^):]+)[\w\W]+?<a\s+href="([^"]+)"[\w\W]+?<!--quotec-->([\w\W]+?)<!--QuoteEnd-->[\w\W]+?<!--QuoteEEnd-->/g, (m, pid, name, link, text) => {
@ahwayakchih
ahwayakchih / cp2bfs
Created April 21, 2021 10:18
Copy a single file or directory into BFS disk image
#!/bin/sh
# Simple script that mounts specified BFS disk image file to temporary directory,
# copies specified file there, unmounts the image and removes temporary directory.
# Usage: cp2bfs my-file-to-copy my-test-disk.bfs
MOUNTDIR=
FROM=$1
BFSFILE=$2