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 / n_bits_number_packing.c
Last active April 16, 2022 16:50
Uma implementação de n bits Number Packing em C. Encoder/decoder de number packing baseado em RGB to Integer, porém com a possibilidade de n bits e n grupos (contanto que tudo isso caiba em um uint64). Desenvolvido em C11.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
/**
* Recebe uma lista contendo uint8_t e retorna a soma desses.
* Ex:
*
* uint8_t numbers[] = { 1, 2, 3, 4, 5 };
@D1360-64RC14
D1360-64RC14 / default.conf
Created July 11, 2022 14:35
NGINX nginx.conf and default.conf files
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
@D1360-64RC14
D1360-64RC14 / ipfs-config.json
Last active January 21, 2023 13:25
My IPFS gateway configuration for CGNAT environment.
{
"Bootstrap": [
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
],
"Addresses": {
@D1360-64RC14
D1360-64RC14 / README.md
Last active July 16, 2022 04:38
My Docker NGINX configuration for local IPFS gateway.

This is my Docker-NGINX-IPFS environment.

Docker Images

Endpoints

URL Description Redirect
@D1360-64RC14
D1360-64RC14 / gimme-all-styles.js
Created November 27, 2022 18:07
An JavaScript code to select all Google Fonts' font styles. Steps the code does: select all styles, open the side panel, print the "import command" to the console, remove all fonts, close the side panel.
(() => {
const todos = [
() => Array.from(document.getElementsByClassName('selection-toggle-button mdc-button mat-mdc-button mat-primary mat-mdc-button-base gmat-mdc-button')).forEach(el => el.click()),
() => document.getElementsByClassName('mat-mdc-tooltip-trigger shopping-bag__toggle mdc-icon-button mat-mdc-icon-button mat-mdc-button-base gmat-mdc-button mat-secondary--gray shopping-bag__toggle--has-items')[0].click(),
() => document.querySelector('input[value="import"]').click(),
() => document.getElementsByClassName('embed-code__import gmat-caption gf-code-block ng-star-inserted')[0].innerText.split('\n')[1],
() => document.getElementsByClassName('mdc-button mat-mdc-button mat-primary mat-mdc-button-base gmat-mdc-button')[1].click(),
() => document.getElementsByClassName('actions__close-button mdc-icon-button mat-mdc-icon-button mat-secondary--gray gmat-mdc-button-with-prefix mat-mdc-button-base gmat-mdc-button')[0].click()
];
const iter = todos[Symbol.iterator]();
@D1360-64RC14
D1360-64RC14 / SimpleTextViewer.html
Last active December 4, 2022 18:03
An URL Text Viewer to be saved in the Bookmarks (literally). Copy the minified code, paste in the URL, and you'll have a simple text viewer for your drafts. You can also bookmark the URL to place it on the Bookmarks bar. Supports Ctrl + Scroll to change font size.
data:text/html,
<body>
<textarea spellcheck="false"></textarea>
</body>
<style>
body {
display: flex;
margin: 0;
height: 100vh;
@D1360-64RC14
D1360-64RC14 / calculate_digit.kt
Last active December 16, 2022 22:32
Algorítmo para calcular os últimos 2 dígitos do CPF.
fun calculateDigit(cpf: List<Int>): List<Int> {
val cpfSum = cpf
.reversed()
.mapIndexed { idx, digit -> (idx + 2) * digit }
.sum()
val remainder = cpfSum * 10 % 11
val partialCPF = cpf + (remainder % 10)
if (partialCPF.size >= 11)
sagaz
âmago
negro
êxito
mexer
termo
nobre
senso
algoz
afeto
@D1360-64RC14
D1360-64RC14 / VSCode-tasks.json
Last active February 10, 2023 03:52
VSCode task script to run multiple commands within an external terminal. The external terminal used in the example is "terminator".
{
"version": "2.0.0",
"tasks": [
{ // Run with multiple commands on external terminal
"label": "run (external terminal)",
"command": "dotnet",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}",
"shell": {
@D1360-64RC14
D1360-64RC14 / opt-bin-to-path.sh
Last active June 8, 2023 16:55
Put every /opt/*/bin into PATH. The bash code should be placed at the end of your ~/.bashrc file (or similar). Supports also symbolic links to bin or complete folders.
# Put every /opt/*/bin into PATH
OPT_BINS=$(find /opt/*/bin -maxdepth 0 -type d,l 2> /dev/null)
PATH_OPT_BINS=$(echo $OPT_BINS | sed 's/ \//:\//g')
export PATH=$PATH:$PATH_OPT_BINS