Skip to content

Instantly share code, notes, and snippets.

View D1360-64RC14's full-sized avatar
👨‍💻
Learning

Diego Garcia D1360-64RC14

👨‍💻
Learning
View GitHub Profile
@D1360-64RC14
D1360-64RC14 / httpsRequest.js
Last active May 25, 2021 00:23
Node.JS Simple HTTPS Request
const HTTPS = require("https");
/**
* @param {string | HTTPS.RequestOptions | URL} options
* @returns {Promise<string>}
*/
function MakeRequest(options) {
return new Promise((Ok, Err) => {
HTTPS.request(options, res => {
// console.log(`statusCode: ${res.statusCode}`);
@D1360-64RC14
D1360-64RC14 / program.desktop
Created June 8, 2021 16:42
Sample program.desktop file
# Directory:
# All Users : /usr/share/applications
# Single User: ~/.local/share/applications
[Desktop Entry]
Type=Application
Name=Program Name
Comment=This is a sample .desktop file
Exec=/path/to/executable
Icon=/path/to/icon.png
@D1360-64RC14
D1360-64RC14 / nodebin_to_path.sh
Last active June 18, 2021 11:49
Bash script que adiciona o diretório "node_modules/.bin" ao path toda vez que presente no diretório atual.
# Copie este arquivo e cole
# no final do arquivo ~/.bashrc
# https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
NO_COLOR='\033[0m'
COLOR_BLACK='\033[0;30m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
COLOR_YELLOW='\033[0;33m'
@D1360-64RC14
D1360-64RC14 / newtemp.sh
Last active August 4, 2021 21:06
Bash script feito para criar um diretório random na pasta /temp para testes
# Este bash script cria um novo diretório na pasta
# /tmp para o testes rápidos sobre qualquer coisa.
# https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
NO_COLOR='\033[0m'
COLOR_BLACK='\033[0;30m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
COLOR_YELLOW='\033[0;33m'
@D1360-64RC14
D1360-64RC14 / sum.js
Created October 31, 2021 21:38
Desafio: realizar uma soma de inteiros sem utilizar operador +
function sum(a, b) {
[xored, carry] = _sum_step(a, b)
while(carry) {
[xored, carry] = _sum_step(xored, carry)
}
return xored
}
function _sum_step(a,b) {
xored = a ^ b
# Adições realizadas ao meu .bashrc
if [ -f ~/.bash_path ]; then
ADD_TO_PATH=$(cat ~/.bash_path)
for p in $ADD_TO_PATH; do
if [[ $(echo $p | head -c 1) != '#' ]]; then
PATH=$PATH:$p
fi
done
fi
@D1360-64RC14
D1360-64RC14 / FormURLEncoded.js
Created December 21, 2021 19:36
Implementation of proper FormURLEncoded class in JS
class FormURLEncoded extends Map {
/**
* @param {Nullable<String>} formString - Form URL encoded string (ex: `'hello=world&foo=bar&tar=gz'`)
*/
constructor(formString = null) {
super(formString ?
formString
.trim()
.split('&')
.map(
@D1360-64RC14
D1360-64RC14 / colors.sh
Created December 25, 2021 03:03
Color codes
#!/bin/bash
# https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
NO_COLOR='\033[0m'
COLOR_BLACK='\033[0;30m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
COLOR_YELLOW='\033[0;33m'
COLOR_BLUE='\033[0;34m'
@D1360-64RC14
D1360-64RC14 / OverwatchTeamCount.js
Last active January 18, 2022 20:38
Script para calcular a quantidade de times possíveis em uma partida do Overwatch. As configurações podem ser alteradas em `teams`.
console.time('timer');
const teams = {
tank: {
size: 8,
slots: 2
},
damage: {
size: 17,
slots: 2
@D1360-64RC14
D1360-64RC14 / mosaic.sh
Last active April 14, 2022 16:33
Script responsável por fazer o Download de todas as imagens de radar recentes do SIMEPAR e criar um gif com as mesmas
#!/bin/bash
download_image() {
# 1 -> Download image name
# 2 -> Output path
REF=http://www.simepar.br/
URL=https://lb01.simepar.br/riak/pgw-radar/$1
curl --silent --referer $REF --output $2 $URL