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 / pg_flatten_json.sql
Created September 30, 2020 01:29 — forked from imamdigmi/pg_flatten_json.sql
Flattening json data in PostgreSQL
create or replace function create_jsonb_flat_view
(table_name text, regular_columns text, json_column text)
returns text language plpgsql as $$
declare
cols text;
begin
execute format ($ex$
select string_agg(format('%2$s->>%%1$L "%%1$s"', key), ', ')
from (
select distinct key
@kmatt
kmatt / colors
Created June 14, 2020 01:56 — forked from bohoomil/colors
show Xresources colours
#!/bin/sh
colors=($(xrdb -query | sed -n 's/.*color\([0-9]\)/\1/p' | sort -nu | cut -f2))
echo -e "\e[1;37m
Black Red Green Yellow Blue Magenta Cyan White
───────────────────────────────────────────────────────────────────────────────────────\e[0m"
for i in {0..7}; do echo -en "\e[$((30+$i))m █ ${colors[i]} \e[0m"; done
echo
for i in {8..15}; do echo -en "\e[1;$((22+$i))m █ ${colors[i]} \e[0m"; done
@kmatt
kmatt / xlcompare.py
Last active May 17, 2020 19:13 — forked from sanzoghenzo/compare.py
Compare Excel sheets with Pandas
"""
Compare two Excel sheets
Inspired by https://pbpython.com/excel-diff-pandas-update.html
For the documentation, download this file and type:
python compare.py --help
"""
import argparse
import pandas as pd
@kmatt
kmatt / spike-day-02-03-20.md
Created February 6, 2020 15:22 — forked from cldwalker/spike-day-02-03-20.md
GraalVM dive in Clojure at work

Spike

I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.

GraalVM Build Tools

@kmatt
kmatt / map_remote_ipmi_ports_to_loopback_ip.sh
Created December 10, 2019 16:35 — forked from sampowers/map_remote_ipmi_ports_to_loopback_ip.sh
SSH tunnel 127.0.0.2 to supermicro IPMI system
#!/bin/bash
set -x
#
# Purpose: Run on a workstation to make a remote IPMI controller available at http://127.0.0.2:80/
# Only does port mapping. IPMI controllers may have their own taxing browser requirements.
# Requires that you have a shell on a host that is on the same network as your IPMI interface.
shell='user@ssh-host-on-ipmi-network'
@kmatt
kmatt / gist:edacedcf66c2e4a0f667fc849f63c5af
Created January 7, 2019 19:25 — forked from mkocikowski/gist:aeca878d58d313e902bb
Setting up Redis to run as a daemon under systemd

This can be used to daemonize anything that would normally run in the foreground; I picked Redis. Put this in /etc/systemd/system/redis.service:

[Unit]
Description=Redis
After=syslog.target

[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
RestartSec=5s
@kmatt
kmatt / gist:80c24c7c44e4e46995cf2687a0ede0e0
Created November 17, 2018 03:08 — forked from gin1314/gist:3697341
bash: redirection cheat sheet
.---------------------------------------------------------------------------.
| |
| Bash Redirections Cheat Sheet |
| |
+---------------------------------------------------------------------------+
| |
| Created by Peteris Krumins (peter@catonmat.net) |
| www.catonmat.net -- good coders code, great coders reuse |
| |
+-----------------------------.---------------------------------------------+
@kmatt
kmatt / .Xresources
Created September 6, 2018 21:21 — forked from liangzan/.Xresources
Xresources for configuring urxvt
! urxvt
URxvt*buffered: true
URxvt*cursorBlink: true
URxvt*underlineColor: yellow
URxvt*font: xft:inconsolata:size=10:antialias=true
URxvt*depth: 32
URxvt*borderless: 1
URxvt*scrollBar: false
URxvt*loginShell: true
Urxvt*secondaryScroll: true # Enable Shift-PageUp/Down in screen
@kmatt
kmatt / nested.txt
Created August 27, 2018 18:33 — forked from alexey-milovidov/nested.txt
Example of Nested data type in ClickHouse.
:) CREATE TABLE test.nested (EventDate Date, UserID UInt64, Attrs Nested(Key String, Value String)) ENGINE = MergeTree(EventDate, UserID, 8192)
CREATE TABLE test.nested
(
EventDate Date,
UserID UInt64,
Attrs Nested(
Key String,
Value String)
) ENGINE = MergeTree(EventDate, UserID, 8192)
@kmatt
kmatt / zil_and_arc.sh
Created June 28, 2018 23:07 — forked from ianblenke/zil_and_arc.sh
FreeBSD ZFS: Putting a ZIL mirror and an L2ARC on only 2 SSD drives
#!/bin/bash
# Based on this blog post: https://clinta.github.io/FreeNAS-Multipurpose-SSD/
set -xe
ssd1=ada2
ssd2=ada3
pool=tank
gpart create -s gpt $ssd1
gpart create -s gpt $ssd2
gpart add -a 4k -b 128 -t freebsd-zfs -s 30G $ssd1