Skip to content

Instantly share code, notes, and snippets.

View lmammino's full-sized avatar
🦁
Roar!

Luciano Mammino lmammino

🦁
Roar!
View GitHub Profile
@lmammino
lmammino / Cargo.toml
Created May 1, 2024 17:51
Poor man async rust HTTP load testing tool
[package]
name = "send-requests"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.38"
clap = { version = "4.5.4", features = ["derive"] }
@lmammino
lmammino / README.md
Created March 18, 2024 14:18
Rust Lambda Workshop Requirements
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"DateLessThan": {"aws:TokenIssueTime": "2014-05-07T23:47:00Z"}
}
}
@lmammino
lmammino / promise-with-resolvers-polyfill.js
Created July 18, 2023 17:57
Promise.withResolvers() polyfill
if (typeof Promise.withResolvers === 'undefined') {
Promise.withResolvers = function () {
let resolve, reject
const promise = new Promise((res, rej) => {
resolve = res
reject = rej
})
return { promise, resolve, reject }
}
}
@lmammino
lmammino / README.md
Last active March 19, 2024 18:37
Setup SSM to connect your VSCode to a remote Cloud9 Instance (awsbites.com)

Initial steps

  1. Launch Cloud9 IDE with SSM option
  2. When it launchers, open the Cloud9 IDE in the AWS Console

With SSM

Install:

  • AWS CLI
@lmammino
lmammino / Cargo.toml
Last active January 9, 2023 22:48
Simple example of using nom, Rust parser combinator
[package]
name = "learning-nom"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nom = "7.1.2"
@lmammino
lmammino / README.md
Last active October 19, 2022 09:13
Lambda Proxy autocomplete and type checking with JSDoc (and no TypeScript!)

How to get type checking and autocompletion in your IDE without TypeScript for your AWS Lambda code

A quick demo that shows how JSDoc annotations can help you to get autocompletion and type checking without having to write (and transpile!) TypeScript code.

The video version is available here: https://youtube.com/shorts/60zUEc_vs1o

For more AWS tutorials, follow us at @AWSBites

@lmammino
lmammino / README.md
Last active June 27, 2022 19:30
Request batching benchmark

Request batching benchmark

Request batching is a Node.js pattern that can be used to optimise how a web server handles identical concurrent requests.

It allows to process the request only once for all the clients concurrently requesting the same information. This can save expensive round trips to backend services and can avoid backend services to be overloaded with many concurrent identical requests. In a way it's a more specialised version of micro-caching.

This can lead to significant performance improvement in cases where there are many concurrent users requesting the same page.

@lmammino
lmammino / goto.js
Created May 3, 2022 18:29
If you ever wanted to use GOTO in JavaScript (for whatever crazy reason)...
// prints the first 100 even numbers and exits
let x = 0
LABEL1: do {
console.log(x)
x = x + 2
// JUMP TO THE END OF THE DO-WHILE - A FORWARDS GOTO
if (x > 100) break LABEL1
// JUMP TO THE START OF THE DO WHILE - A BACKWARDS GOTO...
if (x <= 100) continue LABEL1
} while (true)
@lmammino
lmammino / cp.js
Last active January 20, 2023 17:28
Session about Node.js streams with Kelvin
import { createReadStream, createWriteStream } from 'fs'
const source = createReadStream('./assets/moby-dick.txt')
const dest = createWriteStream('./assets/moby-dick-decompressed.txt')
source
.pipe(dest)