Skip to content

Instantly share code, notes, and snippets.

View steveh's full-sized avatar

Steve Hoeksema steveh

View GitHub Profile
@mandrean
mandrean / install-pulseview-gettext-macos
Created January 23, 2023 17:29
Install PulseView (& gettext) on Apple M1 Silicon (aarch64, arm64)
# install xcodes
brew install robotsandpencils/made/xcodes aria2
# install & select latest version of xcode
xcodes list | awk 'END{system("xcodes install " $1"; xcodes select " $1)}'
# install x86-64 homebrew
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# switch to x86_64 homebrew
@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active July 6, 2024 19:07
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
@sekcompsci
sekcompsci / Comparison Espressif ESP MCUs.md
Last active July 23, 2024 20:41 — forked from fabianoriccardi/Comparison Espressif ESP MCUs.md
Comparison chips (SoCs) table for ESP8266/ESP32/ESP32-S2/ESP32-S3/ESP32-C3/ESP32-C6. Forked from @fabianoriccardi

Comparison chips (SoCs) table for ESP8266/ESP32/ESP32-S2/ESP32-S3/ESP32-C3/ESP32-C6

A minimal table to compare the Espressif's MCU families.

ESP8266 ESP32 ESP32-S2 ESP32-S3 ESP32-C3 ESP32-C6
Announcement Date 2014, August 2016, September 2019, September 2020, December
@alwynallan
alwynallan / Makefile
Last active June 21, 2024 18:53
Hardware PWM Controller for the Raspberry Pi 4 Case Fan
CC = gcc
RM = rm -f
INSTRUMENT_FOR_PROMETHEUS := false
ifeq ($(INSTRUMENT_FOR_PROMETHEUS),true)
CFLAGS = -Wall -DINSTRUMENT_FOR_PROMETHEUS
LIBS = -lbcm2835 -lprom -lpromhttp -lmicrohttpd
else
CFLAGS = -Wall
@tomhicks
tomhicks / plink-plonk.js
Last active July 22, 2024 09:51
Listen to your web pages
@mutin-sa
mutin-sa / Top_Public_Recursive_Name_Servers.md
Last active July 16, 2024 02:38
List of Top Public Recursive Name Servers

DNS:

IPv4 Addr IPv6 Addr ASn Political Region Loc Svc Org
8.8.8.8 2001:4860:4860::8888 AS15169 US Worldwide (Anycast) Google Public DNS Google
8.8.4.4 2001:4860:4860::8844 AS15169 US Worldwide (Anycast) Google Public DNS Google
1.1.1.1 2606:4700:4700::1111 AS13335 US Worldwide (Anycast) Cloudflare-DNS Cloudflare/APNIC
1.0.0.1 2606:4700:4700::1001 AS13335 US Worldwide (Anycast) Cloudflare-DNS Cloudflare/APNIC
208.67.222.222 2620:119:35::35 AS36692 US *W

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@kacole2
kacole2 / README.md
Last active April 25, 2020 11:51
EBS and EFS Volumes with Docker For AWS using REX-Ray

EBS and EFS Volumes with Docker For AWS using REX-Ray

This procedure will deploy Docker For AWS and go through the steps to build REX-Ray containers. This process will have some hiccups because Docker for AWS will provision resources in different availability zones (AZs). Multiple workers/agents will be spread across AZs (not regions) which means a potential host failure will trigger Swarm to restart containers that could spread across an AZ. If a container is restarted in a different AZ, the pre-emption mechanism for REX-Ray will not work because it no longer has access to the volume in the former AZ.

Deploy Docker for AWS.

Launch Stack

SSH into one of your Docker Manager Nodes

@rxseger
rxseger / tachfan.py
Created October 9, 2016 04:53
read RPM from a PC fan tachometer wired to GPIO
#!/usr/bin/python -u
# tachfan.py - read RPM from a PC fan tachometer wired to GPIO
#
# references:
# http://electronics.stackexchange.com/questions/8295/how-to-interpret-the-output-of-a-3-pin-computer-fan-speed-sensor
# http://www.formfactors.org/developer/specs/REV1_2_Public.pdf
import RPi.GPIO as GPIO
import time

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.