Skip to content

Instantly share code, notes, and snippets.

View vijinho's full-sized avatar

Vijay vijinho

  • England
View GitHub Profile
@vijinho
vijinho / dlna.sh
Last active July 22, 2024 19:27
A simple DLNA server using rclone, run with "dlna.sh <PORT> <FOLDER>" e.g. dlna.sh 8080 /mnt/shared/music/ - can be run on boot with last line added to 'crontab -e' for root
# ./dlna.sh 8080 /mnt/data/audio
PORT=$1
DATA_DIR=$2
NAME=`basename $DATA_DIR`
CACHE_DIR=/var/cache/dlna/$NAME
#rm -fR $CACHE_DIR
mkdir -p $CACHE_DIR
chmod -fR 777 $CACHE_DIR
/home/linuxbrew/.linuxbrew/bin/rclone serve dlna --addr :$PORT $DATA_DIR --buffer-size 1G --dir-cache-time 24h --cache-dir $CACHE_DIR --vfs-cache-mode full --vfs-cache-max-size 1G --vfs-cache-max-size 16M --no-checksum --no-modtime --vfs-case-insensitive --vfs-disk-space-total-size 4G --name $NAME 2>&1 > /var/log/rclone.log &
exit 0
@vijinho
vijinho / rclonedlna.service
Created September 20, 2020 22:19
Example rclone dlna startup service script on ubuntu/popos. place in "/etc/systemd/system/rclonedlna.service" then "systemctl daemon-reload" then "systemctl enable rclonedlna.service" and it should be up on next reboot.
[Unit]
Description=rclone dlna service
Documentation=man:rclone(1)
After=network.target auditd.service
[Service]
ExecStart=rclone serve dlna --addr :8080 \
--vfs-cache-mode full \
--vfs-cache-max-age 60m \
--vfs-cache-max-size 32768 \
@vijinho
vijinho / rcloned.service
Last active September 20, 2020 21:22
Simple example of running an rcloned sftpd service on ubuntu/popos. place in "/etc/systemd/system/rcloned.service" then "systemctl daemon-reload" then "systemctl enable rcloned.service" and it should be up on next reboot.
[Unit]
Description=rclone sftp service
Documentation=man:rclone(1)
After=network.target auditd.service
[Service]
ExecStart=rclone serve sftp --no-auth --addr :2022 \
--vfs-cache-mode full \
--vfs-cache-max-age 10m \
--vfs-cache-max-size 32768 \
@vijinho
vijinho / win10-backup.sh
Last active January 6, 2025 10:41
Windows 10 backup script to back up the standard windows installation on a give device - USE AT YOUR OWN RISK!!!
# Improved Windows 10 backup script to backup a Windows 10 installation (EFI or MBR) using the /dev/ name, e.g. if on sda run "sh win10backup.sh sda"
PART=$1
# Check if partition is provided
if [ -z "$PART" ]; then
echo "Error: Partition not specified"
exit 1
fi
@vijinho
vijinho / ext4-defrag.sh
Last active January 6, 2025 10:35
Script to unmount, defrag and remount and ext4 filesystem
#!/bin/bash
# Check if the user has provided a device argument
if [ -z "$1" ]; then
echo "Usage: $0 <device>"
exit 1
fi
DEVICE=$1
@vijinho
vijinho / ext4-check-bad-blocks.sh
Last active January 6, 2025 10:32
Unmount a given ext4 filesystem and check it for bad blocks, then remount it
#!/bin/bash
# Check if the user has provided a device or partition argument
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <device>"
exit 1
fi
DEVICE=$1
@vijinho
vijinho / markdown_escape.php
Last active February 13, 2025 16:12
Return a given string with the text markdown escaped, in PHP
<?php
/**
* Escape markdown text
*
* @param string $text The markdown text to escape
*
* @return string Escaped text
*/
function markdown_escape($text) {
// Define a regex pattern for all special characters in markdown
@vijinho
vijinho / macos-set-hostname.sh
Last active January 6, 2025 10:25
script to set the hostname in macOS using scutil for HostName, LocalHostname, ComputerName to the same value
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 <new-hostname>"
exit 1
}
# Check if the user has provided a hostname argument
if [ $# -eq 0 ]; then
@vijinho
vijinho / adb-backup.sh
Last active January 6, 2025 11:32
Backup all Android apps and data using adb, excluding system apps
#!/bin/bash
# Function to handle errors and log them
handle_error() {
echo "Error: $1" >> backup.log
exit 1
}
# Check if adb is available
command -v adb >/dev/null 2>&1 || {
@vijinho
vijinho / transliterate_files.php
Created December 25, 2019 02:48
Display transliterated files and folders to non-accented ASCII characters script - rename feature tested successfully with a filesystem of over 65,000 files - USE AT OWN RISK!
#!/usr/bin/php
<?php
// show and optionally rename files and dirs to transliterated unaccented ascii from current working folder
// 2019-12-24 Vijay Mahrra [email protected]
// code is public domain
define('DEBUG', true); // use pre-generated file list
define('VERBOSE', true);
define('RENAME', false); // allow renaming
define('RENAME_FILES', false);