Skip to content

Instantly share code, notes, and snippets.

@bdragon
bdragon / pod-logs.bash
Created Apr 29, 2021
Tail kubectl logs from multiple selected pods with colorized output.
View pod-logs.bash
#!/bin/bash
set -euo pipefail
# Tail kubectl logs from multiple selected pods with colorized output.
function usage() {
local name="$(basename "${BASH_SOURCE[0]}")"
echo "Synopsis:"
echo -e "\t$name -n NAMESPACE -l SELECTOR [ -- KUBECTL_LOGS_ARGS ]\n"
View lang_map.py
from typing import Mapping, Optional, Set, Tuple
# Graph is just a mapping whose keys are vertices and values are sets of edges
# leaving keys.
graph: Mapping[str, Set[Tuple[str, str]]] = dict()
# All keys in graph are normalized using this function.
def key(s: str) -> str:
return s.lower().replace("_", "-")
View concat.go
package main
import (
"fmt"
"reflect"
)
// concat returns a slice of type t that contains the specified items.
// Each item is appended according to its type: if it has type t, it is
// appended; if it is a slice of values of type t, each of its elements
View monadic.rb
# == Library code ===========================================
class Result
def self.success(value)
new(nil, value)
end
def self.error(err)
new(err, nil)
end
View loan-payment-data.json
[{"loan":{"id":1,"borrower_id":1,"amount":10984659,"term":120},"period":{"start_at":"2017-05-22T00:00:00-06:00","end_at":"2017-06-21T23:59:59-06:00"},"principal":57702,"interest":83752,"rate_annual":900,"service_fee":{"amount":0,"rate":0}},{"loan":{"id":1,"borrower_id":1,"amount":10984659,"term":120},"period":{"start_at":"2017-06-22T00:00:00-06:00","end_at":"2017-07-21T23:59:59-06:00"},"principal":56262,"interest":80629,"rate_annual":900,"service_fee":{"amount":0,"rate":0}},{"loan":{"id":1,"borrower_id":1,"amount":10984659,"term":120},"period":{"start_at":"2017-07-22T00:00:00-06:00","end_at":"2017-08-21T23:59:59-06:00"},"principal":58577,"interest":82877,"rate_annual":900,"service_fee":{"amount":0,"rate":0}},{"loan":{"id":1,"borrower_id":1,"amount":10984659,"term":120},"period":{"start_at":"2017-08-22T00:00:00-06:00","end_at":"2017-09-21T23:59:59-06:00"},"principal":59026,"interest":82428,"rate_annual":900,"service_fee":{"amount":0,"rate":0}},{"loan":{"id":1,"borrower_id":1,"amount":10984659,"term":120},"peri
@bdragon
bdragon / object.extend.js
Created Aug 7, 2013
Inheritance model with support for inheriting static properties, prototype properties, and ECMAScript 5 getters/setters, as well as for calling "super". See http://www.bryandragon.com/articles/playing-with-javascript-inheritance
View object.extend.js
/**
* Object.extend()
* @author Bryan Dragon
* @website www.bryandragon.com
* @license MIT License
*/
(function () {
'use strict';
var hasOwn = Object.prototype.hasOwnProperty
View mobile-viewport.js
/**
* mobile-viewport.js
*
* Simple script to hide the address bar on iPhone and iPod (when not in fullscreen app mode).
*/
(function () {
var ADDR_BAR_HEIGHT = 60,
app = document.getElementById('myDomEl'),
ua = navigator.userAgent,
iphone = ~ua.indexOf('iPhone') || ~ua.indexOf('iPod'),