Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rolfen
rolfen / crawler.js
Last active March 29, 2024 20:00
Javascript Console (in-browser) based crawler
let getElement, crawlDom, getCats, save, rowify; // functions
let urlBase, pages; // input data
// config
let waitInterval = 500; // how much to wait between fetching pages
// selectors
let catRe = /\{\s*productcategories\s*\:\s*(\[\s*\{[\s\S]*\}\s*\])\s*\}/m;
let selectors = {
'name' : '#showroomTopContentDiv .showroom-header h1',
@rolfen
rolfen / archive.bash
Last active February 29, 2024 11:49
Extract previews and metadata from original photos and videos. Archive and backup.
#!/bin/bash
# Import and organize into subfolders by date taken (YYYY/MM/DD)
scriptname=`basename "$0"`
if [[ $# -ne 2 ]]; then
echo "Usage: $scriptname /source/dir /archive/dir"
else
(cd "$2"; exiftool -progress -ext MTS -ext ARW -ext ORF -ext xmp -r -m -d %Y/%m/%d "-Directory<DateTimeOriginal" "$1")
@rolfen
rolfen / flatten.md
Created April 26, 2022 11:00
Flatten subdirectories (Linux)

This

find -type f -exec mv {} ./ \;

turns this

/folder
@rolfen
rolfen / _README.md
Last active April 9, 2021 05:33
Resume a dd operation with a check

This little script resumes an interrupted dd copy at a given offset.

Before resuming, it rolls back (the amount of roll-back is OVERLAP_SIZE * CHUNK) then calculate the checksum of the overlap on both files to make sure that they are valid images of each other.

The checksums have to be checked manually by the operator (todo: automate).

Setting up multiple user write permission to WWW directory

addgroup www-admin
adduser joe
adduser www-admin joe
setfacl -R -m g:www-admin:rwx /var/www
setfacl -R -m -d g:www-admin:rwx /var/www
chmod -R g+s /var/www
@rolfen
rolfen / CheatCheet.md
Last active February 4, 2021 20:43
MyArchive

Warning These are for educative purposes (examples, tips, etc.). Do not blindly execute them.

Fix double separator in hash-file (double or more space -> single space)

cat meta/hash-file.list | sed -E 's/^(\S+)\s{2,}(\S.+)$/\1 \2/'

Fix windows newlines in file

@rolfen
rolfen / ADB_remote_wifi.md
Last active March 6, 2020 11:51
Remote (wifi) control your android device through ADB

You will need to connect your phone first, using USB.

With the USB cable:

adb tcpip 5555

Find out the IP address of your phone

@rolfen
rolfen / DeutscheWörter.md
Last active January 24, 2021 09:26
German Words
De En
störrischer stubborn
bemühunngen efforts
vorübergehend temporarily
verdrangen to displace
Einschätzung assessment
fällig due
Gegenstand object
Reichweite reach
@rolfen
rolfen / EMAIL.md
Last active August 18, 2018 13:27
Setting up a Linux server
@rolfen
rolfen / MySqlExportBlob.md
Last active May 22, 2019 10:41
Exporting multiple blobs/images from an SQL database

Exporting multiple blobs from an SQL database.

This is tested for MySQL with Linux or OSX

I was in a situation where I had images saved into an SQL table, as "blobs" and needed to export them into proper jpg files.

This relies on the SQL syntax SELECT INTO DUMPFILE. However this command can only export one row at a time.

1. Get the IDs of the rows we want to export