Skip to content

Instantly share code, notes, and snippets.

View kmatt's full-sized avatar
😐

Matt Keranen kmatt

😐
  • SE US
View GitHub Profile
@kmatt
kmatt / clickhousedump
Last active November 17, 2018 23:04 — forked from inkrement/clickhousedump
dump all clickhouse databases and tables
#!/bin/bash
OUTDIR=.
while read -r db; do
while read -r table ; do
if [ "$db" == "system" ]; then
echo "skip system db"
continue 2;
@kmatt
kmatt / thist.awk
Created June 13, 2018 19:13 — forked from dlp/thist.awk
Print a histogram to the terminal.
#!/usr/bin/gawk -f
###############################################################################
# Terminal Histogram
#
# Print a histogram to the terminal.
# Feed lines of single numbers to stdin, set size with W and H.
# If awk variable C is true, prints a cumulative (normalized) histogram
# (empirical distribution function).
#
# 2017, Daniel Prokesch <daniel.prokesch@gmail.com>

Minimal i3 Ubuntu 18.04

TL,DR

A fully fonctional and good-looking linux for less than 256mb of ram

Setting Up

Downloading and installing

Get the "mini.iso" image from archive.ubuntu.com

Legacy boot

Just flash an usb drive with it as follow.

sudo dd bs=4M if=mini.iso of=/dev/sd&gt; conv=fdatasync &amp;&amp; sync
@kmatt
kmatt / gzip_files_in_python.md
Created December 24, 2017 01:43 — forked from john-science/gzip_files_in_python.md
Reading & Writing GZIP Files Faster in Python

Reading & Writing GZIP Files in Python

I have been testing various ways to read and write text files with GZIP in Python. There were a lot of uninteresting results, but there were two I thought were worth sharing.

Writing GZIP files

If you have a big list of strings to write to a file, you might be tempted to do:

f = gzip.open(out_path, 'wb')

for line in lines:

@kmatt
kmatt / zfs
Created November 12, 2017 18:58 — forked from joshenders/zfs
/etc/sudoers.d/zfs
# Allow read-only ZoL commands to be called through sudo without a password.
# Cmnd alias specification
Cmnd_Alias RO_ZFS = \
/sbin/zfs "", /sbin/zfs help *, \
/sbin/zfs get, /sbin/zfs get *, \
/sbin/zfs list, /sbin/zfs list *, \
/sbin/zpool "", /sbin/zpool help *, \
/sbin/zpool iostat, /sbin/zpool iostat *, \
/sbin/zpool list, /sbin/zpool list *, \
@kmatt
kmatt / notify_slack_munin
Last active August 20, 2020 03:29 — forked from anarchivist/slack_munin.sh
Slack notification script for Munin
#!/bin/bash
# Slack notification script for Munin
# Original author: Mark Matienzo (@anarchivist)
#
# To use:
# 1) Create a new incoming webhook for Slack
# 2) Edit the configuration variables that start with "SLACK_" below
# 3) Add the following to your munin configuration:
#
@kmatt
kmatt / slack_munin.sh
Created March 2, 2017 17:01 — forked from hugochinchilla/slack_munin.sh
Slack notification script for Munin
#!/bin/bash
# Slack notification script for Munin
# Mark Matienzo (@anarchivist)
#
# To use:
# 1) Create a new incoming webhook for Slack
# 2) Edit the configuration variables that start with "SLACK_" below
# 3) Add the following to your munin configuration:
#
@kmatt
kmatt / gmail_imap_example.py
Created December 15, 2016 19:55 — forked from robulouski/gmail_imap_example.py
Very basic example of using Python and IMAP to iterate over emails in a gmail folder/label. http://www.voidynullness.net/blog/2013/07/25/gmail-email-with-python-via-imap/
#!/usr/bin/env python
#
# Very basic example of using Python and IMAP to iterate over emails in a
# gmail folder/label. This code is released into the public domain.
#
# RKI July 2013
# http://www.voidynullness.net/blog/2013/07/25/gmail-email-with-python-via-imap/
#
import sys
import imaplib
@kmatt
kmatt / bigquery_schema.py
Created August 8, 2016 20:22 — forked from danielecook/bigquery_schema.py
Sense / infer / generate a big query schema string for import #bigquery
import mimetypes
import sys
from collections import OrderedDict
filename = sys.argv[1]
def file_type(filename):
type = mimetypes.guess_type(filename)
return type
@kmatt
kmatt / table2plot.R
Created May 18, 2016 17:21 — forked from even4void/table2plot.R
A fake example for mixing text and graphic
display.cell <- function(x, bgcol="#DAE6F2", ...) {
opar <- par(bg=bgcol, mar=rep(0,4))
plot(c(0,1), c(0,1), type="n", axes=FALSE, xlab="", ylab="")
text(.5, .5, as.character(x), ...)
lines(c(-0.1,1.1), c(0,0))
par(opar)
}
format.digits <- function(x) as.character(paste("$", as.character(x), sep=" "))