Skip to content

Instantly share code, notes, and snippets.

@rojenzaman
rojenzaman / gist:63597da2a52e8733d6e502672da3b082
Created June 13, 2021 21:47 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@rojenzaman
rojenzaman / rmzero.sh
Created June 9, 2021 10:09
BASH script to write zeros to file before remove | Use for non-secure HDD
#!/bin/bash
# use find exec to remove multiple files:
# find path/to/dir -exec ./rmzero {} \;
if [ "$#" -lt 1 ]; then
echo "./`basename $0` <file>";
exit 1;
fi
function load() { FILE="$(realpath $1)" ; MB_COUNT="$(du -m $FILE | awk '{print $1}')" ; }
@haise0
haise0 / kdzextraction.md
Last active August 31, 2025 07:34
A guide to extracting LG KDZ firmware update files in order to unpack the super.img held therein.

Extracting KDZs and their super.img partition held within

LG KDZ formats are a pain in the ass. Various tools and scripts have been made for the extraction of said KDZs; not many, if any at all, work with the current KDZ format (v3).

The script mentioned below for extraction should work with all three formats, i.e old, older, and new.

Prerequisites

  • Windows (preferably with WSL), or Linux/Mac with a Windows VM
    • NOTE: Unfortunately I am not yet aware of a method for Unix systems that does not require a VM or Wine for the time being. Looking into the 7zip method of extraction may fix this.
  • Python 3 and Pip
@hydrastro
hydrastro / send_mail.sh
Last active October 22, 2021 13:18
Bash SMTP(/S) authentication and mailsending script
#!/bin/bash
smtp_address=""
smtp_username=""
smtp_password=""
smtp_server=""
smtp_port=587
use_starttls=true
send_mail() {
@iscgar
iscgar / kdz.py
Last active December 25, 2025 16:35
A correct extractor for LG's KDZ Android image files
# A simple and correct LG KDZ Android image extractor, because I got fed up
# with the partially working one from kdztools.
#
# Copyright (c) 2021 Isaac Garzon
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@modest
modest / twowayrsync
Created March 2, 2021 07:10
Two-way folder sync with rsync - Inefficient but portable
#!/usr/bin/env bash
remoteuser="$1"
remotehost="$2"
remotedir="$3"
localdir="$4"
syncstatusfile=".lastsync"
if [[ ! -d "$4" ]]; then
@devadvance
devadvance / part_video_to_gif.sh
Created February 28, 2021 03:10
Create animated GIF and WebP from videos using ffmpeg
ffmpeg -ss $INPUT_START_TIME -t $LENGTH -i $INPUT_FILENAME \
-vf "fps=$OUTPUT_FPS,scale=$OUTPUT_WIDTH:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
-loop $NUMBER_OF_LOOPS $OUTPUT_FILENAME
# Change these placeholders:
# * $INPUT_START_TIME - number of seconds in the input video to start from.
# * $LENGTH - number of seconds to convert from the input video.
# * $INPUT_FILENAME - path to the input video.
# * $OUTPUT_FPS - ouput frames per second. Start with `10`.
# * $OUTPUT_WIDTH - output width in pixels. Aspect ratio is maintained.
@rojenzaman
rojenzaman / dynmotd
Created January 9, 2021 22:06
Raspberry Pi OS dynamic motd
#!/bin/bash
# Installation:
#
# 1. nano /etc/ssh/sshd_config
# PrintMotd no
#
# 2. nano /etc/profile
# /usr/bin/dynmotd # Place at the bottom
#
@rojenzaman
rojenzaman / termux.sh
Created December 22, 2020 09:55
termux env into adb shell
#!/system/bin/sh
export PREFIX='/data/data/com.termux/files/usr'
export HOME='/data/data/com.termux/files/home'
export LD_LIBRARY_PATH='/data/data/com.termux/files/usr/lib'
export PATH="/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:$PATH"
export LANG='en_US.UTF-8'
export SHELL='/data/data/com.termux/files/usr/bin/bash'
cd "$HOME"
exec "$SHELL" -l
@syanle
syanle / ss.sh
Created December 22, 2020 05:24
shadowsocks+kcptun
#!/bin/bash
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -qy shadowsocks-libev
cat>/etc/systemd/system/shadowsocks-server.service<<EOF
[Unit]
Description=Shadowsocks Server