Skip to content

Instantly share code, notes, and snippets.

Avatar
🐧
➜ ~ echo "Hello, World\!" | lolcat

Telmo "Trooper" telmotrooper

🐧
➜ ~ echo "Hello, World\!" | lolcat
View GitHub Profile
@telmotrooper
telmotrooper / git-aliases.sh
Last active Oct 17, 2020
POSIX-compliant commands to automate common Git tasks
View git-aliases.sh
# Create a new branch based on the current one and push it to the remote.
function gcob {
echo "You're on branch \"$(git branch --show-current)\"."
git pull
echo "Creating branch with name \"$1\"."
git checkout -b $1
echo "Pushing branch to remote."
git push --set-upstream origin $1
}
View .tmux.conf
# Remap prefix from 'Ctrl + B' to 'Ctrl + A'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
@telmotrooper
telmotrooper / deploy.sh
Last active May 31, 2019
POSIX-compliant deploy function
View deploy.sh
function deploy {
deploy_dir=/home/telmo/Development/deploy-scripts
if [ $1 = "frontend" ] || [ $1 = "front" ] || [ $1 = "f" ]; then
sh "$deploy_dir/deploy_frontend.sh"
elif [ $1 = "backend" ] || [ $1 = "back" ] || [ $1 = "b" ]; then
sh "$deploy_dir/deploy_backend.sh"
else
(>&2 echo "ERROR: \"$1\" doesn't match any known parameter.")
return 1
@telmotrooper
telmotrooper / lse
Created May 21, 2019
ls separated by extensions
View lse
#!/usr/bin/bash
extensions=$(ls -l | awk '{print $9}' | cut -f 2-99 -d '.' | uniq)
for ext in $extensions
do
echo "-- $ext --"
ls -l | grep ".$ext" | awk '{print $9,$5}' | column -t -s " "
done
@telmotrooper
telmotrooper / https-server.py
Created Jul 25, 2018
Simple HTTPS Server in Python 3
View https-server.py
#!/usr/bin/env python3
# Ported to Python 3 by Telmo "Trooper" (telmo.trooper@gmail.com)
#
# Original code from:
# http://www.piware.de/2011/01/creating-an-https-server-in-python/
# https://gist.github.com/dergachev/7028596
#
# To generate a certificate use:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
@telmotrooper
telmotrooper / batchRename.py
Created Jul 8, 2018
Batch file/folder renamer without regular expressions
View batchRename.py
from os import listdir, rename
from os.path import join, isdir
from readline import parse_and_bind
def main():
print("Batch Rename - Developed by Telmo H. V. Silva")
print("-" * 50)
parse_and_bind("control-v: paste")
@telmotrooper
telmotrooper / share_wifi.sh
Created May 26, 2018
Share your Wi-Fi connectiong through cable
View share_wifi.sh
# Based on tutorial at:
# https://null-byte.wonderhowto.com/how-to/share-your-laptops-wireless-internet-with-ethernet-devices-0130528/
# Bring your ethernet interface up and assign an IP to it
sudo ifconfig enp7s0 up
sudo ifconfig enp7s0 192.168.2.1
# Enable IPv4 forwarding
sudo echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward
View sudoku.py
class Sudoku:
"""Sudoku validator"""
grid = [[0] * 9 for i in range(9)]
def __init__(self):
self.populate_grid()
self.print_grid()
self.validate_grid()
@telmotrooper
telmotrooper / getpid.sh
Created Apr 30, 2017
Get Process ID by clicking on it
View getpid.sh
xprop _NET_WM_PID | cut -d' ' -f3
@telmotrooper
telmotrooper / wwwappender.py
Created Apr 30, 2017
Simple script to help appending the "www." prefix to entries in your hosts file
View wwwappender.py
from shutil import copyfile
copyfile("in.txt", "out.txt")
inputFile = open("in.txt", "r")
outputFile = open("out.txt", "a")
outputFile.write("\n\n")
for line in inputFile.readlines():