Skip to content

Instantly share code, notes, and snippets.

View dwin's full-sized avatar
🎯
Focusing

Darwin Smith dwin

🎯
Focusing
View GitHub Profile
@dwin
dwin / bookIndex.js
Created October 2, 2015 17:32
Function that given a sorted array of page numbers, returns a string representing a book index. Combines consecutive pages to create ranges. Given [1,3,4,5,7,8,10] it should return the string “1, 3-5, 7-8, 10”.
var arr = [1,2,3,5,8,10,11,12,15]
function bookIndex(arr) {
var temp = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i]+1 == arr[i+1]) {
var start = arr[i];
while (arr[i]+1 == arr[i+1]) {
i++;
}
@dwin
dwin / accesslog2csv.pl
Created September 2, 2021 03:07 — forked from sepehr/accesslog2csv.pl
Perl: Convert Apache access log to CSV
#!/usr/bin/perl
#
# @file
# Converter tool, from Apache Common Log file to CSV.
#
# All code is released under the GNU General Public License.
# See COPYRIGHT.txt and LICENSE.txt.
#
@dwin
dwin / Instructions.md
Created March 14, 2023 21:16
Duplicacy Install as Linux Service

Installing Duplicacy as a Service on Linux

Ubuntu 22.04 LTS

Using Download link from https://duplicacy.com/download.html

Download and Verify Duplicacy web binary.

wget https://acrosync.com/duplicacy-web/duplicacy_web_linux_x64_1.6.3 -O duplicacy_web
@dwin
dwin / convert.sh
Created January 6, 2019 08:41
Convert all Plex DVR recordings in directory to HEVC/x265
#!/bin/sh --
# Make executable and Run in directory containing files?
# Convert all '.ts' files in directory using ffmpeg using nvidia hardware hevc(x265) encoding, maintain orginal audio
# and extract subtitles/closed-caption as '.srt' to current directory.
# Start looping over files, tell what we do and log any output to screen and log.
for MPEG in *.ts; do echo "Starting ${MPEG}"
ffmpeg -i "${MPEG}" -c:a copy -c:v hevc_nvenc -b:v 3000k -minrate 1000k -maxrate 8000k -level 4.1 -tag:v hvc1 -preset slow -rc-lookahead 32 -movflags faststart "${MPEG%.ts}.mp4" 2>&1 | tee -a "conversion.log"
# If ffmpeg exited OK, then say it and move the original to the backup directory.
if [ $? -eq 0 ]; then