Skip to content

Instantly share code, notes, and snippets.

View AyresMonteiro's full-sized avatar
✝️

Ayres Monteiro AyresMonteiro

✝️
  • EASYB2B
  • 13:10 (UTC -03:00)
View GitHub Profile
@AyresMonteiro
AyresMonteiro / .bashrc
Created March 29, 2024 14:17
[Debian] Add it to ~/.bashrc and show current git branch on bash
# You need to acquire a copy of that script from git source code
# then place it in your home dir
source ~/git-prompt.sh
COMPLETE_CURRENT_DATE="\D{%F %T}"
CURRENT_DATE="\D{%T}"
YELLOW="\e[33m"
BOLD="\e[1m"
BOLD_YELLOW="\e[1;33m"
BOLD_RED="\e[1;91m"
# Debian Reminders:
- PipeWire must be installed to share screen
- PipeWire needs a bluetooth library to work properly with Bluetooth Headphones
@AyresMonteiro
AyresMonteiro / csv-to-json.js
Created May 29, 2023 21:40
CSV to JSON utilities
const fs = require("fs");
const notEmpty = (line) => line !== "\n";
const trim = (str) => str.trim();
const EOL = /\r/;
const commaReg = /, ?/;
function normalizeProp(prop) {
const splitted = prop
.split(" ")
@AyresMonteiro
AyresMonteiro / json-to-csv.js
Created May 29, 2023 19:18
JSON to CSV Utilities
const fs = require("fs");
function jsonToCSV(data) {
let json = JSON.parse(data);
if (typeof json !== "object") throw new Error("data is not array or object");
if (!Array.isArray(json)) json = [json];
const keys = json.reduce((prev, obj) => {
@AyresMonteiro
AyresMonteiro / countCommits.js
Created July 30, 2022 16:32
[nodejs module] Count commits
const { exec, spawn } = require("child_process");
function execPromise(command) {
return new Promise((resolve, reject) => {
exec(command, (err, stdout, stderr) => {
if (err) reject(err);
resolve({ stdout, stderr });
});
});
@AyresMonteiro
AyresMonteiro / README.md
Last active December 15, 2021 16:52
Redes

Gist de Conteúdos de Rede

Um repositório de estudos com conteúdos de redes.

@AyresMonteiro
AyresMonteiro / move.sh
Last active December 1, 2021 17:15
Creates directories with the same name of the files and moves files inside them (Shell script)
#!/bin/bash
# The line above is a shebang. You can read more about it at https://en.wikipedia.org/wiki/Shebang_(Unix).
# Goes to base dir
cd ~/your/dir
# Iterate over directories in base directory.
for dir in *
do
# For each directory, iterate over files.
@AyresMonteiro
AyresMonteiro / validateCNPJ.php
Created October 2, 2021 20:52
A PHP Function that validates Brazil's CNPJ
<?php
function validateCNPJ($cnpj)
{
$parsedCNPJ = preg_replace("/[.\/-]/", "", $cnpj);
if (!preg_match("/^\d{14}$/", $parsedCNPJ)) {
return false;
}