Skip to content

Instantly share code, notes, and snippets.

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

Jan Baer janbaer

🏠
Working from home
View GitHub Profile
#!/usr/bin/node
const puppeteer = require('puppeteer');
const fs = require('fs');
// Start Chrome with `--remote-debugging-port=9222` and then goto `localhost:9222/json/version` to get the CDP Url
const cdpUrl = 'ws://localhost:9222/devtools/browser/e3ed8a89-ebb3-40f9-a818-fb1738926229';
const newScript = fs.readFileSync('./new_script.sh', 'utf8');
for f in $(ls *.mp4); do
ffmpeg -i $f -c copy -bsf:v h264_mp4toannexb -f mpegts $f.ts
done
CONCAT=$(echo $(ls *.ts) | sed -e "s/ /|/g")
ffmpeg -i "concat:$CONCAT" -c copy -bsf:a aac_adtstoasc output.mp4
rm *.ts
@janbaer
janbaer / mongo-snapshot.sh
Last active August 19, 2022 15:00
LVM Snapshots for MongoDb
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
if [ -z "${MONGO_PASSWORD}" ]; then
echo "You need to set then environment variable MONGO_PASSWORD"
exit 1
@janbaer
janbaer / pastebin.sh
Created January 29, 2021 17:27 — forked from cyrus-and/pastebin.sh
Quick way to pipe data to pastebin.com directly from shell
#!/usr/bin/env bash
# usage: <command> | pastebin [+|++|+++]
#
# (none): paste expires in 10 minutes
# +: paste expires in 1 hour
# ++: paste expires in 1 day
# +++: paste expires in 1 months
HOST='pastebin.com'
@janbaer
janbaer / vscode-launch.json
Last active November 15, 2020 08:38
Debug Jest Tests with VSCode
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"cwd": "${workspaceFolder}",
"args": [
@janbaer
janbaer / find-refs.go
Created November 6, 2020 09:09
Find-Refs - A small Go script to use for services and packages in BU-projects
//usr/bin/env go run $0 $@ ; exit
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
@janbaer
janbaer / javascript-improved-error-handling.js
Last active November 2, 2020 17:31
JavaScript improved error handling
const os = require('os');
class ServerError extends Error {
constructor(message, innerError) {
super();
this.name = this.constructor.name;
this.innerError = innerError;
// Borrowed from: https://stackoverflow.com/questions/35392675/how-to-override-error-stack-getter
Object.defineProperty(this, 'message', {
@janbaer
janbaer / create-docker-volume.sh
Last active June 14, 2020 06:50
Creates an extra Docker volume and mounts it to /va/lib/docker
#!/bin/bash
# Check disksize with `parted /dev/sda print` before
STARTING_SIZE=$1
DISK_SIZE=$2
RESTART_DOCKER=false
if [ -z "${STARTING_SIZE}" ]; then
echo "Please enter the starting size in GB from where the new partition should be created"
@janbaer
janbaer / read-lines-from-a-file.sh
Created January 25, 2019 20:10
Read all lines from the passed file and do something with each line
while IFS='' read -r line || [[ -n "$line" ]]; do
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' $line
done < "$1"
@janbaer
janbaer / rename.sh
Created January 25, 2019 20:08
Rename files that are located in the current directory
for FILE in *.mp4; do
mv "$FILE" "`echo $FILE | sed -r "s/^(.+)_hd-froscon16.+.mp4$/\1.mp4"/`";
done