Skip to content

Instantly share code, notes, and snippets.

@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"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:
@redmcg
redmcg / kubedf
Last active May 22, 2024 20:27
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")) | '\
@damonjw
damonjw / LICENSE
Last active March 23, 2024 10:28
Event driven simulator in Python, using async/await
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
@albulescu
albulescu / download.go
Created March 25, 2016 09:44
golang download file with progress
package main
/**
* @website http://albulescu.ro
* @author Cosmin Albulescu <cosmin@albulescu.ro>
*/
import (
"bytes"
"fmt"
@svanellewee
svanellewee / gist:c1f056800a16e189e63c
Created July 18, 2014 06:27
SO Clojure Increment Counter
;;For http://stackoverflow.com/questions/24798831/clojure-increment-a-counter
(ns hack1
;; (:use clojure.contrib.command-line)
)
(def collection-x ['({:customer_id "111", :product_id "222"})
'({:customer_id "333", :product_id "444"}{:customer_id "555", :product_id "666"}{:customer_id "777", :product_id "888"})] )
package main
import (
"fmt"
"reflect"
)
//function types
type mapf func(interface{}) interface{}
@kana
kana / lazy.js
Created April 9, 2013 09:57
Lazy evaluation in JavaScript
function delay(expressionAsFunction) {
var result;
var isEvaluated = false;
return function () {
if (!isEvaluated)
result = expressionAsFunction();
return result;
};
}