Skip to content

Instantly share code, notes, and snippets.

@movalex
movalex / removecompletedtorrents.sh
Created June 14, 2016 22:48 — forked from bulljit/removecompletedtorrents.sh
Transmission-Daemon: Remove Completed Torrents
#!/bin/sh
# script to check for complete torrents in transmission folder, then stop and move them
# either hard-code the MOVEDIR variable here…
MOVEDIR=/home/mjdescy/media # the folder to move completed downloads to
# …or set MOVEDIR using the first command-line argument
# MOVEDIR=%1
# use transmission-remote to get torrent list from transmission-remote list
# use sed to delete first / last line of output, and remove leading spaces
# use cut to get first field from each line
@movalex
movalex / Blocker_update.sh
Last active April 17, 2018 07:19 — forked from jhochwald/Blcoker_update.sh
Cron to update the IPTables Blocker
#!/usr/bin/env bash
# Cron to update the IPTables Blocker
# Now works with Raspberry Pi Raspbian Jessy
# Define some defaults
IPTABLES='/sbin/iptables'
BLOCKLIST='/tmp/enatec_blocked.txt'
# Get the latest List
@movalex
movalex / python.vim
Created April 10, 2019 10:37 — forked from mdzhang/python.vim
Vim - SQL highlighting in Python strings
" Put this in ~/.vim/after/syntax/python.vim
" Slight tweaks to https://lonelycoding.com/can-i-use-both-python-and-sql-syntax-highlighting-in-the-same-file-in-vim/
" Needed to make syntax/sql.vim do something
unlet b:current_syntax
" Load SQL syntax
syntax include @SQL syntax/sql.vim
@movalex
movalex / toggle_swap.sh
Last active September 6, 2022 09:18 — forked from Jekis/toggle_swap.sh
Empty swap. Clear swap. Move swap to RAM. Ubuntu.
#!/bin/bash
function calc_percentage () {
mem="$1"
total="$2"
if [[ $mem -gt 0 ]]; then
return $((mem * 100 / total))
else
return 0
fi
@movalex
movalex / tar_with_progressbar.md
Last active September 22, 2020 21:22
Tar zipping with progressbar on MacOS
  1. install pv with Homebrew

    brew install pv

  2. create tar archive, enjoy this nice progressbar

    tar cf - ./FONTS -P | pv -s $(($(du -sk ./FONTS | awk '{print $1}') * 1024)) | > FONTS.tar

  3. the output will be like:

@movalex
movalex / rename_files_to_uuid.py
Last active March 28, 2021 21:06
UUID Random File renamer
import uuid
import os
import sys
EXT_LIST = [".jpg"]
def rename_file(path):
path = os.path.abspath(path)
print("Renaming...")
@movalex
movalex / uvpn.sh
Created October 11, 2021 18:38
Start VPN Unlimited with Bash script
function uvpn() {
SECRET=$VPN_SECRET
status_vpn=$(scutil --nc list | awk '{if (NR!=1) print$2}' | sed -e 's/[()]//g')
if ! [[ $status_vpn ]]; then
echo "no VPN settings found"
return
fi
vpnName=$(scutil --nc list | awk 'BEGIN {ORS=" "}; {if (NR!=1) for(i = 7;i <= NF-1; i++) print$i}' | sed -e 's/"//g')
vpnID=$(scutil --nc list | awk '{if (NR!=1) print$3}')
@movalex
movalex / batch_mkdir.ps1
Last active August 3, 2023 15:50
Batch to create folders Windows Powershell
mkdir $(0..9 | % tostring 000 | %{"VGM_$_"+"0"})

Compile Samba on macos 12 (Monterey)

git clone https://git.samba.org/samba.git

brew install cmake gnutls jansson libarchive openssl pkg-config python@3.11
brew install readline && brew link --force readline

export CPPFLAGS="-I/usr/local/opt/libarchive/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@3/include"
export LDFLAGS="-L/usr/local/opt/libarchive/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl@3/lib"
@movalex
movalex / win-125x.lua
Created February 26, 2023 21:02 — forked from Egor-Skriptunoff/win-125x.lua
String converter between Windows ANSI and UTF-8 encodings
---------------------------------------------------------------------
-- Converter between win-125x and UTF-8 strings
---------------------------------------------------------------------
-- Written in pure Lua, compatible with Lua 5.1-5.4
-- Usage example:
-- require("win-125x")
-- str_win = utf8_to_win(str_utf8)
-- str_utf8 = win_to_utf8(str_win)
---------------------------------------------------------------------