Skip to content

Instantly share code, notes, and snippets.

View Athesto's full-sized avatar

Gustavo Adolfo Mejía Sánchez Athesto

View GitHub Profile
#!/usr/bin/env bash
##
# NAME
# script-template - this is a template for script functions
#
# SYNOPSIS
# cmd <subcommand> <args>
#
# DESCRIPTION
#!/usr/bin/env bash
LINUX_URL="https://github.com/neovim/neovim/releases/download/stable/nvim.appimage"
command -v curl 1>/dev/null || { echo "curl not found"; exit; }
curl -sfLo appimage $LINUX_URL || { echo "neovim not found"; exit; }
chmod u+x appimage
./appimage --appimage-extract 1>/dev/null
cp squashfs-root/usr/bin/nvim nvim
rm -rf appimage squashfs-root
chmod u+x nvim
@Athesto
Athesto / venv
Last active September 11, 2021 23:47
venv is a python's virtual env manager.
#!/usr/bin/env bash
# VERSION=0.2.3
# shellcheck disable=SC1090
# VARIABLES ----------------------------------
INSTALLATION_DIR="$HOME/.venv"
# --------------------------------------------
function main()
{
@Athesto
Athesto / myPS1
Last active September 23, 2022 16:55
PS1 edition
#!/usr/bin/env bash
COLOR1='RASPBERRY1'
COLOR2='RASPBERRY2'
SCREEN_THRESHOLD=110
declare -A CODES4=(\
#4-BIT
['RED']=31 ['GREEN']=32 ['YELLOW']=33 ['BLUE']=34
@Athesto
Athesto / termux-refresh-hostname
Created May 12, 2021 21:25
This a script update the /etc/hosts with the ip of your termux
#!/usr/bin/env bash
#include here the MAC-ADDRESS of your termux
TERMUX_MAC="<your-termux-mac-address>"
SEARCH_MAX=64
type nmap &>/dev/null ||\
{ echo "this script need nmap, please install it first"; exit 1; }
sudo nmap -sn "$(hostname -I | cut -d' ' -f1)"-"$SEARCH_MAX" 1> /dev/null
@Athesto
Athesto / pdir.py
Last active May 9, 2021 00:59
pretty dir, changes the visualization for the dir command
#!/usr/bin/python3
"""
pdir is a pretty print function for the dir() command
"""
from cmd import Cmd
from re import match
import os
__version__ = "0.0.1"
@Athesto
Athesto / commands.sh
Last active April 26, 2021 16:58
Bash commands
#!/usr/bin/env bash
#check output of ./a.out and checker_file
./a.out | diff - checker_file
#create main files
echo {0..10}-main.c
#touch File1, File2, File3 and remove the ,
echo "File1, File2, File3" | tr -d , | xargs touch
@Athesto
Athesto / 16-track_origins.c
Last active April 11, 2021 23:14 — forked from gaul/gist:5306774
Demonstrate Valgrind --track-origins
/*
* run this command in terminal
* $ gcc -g 16-track_origins.c && valgrind -q ./a.out 2> a && valgrind -q --track-origins=yes ./a.out 2> b && vimdiff a b
* run this command in a buffer and b buffer of vimdiff and don't forget to change <pidNum> by the pid of the buffer
* :%s/<pidNum>/xxxx/g
*
*/
#include <stdio.h>
#include <stdlib.h>
@Athesto
Athesto / docker-login
Last active April 7, 2021 12:15
docker-login
#!/usr/bin/env bash
CONTAINER="${1-main}"
ENTRYPOINT="${2-bash}"
docker start "${CONTAINER}"
docker exec -ti "${CONTAINER}" "${ENTRYPOINT}"
@Athesto
Athesto / gitacp
Created March 23, 2021 18:37
git add commit and push
#!/usr/bin/env bash
git add "$1"
git commit -m "$2"
git push origin "$(git branch | grep \* | cut -d' ' -f2)"