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 / fedora-wsl.txt
Last active November 4, 2023 13:57
Fedora on WSL2
# From https://fedoramagazine.org/wsl-fedora-33/
# prompt ">" indicates Powershell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
> wsl --set-default-version 2
@kmatt
kmatt / LearnGoIn5mins.md
Created January 6, 2021 04:41 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
@kmatt
kmatt / Clickhouse-ranking.sql
Last active February 10, 2021 21:10 — forked from alexey-milovidov/rank.txt
Example of emulation of rank function with arrayEnumerateUniq.
/*
ClickHouse client version 1.1.53996.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.53996.
*/
:) CREATE TABLE IF NOT EXISTS `employee` (
:-] `empid` Int32,
:-] `deptid` Int32,
:-] `salary` Int64
@kmatt
kmatt / vd.py
Created November 9, 2020 18:31
Visidata as a terminal Pandas dataframe viewer
import pandas as pd
import visidata as vd
df=pd.read_csv('file.csv')
vd.view_pandas(df)
@kmatt
kmatt / slugify.postgres.sql
Last active February 1, 2023 12:51 — forked from abn/slugify.postgres.sql
A slugify function for postgres
-- original source: https://medium.com/adhawk-engineering/using-postgresql-to-generate-slugs-5ec9dd759e88
-- https://www.postgresql.org/docs/9.6/unaccent.html
CREATE EXTENSION IF NOT EXISTS unaccent;
CREATE OR REPLACE FUNCTION public.slugify(v TEXT) RETURNS TEXT
LANGUAGE plpgsql
STRICT IMMUTABLE AS
$function$
BEGIN
@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 / gist:af459f7cf3e43db1de63a87940432673
Created July 31, 2020 16:51
PostgreSQL JDBC: SSL client key format
openssl pkcs8 -nocrypt -topk8 -inform PEM -outform DER -in client-key.pem -out client-key.pk8
@kmatt
kmatt / simplenamespace.py
Created July 28, 2020 00:54
Python JSON to SimpleNamespace Object
obj = json.loads(json.dumps(js), object_hook=lambda x: Namespace(**x))
js = vars(obj) # obj.__dict__
@kmatt
kmatt / what-is-my-ip-tcpdump
Last active June 17, 2020 23:45
What is my IP tcpdump
# Host
$ tcpdump -i ${iface} -nn port 5555
# Client
$ telnet ${hostip} 5555
# https://github.com/docker/for-linux/issues/123#issuecomment-346546953
ip link add name docker0 type bridge
ip addr add dev docker0 172.17.0.1/16