Skip to content

Instantly share code, notes, and snippets.

@movalex
movalex / rename_using_tags.py
Last active August 3, 2023 14:41
Rename files based on Windows file tag
from pathlib import Path
import os
import shutil
from win32com.propsys import propsys
FOLDER = Path(".")
OUTPUT = "TEL"
pk = propsys.PSGetPropertyKeyFromName("System.Keywords")
@movalex
movalex / get_latest_gitlab_release.sh
Last active July 21, 2023 12:17
Get latest GitLab release
apk add --no-cache curl jq
PROJECT_ID=47716115
curl https://gitlab.com/api/v4/projects/$PROJECT_ID/releases/ | jq '.[]' | jq -r '.tag_name' | head -1
@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)
---------------------------------------------------------------------

Compile Samba on macos 12 (Monterey)

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

brew install cmake gnutls jansson libarchive openssl pkg-config [email protected]
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 / batch_mkdir.ps1
Last active August 3, 2023 15:50
Batch to create folders Windows Powershell
mkdir $(0..9 | % tostring 000 | %{"VGM_$_"+"0"})
@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 / 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 / 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 / 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 / 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