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
// Brazil's election for president 2022 | |
// Author: Thiago Prates | |
import fetch from "node-fetch"; | |
const url = "https://resultados.tse.jus.br/oficial/ele2022/544/dados-simplificados/br/br-c0001-e000544-r.json"; | |
const response = await fetch(url); | |
const json = await response.json(); | |
const results = json["cand"].reduce((acc, { /* candidato */ nm, /* porcentagem */ pvap }) => { | |
const pct = parseFloat(pvap.replace(/,/g, ".")); |
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
<?php | |
// Brazil's election for president 2022 | |
// Author: Thiago Prates | |
$url = 'https://resultados.tse.jus.br/oficial/ele2022/544/dados-simplificados/br/br-c0001-e000544-r.json'; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
// Link: https://curl.se/docs/caextract.html | |
// curl_setopt($ch, CURLOPT_CAINFO, './cacert.pem'); |
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
<?php | |
/** | |
* List all files in a directory and their respective subdirectories recursively. | |
* | |
* @param string $directory | |
* @return null|Generator | |
*/ | |
function scandir_all(string $directory): ?Generator | |
{ |
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
<?php | |
declare(strict_types=1); | |
/** | |
* Simple TCP Chat. | |
* | |
* @author Thiago Prates <[email protected]> | |
*/ | |
final class SimpleTcpChat |
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
<?php | |
/** | |
* Remove all files and subdirectories from a specific directory (recursively). | |
* | |
* @param string $dir The directory to be removed. | |
* | |
* @return | |
*/ | |
function rm_rf($dir) |
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
# https://overthewire.org/wargames/bandit/ | |
bandit1 NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL | |
bandit2 rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi | |
bandit3 aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG | |
bandit4 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe | |
bandit5 lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR | |
bandit6 P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU | |
bandit7 z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S | |
bandit8 TESKZC0XvTetK0S9xNwm25STk5iWrBvP |
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
// Binary Tree | |
// Author: Thiago Prates <[email protected]> | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct _node { | |
int data; | |
struct _node* left; | |
struct _node* right; |
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
/** | |
* Quicksort implementation. | |
* | |
* @see {@link http://en.wikipedia.org/wiki/Quicksort} | |
* @param {array} arr | |
* @result {array} Sorted array | |
.*/ | |
var quicksort = function(arr) { | |
function partition(arr, left, right) { |
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
/** | |
* To ASCII. | |
* | |
* @param {string} text | |
* @returns {string} | |
*/ | |
function toAscii(text) { | |
var noAscii = 'áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ'; | |
var ascii = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC'; | |
var resultText = ''; |
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
/** | |
* Caesar cipher. | |
* | |
* @link http://en.wikipedia.org/wiki/Caesar_cipher | |
* @param {string} msg | |
* @param {number} shift | |
* @return {string} | |
*/ | |
function caesarCipher(msg, shift) { | |
var result = "", |
NewerOlder