Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import multiprocessing
import random
import time
class Logger:
def __init__(self, num_lines, last_output_per_process, terminal_lock):
self.num_lines = num_lines
@lemmy
lemmy / Qsort.tla
Created June 12, 2021 03:06
A toy program to sort characters with QuickSort (implemented" in TLA+)
$ ./pluspy -s modules/other/Qsort.tla
Enter input: poiuylkjhmnbvcdsxzafgtrewq
abcdefghijklmnopqrstuvwxyz
----------------------------- MODULE Qsort -----------------------------
EXTENDS Naturals, Sequences, FiniteSets, TLC, Input
\* Specification (works reasonably well for sets of cardinality <= 6
\* Takes a set as argument, produces a sorted tuple
Sort(S) == CHOOSE s \in [ 1..Cardinality(S) -> S]:
@slaiyer
slaiyer / hilbert.py
Created May 6, 2021 17:21
Hilbert curve
#!/usr/bin/env python3
import argparse
from turtle import *
def hilbert_curve(step, parity, n):
if n < 1:
return
@xandout
xandout / README.md
Last active March 9, 2024 17:42
Kubernetes DaemonSet that enables a direct shell on each Node using SSH to localhost

Getting a shell on each node

I run several K8S cluster on EKS and by default do not setup inbound SSH to the nodes. Sometimes I need to get into each node to check things or run a one-off tool.

Rather than update my terraform, rebuild the launch templates and redeploy brand new nodes, I decided to use kubernetes to access each node directly.

Alternative option

https://github.com/alexei-led/nsenter

@wudi
wudi / dynamic_router.go
Last active February 8, 2023 16:53
Dynamic Router for Gin
package main
import (
"net/http"
"sync"
"time"
"github.com/gin-gonic/gin"
)
@arthurk
arthurk / gist:ab9ced56ce78bb8309599ccc62fa2576
Created June 1, 2020 03:50
fetch list images from GCR via service account
#!/usr/bin/env bash
set -euo pipefail
######################
# Script that fetches a list of all images from GCR
# uses 3 different users in GCR
######################
keyfile="gcr-svc-acc-keyfile.json"
projectName="example-project"
@L04DB4L4NC3R
L04DB4L4NC3R / arch_std_install.md
Created May 16, 2020 13:10
ArchLinux Standard Installation

Installing Arch the Standard Way


Create a bootable pendrive

Run lsblk to see what is your pendrive

dd if= of=/dev/sd status="progress"
#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@dkhode
dkhode / jenkins-set-system-message.groovy
Created May 7, 2020 03:45
Jenkins - Set Jenkins system message via groovy script - #jenkins #groovy #system #message #html
#!groovy
// imports
import jenkins.model.Jenkins
// parameters
def systemMessage = '''
<h1><span style="background-color: #ff0000">Scheduled maintanence: Jenkins won't be available for use tonight @7pm CST</span></h1>
'''