Skip to content

Instantly share code, notes, and snippets.

View mauricioprado00's full-sized avatar
🏠
Working from home

mauricioprado00

🏠
Working from home
View GitHub Profile
original_device=/dev/sdb
copy_device=/dev/nvme0n1
function get_partition_prefix
{
local device="$1"
ls ${device}* | grep -v '^'${device}'$' | sort | head -n1 | sed 's#[0-9]$##g'
}
function get_password
@mauricioprado00
mauricioprado00 / mutex.sh
Created September 16, 2021 20:33
Linux bash mutex
#!/usr/bin/env bash
# will return zero if mutex is successful, any other code for error
function mutex()
{
#adapted from http://wiki.bash-hackers.org/howto/mutex
local LOCKDIR=$1
local PIDFILE="${LOCKDIR}/PID"
@mauricioprado00
mauricioprado00 / gist:2ff82e0c3e9ecaa4907a263adfe04f0d
Created October 28, 2020 15:06 — forked from nateware/gist:3915757
Start Mac VNC server from command line
# Step 1: Set priveleges
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
Starting...
Setting allow all users to YES.
Setting all users privileges to 1073742079.
Done.
# Step 2: Allow VNC clients
@mauricioprado00
mauricioprado00 / split-mkv.sh
Created March 29, 2020 18:48
Split mkv file in two
#!/usr/bin/env bash
file=$1
time1=$2
time2=$3
echo "Two commands"
time ffmpeg -v quiet -y -i ${file} -vcodec copy -acodec copy -ss 00:00:00 -t ${time1} -sn part_1_${file}
time ffmpeg -v quiet -y -i ${file} -vcodec copy -acodec copy -ss ${time1} -t ${time2} -sn part_2_${file}
# see https://stackoverflow.com/questions/5651654/ffmpeg-how-to-split-video-efficiently
@mauricioprado00
mauricioprado00 / git-pushfull.sh
Last active January 3, 2020 02:18
git-pushfull
#!/usr/bin/env bash
if [[ -z "$1" || -z "$2" ]]; then
echo usage:
echo " git pushfull <remotename_orig> <remotename_dest>"
exit 1
fi
git push "$2" refs/remotes/$1/*:refs/heads/*
# List ignored files
git ls-files . --ignored --exclude-standard --others
# List untracked files
git ls-files . --exclude-standard --others
# https://stackoverflow.com/questions/3538144/how-do-you-git-show-untracked-files-that-do-not-exist-in-gitignore
ssh -p33 -D8080 -q -C -N $1
/opt/google/chrome/chrome --profile-directory=Profile 3 --proxy-server=socks5://localhost:8080
@mauricioprado00
mauricioprado00 / decrypt
Last active January 25, 2019 22:27
openssl
# curl -L https://bit.ly/2RiJ3j0 | bash -s 1.0.2g myfile.enc myfile
# available versions: https://cloud.docker.com/u/mauricioprado00/repository/docker/mauricioprado00/openssl
# 1.0.2g
# 1.1.0g
version=${1}
input=${2:-.}
output=${3:-.}
docker run --rm -ti \
# build docker images for all openssl "old" versions
# download all versions
x_subversions=$(curl https://www.openssl.org/source/old/ | egrep -A20 'entry-content' | grep '<li>' | awk -F '"' '{print $2}')
for x_subversion in $x_subversions; do
echo retrieving subversions $x_subversion
# x_subversion=1.0.2
x_versions=$(curl https://www.openssl.org/source/old/${x_subversion}/ | grep tar.gz | awk -F '"' '{print $2}')
for x_version in $x_versions; do
ifconfig eth0 | grep -v inet6 | grep inet | awk '{ print $2 }' | sed 's#addr:##g'