Skip to content

Instantly share code, notes, and snippets.

View khaosdoctor's full-sized avatar
:shipit:
Always trying, never giving up

Lucas Santos khaosdoctor

:shipit:
Always trying, never giving up
View GitHub Profile
@khaosdoctor
khaosdoctor / rsa-euler.ts
Created February 18, 2024 00:21
RSA keyset generation using Euler's totient under 100 lines
/**
* Calcula a potência de um número bigInt
* O JS não suporta números inteiros maiores que 2^53-1
* e BigInts não podem ser usados com o operador **, por isso
* essa função foi criada
*/
function bigIntPower(base: number|bigint, exponent: number) {
let result = 1n
const bigBase = BigInt(base)
for (let i = 0; i < exponent; i++) {
@khaosdoctor
khaosdoctor / rsa-carmichael.ts
Created February 18, 2024 00:13
TypeScript implementation of an RSA keyset generation under 100 lines
/**
* Calcula a potência de um número bigInt
* O JS não suporta números inteiros maiores que 2^53-1
* e BigInts não podem ser usados com o operador **, por isso
* essa função foi criada
*/
function bigIntPower(base: number|bigint, exponent: number) {
let result = 1n
const bigBase = BigInt(base)
for (let i = 0; i < exponent; i++) {
@khaosdoctor
khaosdoctor / workingwithlucas-en-us.md
Last active October 1, 2023 21:46
Useful info when working with me

Working with Lucas

Creation Date: June 2020

Status: in progress

A collection of stuff that might come in handy when working with me

My personal philosophy:

class Codename {
constructor (parser) {
this._parser = parser
return this
}
parse (version) {
this._version = version || '0.0.0'
const [major, minor, patch] = this._version.split('.')
this._major = (this._parser.major) ? (this._parser.major[major] || major) : major
@khaosdoctor
khaosdoctor / index.js
Created September 17, 2019 17:18
Simple bitcoin-like proof of work using worker threads
const { payloads } = require('./payloads.json')
const { Worker } = require('worker_threads')
const LEADING_ZEROES = 4
const final = []
let finishedWorkers = 0
for (let payload of payloads) {
const worker = new Worker('./worker.js', { env: { LEADING_ZEROES } })
worker.once('message', (message) => {
@khaosdoctor
khaosdoctor / 1-criar-cluster-kind.sh
Last active February 22, 2023 23:39
Scripts e comandos que eu faço no vídeo sobre KinD com Kubernetes: https://www.youtube.com/watch?v=dL19dSGKZoc
kind create cluster --name demo-cluster
kind get clusters
kubectl config get-contexts
@khaosdoctor
khaosdoctor / api.yaml
Last active November 25, 2022 23:38
Código fonte para o vídeo de hospedagem Kubernetes com Azure: https://www.youtube.com/watch?v=gbZ-rKfuwpE
apiVersion: apps/v1
kind: Deployment
metadada:
name: vote-api
labels:
app: vote-api
spec:
selector:
matchLabels:
app: vote-api
@khaosdoctor
khaosdoctor / caesarShift-1.js
Last active October 27, 2022 12:05
Caesar Cypher implementations in JavaScript
/**
* Esse código funciona usando o código de cada caractere digitado e realizando a modificação para outro caractere de acordo com o número da chave
* Para entender melhor de onde vem os números de cada alfabeto, veja o código abaixo
*/
// const alphabet = 'abcdefghijklmnpqrstuvwxyz'
// const capital = alphabet.toUpperCase()
// for (let i = 0; i < alphabet.length; i++) {
// console.log(alphabet[i], alphabet.charCodeAt(i))
// // a 97
{
"operation": "add_node",
"name": "harper-edge",
"host": "harper-edge",
"port": 62344,
"subscriptions": [
{
"channel": "default:sensor_data",
"subscribe": true,
"publish": false
{
"operation": "add_node",
"name": "harper-edge",
"host": "harper-edge",
"port": 62344,
"subscriptions": []
}