This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Process arguments spoofing in GNU/Linux. | |
* | |
* Hide program arguments by overwriting them with null. | |
* | |
* You can read my full post here: https://rubenhortas.github.io/posts/process-argument-spoofing-gnu-linux/ | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias b64urlencode='python3 -c "import sys, base64; print(base64.urlsafe_b64encode(bytes(sys.argv[1], \"UTF-8\")).decode(\"UTF-8\"))"' | |
alias b64urldecode='python3 -c "import sys, base64; print(base64.urlsafe_b64decode(bytes(sys.argv[1], \"UTF-8\")).decode(\"UTF-8\"))"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias urldecode='python3 -c "import sys, urllib.parse as parse; print(parse.unquote_plus(sys.argv[1]))"' | |
alias urlencode='python3 -c "import sys, urllib.parse as parse; print(parse.quote_plus(sys.argv[1]))"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Encodes/decodes a string to/from base64url. | |
print_help() { | |
echo "Usage: $(basename "$0") [-d] STRING" | |
echo | |
echo "Without -d encodes the string to base64url." | |
echo | |
echo " -d decodes the string from base64url (or base64)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Adjust the screen brightness modifying directly the gnome settings daemon power. | |
# To use this script you just have to save it in a path with execution permissions and assign the commands "brightnessControl up" and "brightnessControl down" to the keys using shortcuts. | |
# There's a better way to do this: install xdotool and assign the commands “xdotool key XF86MonBrightnessUp” and “xdotool key XF86MonBrightnessDown” to the brightness keys. | |
# With this solution the brightness indicator will come out on screen when we change the brightness. | |
# Arguments | |
way="$1" # Up or Down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Implement a progress bar using using tqdm. | |
""" | |
from tqdm import tqdm | |
from time import sleep | |
if __name__ == '__main__': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Script that looks for programs consuming CPU above a certain threshold and logs the results. | |
""" | |
from types import FrameType | |
from psutil import cpu_percent, process_iter, NoSuchProcess, AccessDenied, ZombieProcess | |
from signal import signal, SIGINT | |
from datetime import datetime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A good example of a Python program that can put the CPU at 100% usage involves creating a CPU-intensive task | |
and then distributing this task across all CPU cores using the multiprocessing module. | |
""" | |
import math | |
import multiprocessing | |
from concurrent.futures import ProcessPoolExecutor | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Code to find all the permutations that solve the math puzzle for third graders from the image. | |
You're supposed to fill the blanks with the numbers 1 through 9 using each digit once. | |
Usage: | |
- Compile: gcc -O3 mathPyzzleForThirdGraders.c -o mathPyzzleForThirdGraders.out | |
- Run: ./mathPyzzleForThirdGraders.out | |
*/ |