Skip to content

Instantly share code, notes, and snippets.

View santigimeno's full-sized avatar

Santiago Gimeno santigimeno

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active November 11, 2025 10:00
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
Example Event Loop Execution Timeline
L₁ L₂ L₃ L₄
(1) ━━━┪ ┏━━━━━━━━━━━━━━╈┳━━━━━━━━━┯━━━━━━━━━━━╈┳━━━━┓ ┢━━━━━
┃ ┃ e₁ ┃┃ e₂ │ e₃ ┃┃ e₄ ┃ ┃ e₅
───┨ ┠──────────────┨┠─────────┼───────────╂╂────┨ ┠─────
(2) ┄┄┄┺━━━╃┄┄┄┄┄┄┄┄┄┄┄┄┄┄┺╃┄┄┄┄┄┄┄┄┄┴┄┄┄┄┄┄┄┄┄┄┄┺╃┄┄┄┄┺━━━━╃┄┄┄┄┄
│ [e₂] [e₃] │ [e₄] │ │
[e₁] [e₂] [e₄] [e₅]
[e₃]

The information below was written in Oct 2017. In August 2019 AWS launched official support for multiple target groups per AWS ECS service. Please use that feature instead!


Unfortunately as of writing this (Oct 18, 2017) there is no built in integration for multiple target groups per AWS ECS service. Here are a few things you can try:

  1. If your application just serves port 80 (HTTP) & port 443 (HTTPS) then you should consider using the application load balancer and terminating SSL at the load balancer. This will allow your application to function using just port 80.
@artynet
artynet / buildnode-raspbpi2-v7.sh
Last active July 17, 2017 19:05
Simple bash script to cross-compile node.js source (v7 release as well) for RPi2 platform
#!/bin/bash
## Node.js for Raspberry Pi 2 Packaging Script
## =========================================
## Use like this:
## ./buildnode.sh <node_tarball_version>
clean () {
rm -rvf node-v$1 node-v$1-rpi2
}
@joepie91
joepie91 / sessions.md
Last active September 12, 2025 09:50
Introduction to sessions

While a lot of Node.js guides recommend using JWT as an alternative to session cookies (sometimes even mistakenly calling it "more secure than cookies"), this is a terrible idea. JWTs are absolutely not a secure way to deal with user authentication/sessions, and this article goes into more detail about that.

Secure user authentication requires the use of session cookies.

Cookies are small key/value pairs that are usually sent by a server, and stored on the client (often a browser). The client then sends this key/value pair back with every request, in a HTTP header. This way, unique clients can be identified between requests, and client-side settings can be stored and used by the server.

Session cookies are cookies containing a unique session ID that is generated by the server. This session ID is used by the server to identify the client whenever it makes a request, and to associate session data with that request.

*S

@trevnorris
trevnorris / main.cc
Created February 5, 2016 23:53
Run a callback when an object is GC'd
#include <v8.h>
#include <node.h>
using namespace v8;
typedef void (*FreeCallback)(Local<Object> object, Local<Function> fn);
class CallbackStuff {
public:
@hosaka
hosaka / README.md
Last active February 3, 2022 08:12
Abstract Data Type using opaque pointers in C

Compile and run

gcc adt.c array.c -o adt
./adt
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@afolarin
afolarin / resource_alloc_docker.md
Last active March 18, 2024 17:01
Resource Allocation in Docker

#Container Resource Allocation Options in docker-run

now see: https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources

You have various options for controlling resources (cpu, memory, disk) in docker. These are principally via the docker-run command options.

##Dynamic CPU Allocation -c, --cpu-shares=0
CPU shares (relative weight, specify some numeric value which is used to allocate relative cpu share)

@trevnorris
trevnorris / perf-flame-graph-notes.md
Last active September 30, 2025 01:16
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0