Skip to content

Instantly share code, notes, and snippets.

View midnight-wonderer's full-sized avatar

Sarun Rattanasiri midnight-wonderer

View GitHub Profile
@midnight-wonderer
midnight-wonderer / popular-domain-suggestion.ts
Created June 1, 2023 08:09
Email domain suggestion for typo prone user segments
@midnight-wonderer
midnight-wonderer / random_code.rb
Last active June 10, 2022 14:41
Random code with Ruby
# frozen_string_literal: true
require 'securerandom'
class RandomCode
class NotSupported < ::StandardError
end
class P_Single < ::StandardError
end
@midnight-wonderer
midnight-wonderer / README.md
Created October 5, 2021 08:04
How do I resolve the certificate expiration error that I receive when Lambda invokes dependencies for a Let's Encrypt certificate?

I get an SSL error when AWS Lambda invokes dependencies that use a Let's Encrypt certificate.

Short description

Some AWS Lambda .NET Core and Ruby runtimes are experiencing certificate errors due to an expired Let's Encrypt cross-signed DST Root CA X3. For compatibility purposes, Let's Encrypt certificates default to using a certificate chain that's cross-signed by the DST Root CA X3 certificate that expired on September 30, 2021. OpenSSL versions 1.0.2 and earlier return an error when one of the verification paths is invalid, which prevents the successful establishment of SSL/TLS connections.

The following resolution removes the expired CA from the CA bundle and forces the system to use the file provided by the layer instead of the file packaged with the base system. OpenSSL versions 1.0.2 and earlier are forced to validate Let's Encrypt certificates using the alternate path provided in the environment variables.

Important: The system's trust store is frequently updated to include new CA root cer

@midnight-wonderer
midnight-wonderer / README.md
Created October 4, 2021 14:55
BLAKE3 vs BLAKE2 for short input message

BLAKE3 vs BLAKE2 benchmark for short input

Observed result

blake3 : 335251.50 per second
blake2s: 715722.22 per second
blake2b: 663446.58 per second

Conclusion from the result

@midnight-wonderer
midnight-wonderer / note.txt
Last active February 22, 2022 03:50
Higher apt repo priority
path:
/etc/apt/preferences.d
command:
apt policy
apt-cache policy package-name
content:
Package: *
Pin: release o=RepoNameFromPolicyCommand
# start session
ssh-agent $SHELL
ssh-add ./destination-key
ssh -i ./intermediate-key -A -t user@intermediate.example.com ssh -A user@destination.example.com
@midnight-wonderer
midnight-wonderer / sudoers
Created June 30, 2020 01:01
Allow a user to run privilege commands
# Cmnd alias specification
Cmnd_Alias FIREWALL = /usr/sbin/ufw
# User privilege specification
username ALL=NOPASSWD: FIREWALL
@midnight-wonderer
midnight-wonderer / sigrok-checklist.md
Last active December 7, 2019 02:08
Sigrok checklist
  • Firmware in place
  • udev rules
@midnight-wonderer
midnight-wonderer / shadowsocks.Makefile
Last active August 24, 2019 15:06
Make script for simple Shadowsocks deployments
SHELL:=/usr/bin/env bash
SOURCE_DIR=$(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
PSK=$(shell cat $(SOURCE_DIR)/psk | xargs)
SHADOWSOCKS_VERSION=v0.0.11
shadowsocks-download:
URL="https://github.com/shadowsocks/go-shadowsocks2/releases/download/$(SHADOWSOCKS_VERSION)/shadowsocks2-linux.gz" && \
((curl -s -L $$URL | gunzip -q) > $(SOURCE_DIR)/shadowsocks2) && \
chmod +x $(SOURCE_DIR)/shadowsocks2
@midnight-wonderer
midnight-wonderer / nat-instance.Makefile
Last active August 24, 2019 11:35
Creating Linux NAT router
SHELL:=/usr/bin/env bash
DEFAULT_INTERFACE=$(shell /sbin/route | grep default | grep -Eo "[a-z0-9]+$$")
VPC_CIDR=10.0.0.0/16
forward-traffic:
/sbin/iptables -t nat -A POSTROUTING -o $(DEFAULT_INTERFACE) -s $(VPC_CIDR) -j MASQUERADE