Skip to content

Instantly share code, notes, and snippets.

View wallyqs's full-sized avatar
🌎

Waldemar Quevedo wallyqs

🌎
  • Synadia Communications, Inc.
  • San Francisco
  • X @wallyqs
View GitHub Profile
@andreib1
andreib1 / hold.go
Last active April 1, 2021 21:53
Prevent a nats message from being redelivered during processing
// This function can be called to start a hold on a message for processing on Jetstream.
// The interval should be shorter than the message ack timeout.
// The parentCancel can be used to provide a cancellation function for processing in the event that we cannot set InProgress
// The function return should be named release by the caller, and can be used to unlock message processing after a successful ACK/NAK
func HoldMessage(ctx context.Context, msg *nats.Msg, interval time.Duration, parentCancel context.CancelFunc) context.CancelFunc {
ctx, release := context.WithCancel(ctx)
if interval < 1 {
return release
}
@CAFxX
CAFxX / bench_test.go
Last active September 8, 2020 23:43
Golang sharding primitive
package main
import (
"runtime"
"sync"
"sync/atomic"
"testing"
"unsafe"
)
@graninas
graninas / haskeller_competency_matrix.md
Last active June 30, 2024 10:13
Haskeller competency matrix
@smitchell
smitchell / main.py
Last active July 29, 2020 12:08
The trouble with tuples
#!/usr/bin/env python3
from pprint import pprint
from marshmallow import Schema
from marshmallow import fields
from marshmallow import post_load
class ModifyEntryRequest:
def __init__(self, dn, changes, controls=None):
@ColinSullivan1
ColinSullivan1 / mk_self_signed_test_cert.sh
Created May 8, 2020 17:38
Create self signed test certs (ca, client, server) with domain components "foo1" and "foo2"
#!/bin/sh
openssl genrsa -out ca.key 2048
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt -subj "/C=US/ST=California/L=Los Angeles/O=NATS/OU=NATS/CN=localhost"
cp ca.key ca-key.pem
cat ca.key > ca.pem
cat ca.crt >> ca.pem
# create client certs
openssl genrsa -out client.key 2048
$ nats -s demo.nats.io req 'registry.detect_type' '{
"schema": "io.nats.jetstream.advisory.v1.api_audit",
"id": "uafvZ1UEDIW5FZV6kvLgWA",
"timestamp": "2020-04-23T16:51:18.516363Z",
"server": "NDJWE4SOUJOJT2TY5Y2YQEOAHGAK5VIGXTGKWJSFHVCII4ITI3LBHBUV",
"client": {
"host": "::1",
"port": 57924,
"cid": 17,
"account": "$G",
@tompng
tompng / kvs_client.rb
Last active September 26, 2020 08:02
require 'socket'
100.times.map do |t|
Thread.new do
socket = TCPSocket.new 'localhost', 9876
100.times do
key = rand 100
cmd = ["get #{key}", "set #{key} #{t}_#{rand}", "delete #{key}"].sample
socket.puts cmd
p [t, cmd, socket.gets]
end
@redmcg
redmcg / kubedf
Last active June 14, 2024 19:51
Bash script to show k8s PVC usage
#!/usr/bin/env bash
NODESAPI=/api/v1/nodes
function getNodes() {
kubectl get --raw $NODESAPI | jq -r '.items[].metadata.name'
}
function getPVCs() {
jq -s '[flatten | .[].pods[].volume[]? | select(has("pvcRef")) | '\
@posener
posener / go-table-driven-tests-parallel.md
Last active April 30, 2024 20:34
Be Careful with Table Driven Tests and t.Parallel()

Be Careful with Table Driven Tests and t.Parallel()

We Gophers, love table-driven-tests, it makes our unittesting structured, and makes it easy to add different test cases with ease.

Let’s create our table driven test, for convenience, I chose to use t.Log as the test function. Notice that we don't have any assertion in this test, it is not needed to for the demonstration.

func TestTLog(t *testing.T) {
	t.Parallel()
@tsaarni
tsaarni / README.md
Last active May 8, 2024 11:42
How to connect to Azure AKS Kubernetes node VM by SSH

How to connect to Azure AKS Kubernetes worker node by SSH

Nodes are not assigned public IP. If you have accessible VM in the same VNET as worker nodes, then you can use that VM as jump host and connect the worker via private IP.

Alternatively public IP can be assigned to a worker node. This readme shows how to do that.

Steps how to attach public IP to a worker node

find out the resource group that AKS created for the node VMs