Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am lbn on github.
  • I am archeronl (https://keybase.io/archeronl) on keybase.
  • I have a public key ASC5zu7Bd9vcEuNu_YUa2XSHSiqnOisIp75ivGRI0MsHTAo

To claim this, I am signing this object:

@lbn
lbn / naive_app.py
Created November 10, 2016 22:45
Example Flask app with Prometheus running on a separate port
import socket
import logging as log
import threading
from http.server import HTTPServer
from flask import Flask
from prometheus_client import Summary, MetricsHandler
app = Flask("prom-gunicorn-ex")
@lbn
lbn / matprint.js
Last active April 28, 2024 11:25
Pretty print a matrix in ES6
"use strict"
function matprint(mat) {
let shape = [mat.length, mat[0].length];
function col(mat, i) {
return mat.map(row => row[i]);
}
let colMaxes = [];
for (let i = 0; i < shape[1]; i++) {
colMaxes.push(Math.max.apply(null, col(mat, i).map(n => n.toString().length)));
@lbn
lbn / matprint.py
Created November 7, 2015 12:32
Pretty print a matrix in Python 3 with numpy
def matprint(mat, fmt="g"):
col_maxes = [max([len(("{:"+fmt+"}").format(x)) for x in col]) for col in mat.T]
for x in mat:
for i, y in enumerate(x):
print(("{:"+str(col_maxes[i])+fmt+"}").format(y), end=" ")
print("")
# Try it!
import numpy as np
@lbn
lbn / .vimrc
Created September 14, 2015 11:02
My .vimrc on 14.09.2015
set tabstop=2
set shiftwidth=2
set expandtab
set t_Co=256
let g:solarized_termcolors=256
set background=dark
set cursorline
set cursorcolumn
set colorcolumn=80