Skip to content

Instantly share code, notes, and snippets.

View dreamorosi's full-sized avatar
👽

Andrea Amorosi dreamorosi

👽
View GitHub Profile
@dreamorosi
dreamorosi / instrumentHttp.ts
Last active May 2, 2024 17:47
POC that shows how to subscribe to built-in diagnostics_channel events for the http module in Node.js - unfortunately there's no way of subscribing to error events. As of now, if the request fails after having started (i.e. `ECONNREFUSED`) the segment remains opened.
import type { ClientRequest, IncomingMessage } from 'node:http';
import { subscribe } from 'node:diagnostics_channel';
public captureHTTPsGlobal(): void {
const onRequestStart = (message: unknown): void => {
const { request } = message as { request: ClientRequest };
console.log(message);
const parentSubsegment = this.getSegment();
if (parentSubsegment && request.host) {
{
"$schema": "https://biomejs.dev/schemas/1.7.0/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": [
"es2022"
],
"declaration": true,
"strict": true,
@dreamorosi
dreamorosi / readme.md
Created October 17, 2023 12:18
Install neovim on Amazon Linux 2023

Build & Install neovim

AL2023 doesn't have a distribution for neovim, so you need to build it from source - for more info see here.

Install prerequisites:

sudo yum -y install ninja-build cmake gcc make unzip gettext curl git --allowerasing

Clone repository:

@dreamorosi
dreamorosi / .zshrc
Last active March 31, 2023 14:07
.zshrc for remote boxes
fpath+=$HOME/.zsh/pure
# Theme
# Commented since pure is used https://github.com/sindresorhus/pure
# ZSH_THEME="refined"
ZSH_THEME=""
autoload -U promptinit; promptinit
prompt pure
# Case-sensitive completion.
@dreamorosi
dreamorosi / resize.sh
Created November 5, 2021 14:10
Resize a Cloud9 volume
#!/bin/bash
# Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
SIZE=${1:-20}
# Get the ID of the environment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)
# Get the ID of the Amazon EBS volume associated with the instance.
VOLUMEID=$(aws ec2 describe-instances \
@dreamorosi
dreamorosi / Chime Mute Toggle Script.md
Last active October 5, 2021 13:35
Karabiner Elements script that works with OneKey Mute Button Edition from TechKeys and brings Chime foremost to mute/unmute or mutes Teams when foremost

This script works with Karabiner Elements and OneKey Mute Button Edition.

When the button is pressed it performs one of these actions evaluated in this order:

  • If MS Teams is the frontmost application then it toggles mute.
  • If Chime is the frontmost application then it toggles mute.
  • Else it brings Chime to the front and toggles mute.
@dreamorosi
dreamorosi / git_commands.md
Created October 27, 2020 14:28
Useful Git Commands

Prune local branches that don't exist anymore on remote

git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done

Undo last local commit but keep changes

git reset HEAD^
import boto3
import json
class EC2Handler:
"""
Class used to handle operations with EC2 through boto3.
"""
def __init__(self, region_name: str):
self.client = boto3.resource('ec2', region_name)
@dreamorosi
dreamorosi / README.md
Last active March 9, 2022 18:02
Convert Markdown to PDF with Asciidoctor

Use the script above by making it executable (chmod +x convert.sh) and running it (./convert.sh).

If you want to add a page break use <<<, if you want to add syntax highlighting add :source-highlighter: rouge at the top of the Markdown file, it won't be rendered in Markdown but will be used by asciidoctor.