Skip to content

Instantly share code, notes, and snippets.

View heijmerikx's full-sized avatar

Rutger Heijmerikx heijmerikx

View GitHub Profile
name: "air-quality-indoor"
platform: ESP32
board: "featheresp32"
stardigits /
Created July 4, 2020 15:13
How to Install Visual Studio Code on MX Linux 19.5 (Debian 10)
slava-vishnyakov /
Last active April 12, 2024 06:24
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

 * Matches following attributes in Markdown-typed image: [, alt, src, title]
evgeniy-trebin /
Last active September 21, 2022 22:39
How to install specific version of elasticsearch via brew
brew tap homebrew/versions
brew cask install java
brew search elasticsearch
brew install elasticsearch@2.3
brew services start elasticsearch@2.3
vlucas / encryption.js
Last active April 2, 2024 14:26
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
eloo / node_exporter.default
Last active December 22, 2023 09:00
Init.d script for prometheus node exporter
# Set the command-line arguments to pass to the server.
ARGS='-web.listen-address=:9100 -collector.diskstats.ignored-devices="^(ram|loop|fd)\\d+$"'
# Prometheus-node-exporter supports the following options:
# -collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z])\\d+$": Regexp of devices to ignore for diskstats.
# -collector.filesystem.ignored-mount-points="^/(sys|proc|dev)($|/)": Regexp of mount points to ignore for filesystem collector.
# -collector.ipvs.procfs="/proc": procfs mountpoint.
# -collector.megacli.command="megacli": Command to run megacli.
# -collector.ntp.server="": NTP server to use for ntp collector.
#"": Directory to read text files with metrics from.
anhldbk /
Last active March 3, 2024 16:36
TLS client & server in NodeJS

1. Overview

This is an example of using module tls in NodeJS to create a client securely connecting to a TLS server.

It is a modified version from documentation about TLS, in which:

  • The server is a simple echo one. Clients connect to it, get the same thing back if they send anything to the server.
  • The server is a TLS-based server.
  • Clients somehow get the server's public key and use it to work securely with the server

2. Preparation

mickhansen / optimize.js
Last active December 29, 2015 12:25 — forked from heijmerikx/optimize.js
router.get('/', function(req, res, next) {
where: {
published: true
limit: 3,
order: [["createdAt","DESC"]],
include: [
{ model: models.Photo }
IceCreamYou / percentile.js
Last active November 17, 2022 01:54
Utility functions to calculate percentiles and percent ranks in a JavaScript array.
// Returns the value at a given percentile in a sorted numeric array.
// "Linear interpolation between closest ranks" method
function percentile(arr, p) {
if (arr.length === 0) return 0;
if (typeof p !== 'number') throw new TypeError('p must be a number');
if (p <= 0) return arr[0];
if (p >= 1) return arr[arr.length - 1];
var index = (arr.length - 1) * p,
lower = Math.floor(index),
igordeoliveirasa / gist:78a310f0348fcad9b270
Created March 26, 2015 01:41
iOS Loading Overlay View - SWIFT
// LoadingOverlay.swift
// app
// Created by Igor de Oliveira Sa on 25/03/15.
// Copyright (c) 2015 Igor de Oliveira Sa. All rights reserved.
// Usage:
// # Show Overlay