Skip to content

Instantly share code, notes, and snippets.

View jlucaso1's full-sized avatar
🏠
Working from home

João Lucas de Oliveira Lopes jlucaso1

🏠
Working from home
View GitHub Profile
// --- Initialization ---
// Ensure the original functions are stored so we can call them
if (!window.originalDecodeStanza) {
window.originalDecodeStanza = require("WAWap").decodeStanza;
window.originalEncodeStanza = require("WAWap").encodeStanza;
}
/**
* Recursively walks through an object or array and decodes any Uint8Array
* placeholders it finds into JSON objects.
@jlucaso1
jlucaso1 / reverse_proxy.zig
Created March 28, 2025 02:07
A tcp and udp reverse proxy in zig
const std = @import("std");
const net = std.net;
const mem = std.mem;
const fmt = std.fmt;
const process = std.process;
const log = std.log.scoped(.proxy);
const posix = std.posix; // For UDP socket operations
const Thread = std.Thread;
const io = std.io;
const Allocator = mem.Allocator;
@jlucaso1
jlucaso1 / zig-0-14-0-std.md
Last active March 28, 2025 01:37
Zig 0.14.0 summary std libraries

Zig Standard Library std.crypto Summary

This document summarizes the std.crypto module in Zig's standard library, focusing on common cryptographic operations and how to use them. The library provides a wide range of cryptographic primitives and high-level APIs designed for security and ease of use.

Core Concepts

  • Hashing: Creating fixed-size digests of data (e.g., for integrity checks). See `crypto.hash`.
  • Authentication (MAC): Creating tags to verify data integrity and authenticity using a secret key. See `crypto.auth`.
  • Password Hashing: Securely hashing passwords for storage, designed to be slow and resource-intensive. See `crypto.pwhash`.
  • Encryption (AEAD): Encrypting data while also providing integrity and authenticity verification (Authenticated Encryption with Associated Data). Preferred over raw stream/block ciphers. See `crypto.aead`.
@jlucaso1
jlucaso1 / prefixKeys.ts
Last active August 8, 2024 05:44
This TypeScript code snippet provides a function prefixKeys that allows you to prefix all the keys of an object or array of objects with a specified string. It also defines helper types to ensure type safety throughout the process.
// @author: https://github.com/jlucaso1
// @url: https://gist.github.com/jlucaso1/220756deaa75d130306bdece460d4c61
type ObjectUnion = Record<string, unknown> | unknown;
const isObject = (value: unknown): value is Record<string, unknown> =>
typeof value === 'object' &&
value !== null &&
!(value instanceof RegExp) &&
!(value instanceof Error) &&
@jlucaso1
jlucaso1 / configure.sh
Last active May 27, 2022 18:43
Configure Oracle Cloud Machine
# change PasswordAuthentication to yes
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo service sshd restart
# read from keyboard and store in a variable the username and password
read -p "Enter username: " username
read -p "Enter password: " password
# create a user with the username and password
sudo useradd -m -p $(openssl passwd -1 $password) $username
# add the user to the sudo group
sudo usermod -aG sudo $username