Skip to content

Instantly share code, notes, and snippets.

View knbknb's full-sized avatar
💭
🙅‍♀️💡💤😴🛌🤪🧔

Knut Behrends knbknb

💭
🙅‍♀️💡💤😴🛌🤪🧔
  • Nothing to see here
  • Potsdam, Germany
View GitHub Profile
wget -O /tmp/YaHei.Consolas.1.12.zip https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/uigroupcode/YaHei.Consolas.1.12.zip
unzip /tmp/YaHei.Consolas.1.12.zip
sudo mkdir -p /usr/share/fonts/consolas
sudo mv YaHei.Consolas.1.12.ttf /usr/share/fonts/consolas/
sudo chmod 644 /usr/share/fonts/consolas/YaHei.Consolas.1.12.ttf
cd /usr/share/fonts/consolas
sudo mkfontscale && sudo mkfontdir && sudo fc-cache -fv
@knbknb
knbknb / mysql-vertical-result-EXPLAIN-extract-json.sh
Last active May 23, 2022 10:35
mysql: extract multiline vertical JSON output with perl and jq
#!/usr/bin/env bash
# query will onlny be explained, not executed
mysql --defaults-extra-file=$HOME/.mysql-credentials.cnf 2>/dev/null -Dworld -E -t<<EOF | perl -000 -nlE '/(?<=EXPLAIN:)(.*)/ms && say $1' | jq
EXPLAIN FORMAT=JSON SELECT * FROM city WHERE name = 'London';
EOF
# /* expected result:
# {
# "query_block": {
@knbknb
knbknb / mysql-multiline-statement.command.heredoc.sh
Last active May 23, 2022 09:12
Bash: multiline SQL statements for mysql with the heredoc syntax and vertical output
#!/usr/bin/env bash
mysql -u root -psecret -Dworld 2>/dev/null -E -t<<EOF
SELECT *
FROM city
WHERE NAME = 'amsterdam';
EOF
# /* expected result -- in vertical format */:
@knbknb
knbknb / div-figure-img-figcaption.html
Last active July 1, 2022 07:29
<figure> HTML Snippet for Embedding Image into Markdown docs, with CSS, etc
<style>
.myimagediv {
width: 100%;
}
/* .myimage {
filter: invert(14%) sepia(95%) saturate(6069%) hue-rotate(360deg) brightness(108%) contrast(117%);
}
*/
</style>
<div class="myimagediv">
@knbknb
knbknb / doi_resolver.py
Created May 19, 2022 13:31 — forked from mirekys/doi_resolver.py
Resolves a DOI identifier and returns record metadata in JSON format
#!/usr/bin/env python3
# pip install crossrefapi
from crossref.restful import Works
import requests
"""
Simple client for CrossRef DOI content negotiation
Tries to resolve a given DOI with CrossRef API.
If it fails (e.g. DOI is not minted by the CrossRef agency),
@knbknb
knbknb / uni2utf8.pl
Last active April 15, 2022 17:20
perl: humanreadable display of UTF-8 characters in terminal
#!/usr/bin/perl
# Convert \u1234 sequences (e.g. from Wikipedia)
# to characters the terminal can display.
#
# example call:
# curl -sL -H "Accept: text/turtle" "http://dbpedia.org/resource/Pudding" | uni2utf8.pl
use strict;
use warnings;
@knbknb
knbknb / NodeJS-Cheatsheet.js
Last active April 14, 2022 11:36 — forked from devmoreno/CheatCheat.js
Collection of Node.js Codesnippets, from various sources, 2016
// Node.js CheatSheet.
// Credit:
// forked from Github gist: devmoreno/CheatCheat.js
// source URL: https://gist.github.com/devmoreno/f8db88351bc10e2a82e02dc0b06e68dd
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
@knbknb
knbknb / ssh-tunnel-to-windowsbox.sh
Last active April 15, 2022 17:35
Open 2 Gnome terminals: _1: ssh--tunnel to linux-Jumpbox, _2: rdp to Windows Machine
#!/usr/bin/env bash
# create an SSH Tunnel to a Windows Remote Desktop machine via a sshd-jumpbox
# with SSH, local port fortwarding, and xfreerdp/rdesktop.
#
# last lines (xdotool ...) are optional
# they will open new gnome-terminal windows
#
# recommended step before
# ssh-agent add some-privatekey
#
@knbknb
knbknb / exa-config.sh
Last active April 10, 2022 09:15 — forked from louiskounios/exa-config.sh
exa useful aliases, and EXA_COLORS (/ LS_COLORS) config
alias ls='exa --classify --across'
alias l='exa --classify --oneline'
alias ll='exa --classify --long --group'
alias llg='exa --classify --long --grid --group'
alias tree='exa --classify --tree'
alias lrt='exa --classify --long --group --sort newest'
# When --long --grid are used at the same time, --grid will only apply if the
# resulting output will be at least EXA_GRID_ROWS long.
export EXA_GRID_ROWS=3
@knbknb
knbknb / checkerboard-mixin.scss
Created October 12, 2021 19:30
Checkerboard Pattern mixin - from L. Verou's book "CSS Secrets", 2015
@mixin checkerboard($size, $base, $accent: rgba(0,0,0, 0.26)) {
background: $base;
background-image: linear-gradient(
45deg,
$accent 25%,
transparent 0,
transparent 75%, $accent 0
),
linear-gradient(
45deg,