1. Various tools
    1. Drawing and diagramming
    2. Command line
  2. Mini-notes
    1. Bash
    2. Git
    3. Vim - useful advanced commands
    4. jq - sed for JSON

(For the index of Tools sub-pages see the parent page with its global index.)

Various tools

Drawing and diagramming

From text

WYSIWYG

  • yEd Graph Editor - "The interface is great. It’s portable. Lots of really cool tricks you can do with diagramming and graph transformations. Many graph import/export options. It has a java-based version that’s just a jar file." Automatic layout algorithms.

  • diagrams.net and its open source desktop client - "very feature rich and touch screen friendly, nice sketch and comic effects". Exports/imports many formats.

Command line

Quickly jump to a directory based on frequency/clever substring matching:

  • z (zsh, bash) - “z is the new j, yo” - also j2 and the fish clone z-fish

  • DirB, Directory Bookmarks for Bash (home) – moving efficiently among favourite directories (s <name> to create a bookmark for pwd, g <bookmark | relative/abs dir path> to enter a dir (⇒ works both for bookmarks and as a replacement for cd); also support for relative path bookmarks & more; sl lists bookmakrs in the last used order)

  • Autojump, described in Dec 11

Mini-notes

Bash

Loop with 0-padded numbers for a number of repetitions (using for and seq, from 1 to 50, outputting 01, 02, .., 50):

for i in $(seq -f '%02g' 1 50); do echo $i; done

Basic math in Bash (addition, ..; using let for a numerical var and $<expression> for math):

let num=0; echo $num; INC="1"; num=$((num+$INC)); echo $num

Git

  • Undo merge: git reset –hard ORIG_HEAD (the pointer ORIG_HEAD is set automatically by Git)

  • Unfo file changes: git co – path/to/file/to/reset [other/files/..]

  • git whatchanged master..

Vim - useful advanced commands

  • Change/delete a text region

    • (d|c)i<delim> - Delete|change text up to the given delimiting character; requires that you are inside pair delimiters such as “…” or (…); use ‘a’ to include the delimiters

  • Operations on selections (⇒ y to copy (yank), dto delete)

    • Select lines (e.g. for deletion via ‘d’): S-V

    • Select rectangle (e.g. to delete whitespace): C-V

  • Search and replace with confirmation: :%s/foo/bar/gc

jq - sed for JSON

Ex.: Extract nested structure with select, filter combination

// INPUT
{"name":"Sony Xperia Z3 Black",
 "dealerDetails":[
    {"dealerGroup":"webshop","rank":3},{"dealerGroup":"CustomerCentre","rank":3}]}
// COMMAND
jq '. | {name: .name, rank: (.dealerDetails|map(select(.dealerGroup == "webshop"))[0].rank)}'
// OUTPUT
{"name":"Sony Xperia Z3 Black","rank":3}

Copyright © 2024 Jakub Holý
Powered by Cryogen
Theme by KingMob