Skip to content

Instantly share code, notes, and snippets.

View airvzxf's full-sized avatar

Israel Roldan airvzxf

View GitHub Profile
@airvzxf
airvzxf / terminal-colors.bash
Last active August 29, 2023 00:19
Show the terminal colors.
#!/usr/bin/env bash
# Change the font styles and the background color:
declare -a FIRST_POSITION=(0 1 2 4 5 6 8 9)
declare -a SECOND_POSITION=(30 31 32 33 34 35 36 37
40 41 42 43 44 45 46 47
90 91 92 93 94 95 96 97
100 101 102 103 104 105 106 107)
# To change the colors of the foreground and background, uncomment the variables:
@airvzxf
airvzxf / github-remove-and-make-release.bash
Created August 6, 2023 07:42
In GitHub it remove all the actions, tags and releases. Furthermore, it create a new release. It use the 'gh' command-line tool.
#!/usr/bin/env bash
set +xve
RELEASE_TAG='v1.0.0'
REPOSITORY_ID='airvzxf/archlinux-brightness-xrandr'
GITHUB_ACTIONS=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
@airvzxf
airvzxf / ls-chars.bash
Last active July 28, 2023 20:29
Given a font, it will display all the character sets it contains.
#!/usr/bin/env bash
# Thanks for this code Lu Xu.
# https://stackoverflow.com/a/60475015/1727383
# Make this file executable.
# chmod u+x ls-chars.bash
# Usage:
# ./ls-chars.bash "FontAwesome"
@airvzxf
airvzxf / xmllint-xmlns-solution.bash
Last active July 25, 2023 15:09
xmllint xmlns error using the XPath
#!/usr/bin/env bash
set -vx
# chmod u+x xmllint-xmlns-solution.bash
# Execute: ./xmllint-xmlns-solution.bash
# DESCRIPTION
# The xmllint program parses one or more XML files, specified on the command line as XML-FILE (or the standard input if the
# filename provided is - ). It prints various types of output, depending upon the options selected. It is useful for detecting
# errors both in XML code and in the XML parser itself.
@airvzxf
airvzxf / match-words-in-phrases.py
Last active March 3, 2023 21:56
Match words in phrases. If the words is in the phrase returns true and print the phrase, otherwise it return false and print anything.
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Given a text, it detects a serie of words and return true if it finds some of these.
"""
def match_words(text: str, words: list) -> bool:
"""
Detect if the text contains the words from the first and second list.
#include <sys/socket.h> // For socket functions
#include <netinet/in.h> // For sockaddr_in
#include <cstdlib> // For exit() and EXIT_FAILURE
#include <iostream> // For cout
#include <unistd.h> // For read
// Compile: `g++ main.cpp -o web-service-c`
// Usage: `telnet localhost 8002`
int main() {
// Create a socket (IPv4, TCP)
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Convert String into Array of Strings.
"""
from http import server
from socketserver import ThreadingMixIn
from hello_world import hello, world
#include <iostream>
#include <cstring>
void string_split(const char *text, const char *delimiter, char *tokens[10]);
int main() {
// Convert String into Array of Strings.
// Managing memory is usually a feat.
// Furthermore, execute in terminal: `g++ main.cpp -o strings-c`.
const char *text = "a/apple/arm/basket/bread/car/camp/element/...";
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Convert String into Array of Strings.
"""
from doctest import testmod
# Press CTR+Q to see the documentation.
def string_split(text: str, delimiter: str) -> list[str]:
#include <iostream>
#include <cstring>
int main() {
// Convert String into Array of Strings.
// Managing memory is usually a feat.
// Furthermore, execute in terminal: `g++ main.cpp -o strings-c`.
const char *text = "a/apple/arm/basket/bread/car/camp/element/...";
char split_char = '/';
char *token, *str, *toFree;