Skip to content

Instantly share code, notes, and snippets.

@svanellewee
svanellewee / aproducer.py
Created February 22, 2023 13:55 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@svanellewee
svanellewee / macos-multipass-docker.sh
Last active October 31, 2022 08:25 — forked from spuf/macos-multipass-docker.sh
macos multipass docker
brew install multipass
multipass launch lts -c 6 -d 20G -m 8G -n docker
multipass set client.primary-name=docker
multipass mount /Volumes/path/to/repo docker
multipass shell
curl -sSL https://get.docker.com/ | sh
echo '{"features": {"buildkit": true}}' > /etc/docker/daemon.json
# or if you have a local k8s cluster (ala microk8s)
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@svanellewee
svanellewee / kubedf
Created November 20, 2019 07:43 — forked from redmcg/kubedf
Bash script to show k8s PVC usage
#!/usr/bin/env bash
KUBEAPI=127.0.0.1:8001/api/v1/nodes
function getNodes() {
curl -s $KUBEAPI | jq -r '.items[].metadata.name'
}
function getPVCs() {
jq -s '[flatten | .[].pods[].volume[]? | select(has("pvcRef")) | '\
@svanellewee
svanellewee / myfirstbot.go
Created May 19, 2017 12:04 — forked from IndianGuru/myfirstbot.go
My First Telegram Bot
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
)

ert

(ert-deftest foo ()
  (assert nil))

Now: M-x ert RET foo RET

apropos

Emacs makes discovery easier.

@svanellewee
svanellewee / 01.js
Last active August 29, 2015 14:23 — forked from martinaglv/01.js
function whatDoesItDo(val){
return val ? 1 : 2;
}
function cons(x, y) {
return function(w) { return w(x, y) };
};
function car(z) {
return z(function(x, y) { return x });
};
function cdr(z) {
return z(function(x, y) { return y });