This file contains hidden or 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
type Success<T> = [T, null]; | |
type Failure<E=Error> = [null, E]; | |
type Result<T, E> = Success<T> | Failure<E>; | |
/** | |
* A utility function that wraps a promise and returns a tuple. | |
* The first element of the tuple is the resolved value or null, | |
* and the second element is the error or null. | |
* | |
* @param promise - The promise to wrap. |
This file contains hidden or 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
# Função para lidar com argumentos nos cinco formatos: -n=valor, e -nValor, -n valor, --nome=valor, --nome valor | |
# Função para lidar com argumentos nos cinco formatos: -n=valor, -n valor, -nValor, --nome=valor, --nome valor | |
funcao-com-flag() { | |
local nome="fulano" | |
# Processar argumentos curtos, longos e curtos com e sem "=" | |
while [[ $# -gt 0 ]]; do | |
case "$1" in | |
# Argumentos curtos sem igual (-n valor) |
This file contains hidden or 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 | |
if [ -z "$1" ]; then | |
echo "Use: $0 /path/to/AppBundle.app" | |
exit 1 | |
fi | |
APP_PATH="$1" | |
APP_NAME=$(basename "$APP_PATH" .app) | |
TMP_DIR="/tmp/${APP_NAME}_dmg" |
This file contains hidden or 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
using System; | |
using System.Drawing; | |
using System.Windows.Forms; | |
using System.Runtime.InteropServices; | |
// Copile with: | |
// C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /target:winexe FakeWallpaper.cs | |
// Compilar with icon file: |
This file contains hidden or 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
#!/usr/bin/env zsh | |
pad_zero() { | |
local NUMBER=$1 | |
if [[ $NUMBER -lt 10 ]]; then echo 0$NUMBER; else echo $NUMBER; fi | |
} | |
convert_seconds_to_hours() { | |
local SECONDS=$1 | |
HOURS=$(expr $SECONDS / 3600) |
This file contains hidden or 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
from http.server import HTTPServer, BaseHTTPRequestHandler | |
class RequestHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.send_header('Content-Type', 'text/html') | |
self.end_headers() | |
file = open('index.html', 'r') | |
index = file.read() |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import os, re, argparse | |
NOT_ALLOWED_CHARACTERS_REGEX = r'["*|/\\:<>?\[\]]' | |
def parse_arguments(): | |
parser = argparse.ArgumentParser(description='Rename file or folder with only allowed characters on FAT partitions') |
This file contains hidden or 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
class CPF { | |
static CPF_MASK = '$1.$2.$3-$4'; | |
static CPF_REGEX = /(\d{3})(\d{3})(\d{3})(\d{2})/; | |
static generateFormated() { | |
return this.format(this.generate()); | |
} | |
static format(cpf) { | |
return cpf.replace(this.CPF_REGEX, this.CPF_MASK); | |
} |
This file contains hidden or 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
export function openTestingPlayground() { | |
const exec = require("util").promisify(require("child_process").exec); | |
const originalLogFn = console.log.bind(console); | |
console.log = function (...args) { | |
const url = args[0].match(/http.*/)[0]; | |
const commandsForEachPlatform = { | |
linux: `xdg-open ${url}`, | |
win32: `start chrome "${url}"`, | |
darwin: `open ${url}`, | |
}; |
This file contains hidden or 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
function isNumber(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n) | |
} | |
function searchTermInObjectAndPrintPath(object, text, path = '') { | |
text = text.toLowerCase() | |
for (let [key, value] of Object.entries(object)) { | |
if (key.toLowerCase().includes(text)) { | |
// encontrou na key | |
console.log(path) |
NewerOlder