Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
🕹️

Steven de Salas sdesalas

🕹️
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 3, 2024 10:19
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.
@mandrean
mandrean / install-nodejs-lts-raspberry-pi-zero-w-armv6
Created November 7, 2022 11:22
Install NodeJS LTS on Raspberry Pi Zero W (ARMv6)
# update system
$ sudo apt update && sudo apt upgrade
# uninstall old node (v10?)
$ sudo apt remove nodejs npm -y
# install nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
# use 'unofficial builds' in nvm
@bszwej
bszwej / echo.js
Last active April 26, 2024 05:22
Pure Node.js echo server, that logs all incoming http requests (method, path, headers, body).
const http = require('http');
const server = http.createServer();
server.on('request', (request, response) => {
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
@dideler
dideler / bot.rb
Last active April 17, 2024 08:40
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@pcan
pcan / README.md
Last active April 17, 2024 01:45
Node.js plain TLS Client & Server, 2-way Cert Auth

Node.js TLS plain TLS sockets

This guide shows how to set up a bidirectional client/server authentication for plain TLS sockets.

Newer versions of openssl are stricter about certificate purposes. Use extensions accordingly.

Prepare certificates

Generate a Certificate Authority:

# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@Cyclenerd
Cyclenerd / AccessPoint.ino
Created July 26, 2017 19:46
ESP8266 : Create a WiFi access point and provide a DNS and web server on it, catch all traffic
/* Create a WiFi access point and provide a web server on it. */
#include <ESP8266WiFi.h>
#include "./DNSServer.h" // Patched lib
#include <ESP8266WebServer.h>
const byte DNS_PORT = 53; // Capture DNS requests on port 53
IPAddress apIP(10, 10, 10, 1); // Private network for server
DNSServer dnsServer; // Create the DNS object
ESP8266WebServer webServer(80); // HTTP server
@pgilad
pgilad / Instructions.md
Last active March 31, 2024 22:30
Git commit-msg hook to validate for jira issue or the word merge

Instructions

  • copy the file commit-msg to .git/hooks/commit-msg
  • make sure your delete the sample file .git/hooks/commit-msg.sample
  • Make commit msg executable. chmod +x .git/hooks/commit-msg
  • Edit commit-msg to better fit your development branch, commit regex and error message
  • Profit $$

Shell example

@smolleyes
smolleyes / upnp.js
Last active March 31, 2024 12:26 — forked from acacio/upnp.js
simple upnp port mapping with nodejs
/* node UPNP port forwarding PoC
This is a simple way to forward ports on NAT routers with UPNP.
This is a not-for-production hack that I found useful when testing apps
on my home network behind ny NAT router.
-satori / edited by smolleyes for freebox v6
usage: (install/clone node-ip from https://github.com/indutny/node-ip)
@matthiasak
matthiasak / languages-that-compile-to-js.md
Created October 15, 2015 13:12
Languages that compile to JS (from CoffeeScript wiki)

CoffeeScript Family (& Friends)

Family (share genes with CoffeeScript)
  • Coco A CoffeeScript dialect that aims to be more radical and practical, also acts as a test bed for features that get imported in CoffeeScript.
    • LiveScript is a fork of Coco that is much more compatible with CoffeeScript, more functional, and with more features.
  • IcedCoffeeScript A CoffeeScript dialect that adds support for await and defer keywords which simplify async control flow.