Um repositório de estudos com conteúdos de redes.
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
# You need to acquire a copy of that script from git source code | |
# then place it in your home dir | |
source ~/git-prompt.sh | |
# Function to safely wrap __git_ps1 for use in PS1 | |
git_branch_prompt() { | |
local branch | |
branch="$(__git_ps1 ' (%s)')" | |
if [ -n "$branch" ]; then | |
echo "\[\033[1;33m\]$branch\[\033[0m\]" |
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
# Debian Reminders: | |
- PipeWire must be installed to share screen | |
- PipeWire needs a bluetooth library to work properly with Bluetooth Headphones |
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
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(" ") |
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
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) => { |
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
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 }); | |
}); | |
}); |
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 | |
# 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. |
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
<?php | |
function validateCNPJ($cnpj) | |
{ | |
$parsedCNPJ = preg_replace("/[.\/-]/", "", $cnpj); | |
if (!preg_match("/^\d{14}$/", $parsedCNPJ)) { | |
return false; | |
} |