Skip to content

Instantly share code, notes, and snippets.

View gburd's full-sized avatar

Greg Burd gburd

View GitHub Profile
@jrudolph
jrudolph / SimpleQuicClientMain.scala
Last active February 20, 2020 16:45
"Simple" "Http/3" "client"
import java.math.BigInteger
import java.net.DatagramPacket
import java.net.DatagramSocket
import java.net.InetAddress
import java.security.KeyPairGenerator
import java.security.MessageDigest
import java.security.SecureRandom
import java.security.interfaces.ECPrivateKey
import java.security.interfaces.ECPublicKey
import java.security.spec.ECPoint
@kekru
kekru / 01nginx-tls-sni.md
Last active June 19, 2024 17:24
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@slayerlab
slayerlab / histogram.c
Created October 21, 2018 10:36
ANSI C K&R: Horizontal & Vertical Histogram
#include <stdio.h>
/* *
* Exercise 1-13. Write a program to print a histogram of the lengths of words in
* its input. It is easy to draw the histogram with the bars horizontal; a vertical
* orientation is more challenging.
* ----
* ANSI C K&R - CHARACTER INPUT AND OUTPUT: PAGE 15
* The quantities IS_LOWER, IS_UPPER, IS_ALPHA, MAXLEN, OUT and IN (macros)
* are symbolic constant, not variables, so they do not appear in declarations.
@glampert
glampert / atomic_slist_128bits_cas.cpp
Created March 20, 2017 17:52
Atomic/lockless linked list using 128-bits Compare And Swap to solve the A-B-A problem.
// --------------------------------------------------------------------------------------
// Atomic singly-linked intrusive list using 128-bits Compare And Swap (AKA: DCAS).
// Keeps a version counter with the list head to prevent the A-B-A problem.
//
// Based on the implementation found in moodycamel.com:
// http://moodycamel.com/blog/2014/solving-the-aba-problem-for-lock-free-free-lists
//
// My implementation uses raw GCC/Clang atomics intrinsics. While in theory
// std::atomic of a struct of exactly 16 bytes and properly aligned could
@rmullinnix
rmullinnix / cluster_bounce.yml
Last active January 22, 2021 22:56
Ansible playbook for consul cluster bounce - ansible-playbook -i hosts.dev cluster_bounce.yml --ask-become-pass (peers.tmpl is in roles/consul/templates; sedfile is in roles/consul/files; main.yml is in roles/consul/vars)
---
# This Playbook bounces a consul cluster that is unable to elect a leader
# push peers.json to the consul/raft data directory, change single quotes to doubles, restart consul servers
- hosts: consulservers
become: yes
# update the peers.json file with the correct consul server ip addresses and port
tasks:
- include_vars: roles/consul/vars/main.yml
@tvlooy
tvlooy / unit.sh
Last active February 4, 2024 04:20
Bash test: get the directory of a script
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else
@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@ptrv
ptrv / lldb-gud-emacs-24.patch
Last active September 5, 2019 14:16
lldb-gud patch from llvm.org for emacs 24.4
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index e2d996f..d1458a2 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -34,7 +34,7 @@
;; and added a menu. Brian D. Carlstrom <bdc@ai.mit.edu> combined the IRIX
;; kluge with the gud-xdb-directories hack producing gud-dbx-directories.
;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java
-;; debugger.)
+;; debugger). llvm.org added support for lldb.
include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <math.h>
#include "stinger_utils/timer.h"
int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) {
int64_t b= -1, j = 0;
@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2