Skip to content

Instantly share code, notes, and snippets.

@gustavorv86
gustavorv86 / colors.py
Created October 1, 2019 08:03
Print Bash palette color in python
#!/usr/bin/env python3
def colors_16():
print("\n\n8/16 COLORS\n")
buff = ""
for i in range(30, 38):
buff += "\t\033[{}m {}".format(i, i)
print(buff)
@gustavorv86
gustavorv86 / jpg_sort.py
Last active May 16, 2021 23:08
Renamed a lot of JPG files by the taken date
#!/usr/bin/env python3
"""
Author: gustavorv86
Usage: Copy this script into the folder with the JPG files and execute it.
"""
try:
import os
import shutil
import sys
@gustavorv86
gustavorv86 / debian-11-bullseye-sources.list
Last active November 8, 2023 07:06
Debian Bullseye/Oldstable official repositories
deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian-security/ bullseye-security main contrib non-free
deb-src http://deb.debian.org/debian-security/ bullseye-security main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free
@gustavorv86
gustavorv86 / c_string_append.c
Last active August 13, 2019 11:09
String append function written in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_BUF 128
int string_append(char * buffer, size_t buffer_size, const char * string) {
size_t buffer_len = strlen(buffer);
size_t free_size = buffer_size - buffer_len;
size_t string_len = strlen(string);
@gustavorv86
gustavorv86 / c_string_to_int.c
Last active August 13, 2019 11:10
Converts string to integer checking input errors.
/**
* Compile:
* gcc -Wall -Wextra -ggdb c_string_to_int.c -o string_to_int
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int string_to_int(const char * string, int * retval) {
@gustavorv86
gustavorv86 / c_string_trim.c
Last active August 13, 2019 11:02
Function to trimmed string in ANSI C 11
// COMPILE: gcc -std=c11 -Wall -Wextra c_string_trim.c -o string_trim
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
char * string_trim(char * string) {
int s_size = strlen(string);
@gustavorv86
gustavorv86 / number-conversion.py
Last active July 11, 2023 08:26
Graphical user interface (aka GUI) to convert from/to binary, decimal, hexadecimal and IP address using Tkinter python modules.
#!/usr/bin/env python3
import ipaddress
import tkinter
import tkinter.ttk
import tkinter.messagebox
import sys
def bin2dec(value):
@gustavorv86
gustavorv86 / json_utils.py
Created May 22, 2019 06:30
Serialize and deserialize python dictionaries to JSON format.
import json
import sys
def serialize(json_data, json_filename):
try:
json_string = json.dumps(json_data, sort_keys=True, indent=4)
fd = open(json_filename, "w")
fd.write(json_string)
@gustavorv86
gustavorv86 / find_broken_symlinks.py
Created May 17, 2019 06:53
Search broken symbolic links into a directory.
@gustavorv86
gustavorv86 / find_symlinks.py
Created May 17, 2019 06:52
Search symbolic links into a directory.