Skip to content

Instantly share code, notes, and snippets.

@miron
Last active January 3, 2026 14:24
Show Gist options
  • Select an option

  • Save miron/4997128 to your computer and use it in GitHub Desktop.

Select an option

Save miron/4997128 to your computer and use it in GitHub Desktop.

Revisions

  1. miron revised this gist Feb 12, 2023. 2 changed files with 9 additions and 7 deletions.
    8 changes: 4 additions & 4 deletions git.sh
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ git push --force (or git push -f) # all commits after reset will be deleted from
    git stash pop # reapply

    git rm #remove file from repository
    git svn clone ... ... # get the latest source from SVN ...
    git svn clone ... ... # get the latest source from SVN ...
    git checkout master # ...
    git svn rebase # ...
    git diff master # check differencies between modified and remote
    @@ -14,12 +14,12 @@ git revert HEAD # revert to previous, new commit
    git revert --no-commit 0766c053..HEAD # revert to commit ...
    git commit # and commit as HEAD ...
    git grep -z --full-name -l '.' | xargs -0 sed -i -e 's/old-text/new-text/ig' # find and replace text in all files of a repository
    git branch -m old_branch new_branch # Rename branch locally ...
    git branch -m old_branch new_branch # Rename branch locally ...
    git push origin :old_branch # Delete the old branch ...
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote ...
    gitk #gui for git
    gitk # gui for git

    If you worked in wrong branch
    # If you worked in wrong branch
    git stash
    git checkout main
    git stash apply
    8 changes: 5 additions & 3 deletions kb_misc
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    ## VIM ##
    :grep -Rn TODO . "grep through all TODOs and open first occurence
    :cn "switch to next occurence of TODO
    :cp "switch to previous occurence of TODO
    :make|!./%< "compile and execute programm
    :vsplit | ctrl+w+v "split verticaly
    :split | ctrl+w+s "split horizontaly
    @@ -113,11 +116,10 @@ NVAC (MCP79/MCP7A) #codename graphic card for nouveau driver
    # Win-` to open quake mode windows terminal
    # Delete windows installed keyboard:
    # https://superuser.com/questions/957552/how-to-delete-a-keyboard-layout-in-windows-10
    # use us international keyboard for umlauts:
    # use US international keyboard for umlauts:
    # " is dead key, use for ä,ü,ö,Ä,Ü,Ö,
    # right Alt-s for ß and right Alt-5 for €
    # Disable Zone Identifier
    # gpedit.msc User Configuration/Administrative Templates/Windows Components/Attachment Manager
    # "Do not preserve zone information in file attachments", Enabled

    cmd-shift-` #_switch between app-windows (german keyboard)
    # cmd-shift-` to switch between app-windows (german keyboard)
  2. miron revised this gist Jul 10, 2022. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion git.sh
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,9 @@ git grep -z --full-name -l '.' | xargs -0 sed -i -e 's/old-text/new-text/ig' # f
    git branch -m old_branch new_branch # Rename branch locally ...
    git push origin :old_branch # Delete the old branch ...
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote ...
    gitk #gui for git
    gitk #gui for git

    If you worked in wrong branch
    git stash
    git checkout main
    git stash apply
  3. miron revised this gist Jun 17, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    git update-git-for-windows # update to newest version on windows
    git stash # save local modifications
    git reset --hard 26b6d18 # hash before commit, destroys any local modifications!
    git push --force (or git push -f) # all commits after reset will be deleted from history
  4. miron revised this gist May 27, 2022. 13 changed files with 119 additions and 113 deletions.
    5 changes: 3 additions & 2 deletions cli.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,8 @@ help #brief summaries of builtin commands
    fc #open last commandline in editor
    kill -HUP $(ps -A -ostat,ppid | grep -e '[zZ]'| awk '{ print $2 }') #kill zombie processes
    echo $0 #show if login shell or not, login shell has -bash
    rm/cd ./-somefileordir #rm or cd file or dir with hyphen
    rm ./-somefileordir #remove file with hyphen
    cd ./-somefileordir #change into dir with hyphen
    type #type of command
    type -a program #show path to all versions of program
    export HISTTIMEFORMAT="%h/%d - %H:%M:%S " #shows date in historyfile
    @@ -30,7 +31,7 @@ yes foo > bar.txt #repeat some text (default is y) infinetly and save it to a fi
    strings #find the printable strings in a object, or other binary, file
    mkfifo --mode=0666 /tmp/namedPipe #load SQL commands ...
    gzip --stdout -d file.gz > /tmp/namedPipe #from gzipped file ...
    LOAD DATA INFILE '/tmp/namedPipe' INTO TABLE tableName; #into database ...
    LOAD DATA INFILE '/tmp/namedPipe' INTO TABLE tableName; #into database ...
    java -version #java version
    javac -version #java compiler version
    ant -version #java make tool version
    84 changes: 0 additions & 84 deletions editors
    Original file line number Diff line number Diff line change
    @@ -1,84 +0,0 @@
    ## VIM ##
    :make|!./%< "compile and execute programm
    :vsplit | ctrl+w+v "split verticaly
    :split | ctrl+w+s "split horizontaly
    ctrl+w+J,r,L "switch splits
    :so $MYVIMRC "reload .vimrc
    :so % "if editing
    :terminal "start terminal in vim
    :vertical terminal "start terminal in vertical split
    :term ./%< "run sourcecode in terminal
    :%s/foo/bar/g "substitute
    :ls "list buffers
    :buffers "list buffers
    :b "switch to buffer
    :bnext "switch to buffer
    :bprevious "switch to buffer
    :buffer <number> "switch to buffer
    :buffer <tab> "switch to buffer
    ctrl-w s ctrl-w T "buffers to tabs
    :tab ba "buffers to tabs
    :bufdo tab split "buffers to tabs
    gt "switch tabs
    :w !sudo tee % "write to read only
    :E rename files inside vim
    :set invlist #invisible characters in vim
    %s/ /^M/g #replace space with newline in vim (^M is Control-V Enter)
    C-v I# ESC #comment block
    C-o #paste in insert mode
    :Ex[plore] #open current file's directory in vim
    :noh #unhighlight search in vim
    :term # ctrl-w N terminal scrollback buffer!
    vim -c ':term ++curwin' #start vim as terminal in full screen

    ## VIM INSERT IN VSCODE AND PYCHARM ##
    # Ctrl-o h move cursor left
    # Ctrl-o l move cursor right
    # Ctrl-o j move cursor down
    # Ctrl-o k move cursor up
    # Ctrl-h backspace/delete
    # Ctrl-o x delete
    # Ctrl-o R replace mode
    # Ctrl-c or Esc exit replace mode
    # Ctrl-t indent
    # Ctrl-d unindent

    # VIM NORMAL IN VSCODE
    # f find forward, also works with df
    # F find backward, also works with dF
    # Ctrl-o, Ctrl-i jumplist (Ctrl-i brings you back)
    # Ctrl-/ to quickly comment/uncomment in vscode

    ## VSCODE ##
    # %% to create a notebook like cell in a python file in vscode, create new cell with Shift+Enter
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)
    # "justMyCode": false, to step into external modules
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # Ctrl+Shift+P toggleVim temporaly disable Vim keybindings
    # Ctrl+Shift+V render markdown, double click to switch back. disable vim keybindings first
    # Ctrl+K V view rendered markdown side by side

    ## PYCHARM ##
    Alt+4 # Focus Run window
    Ctrl-0 (mapped) # Run File
    Alt-= (mapped) # Focus Terminal
    Alt-Shift-E # execute curent line in terminal
    Ctrl+TAB # Focus and switch through open files...

    ## EMACS ##
    C-s #incremental search
    C-g #quit menu
    C-x b #switch buffer
    q #quit undo-tree
    C-x C-b #list buffers
    C-x 1 #close windows except cursor
    TAB #select from completion
    C-TAB #view list of M-x commands
    C-x k #kill buffer
    C-x o #switch to other window of buffers
    M-b #vims *, beginning of word
    C-s C-w #select word
    C-w #further selection of word if underscore
    C-s # ...
    File renamed without changes.
    2 changes: 1 addition & 1 deletion gh → gh.sh
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,4 @@ gh issue create -R owner/repo # create issue in specified repository
    gh issue create -m <name> # Add issue to a milestone by name
    # Automated in powershell for ($num =1 ; $num -le 365 ; $num++){ sleep 10 ; gh issue create -t 'learn python' -b ' ' -m python }
    gh issue list --search 'sort:created-asc' # list issues in ascending order
    gh issue close <number> # close issue
    gh issue close <number> # close issue
    2 changes: 1 addition & 1 deletion git → git.sh
    Original file line number Diff line number Diff line change
    @@ -16,4 +16,4 @@ git grep -z --full-name -l '.' | xargs -0 sed -i -e 's/old-text/new-text/ig' # f
    git branch -m old_branch new_branch # Rename branch locally ...
    git push origin :old_branch # Delete the old branch ...
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote ...
    gitk #gui for git
    gitk #gui for git
    File renamed without changes.
    106 changes: 105 additions & 1 deletion kb_misc
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,88 @@
    ## VIM ##
    :make|!./%< "compile and execute programm
    :vsplit | ctrl+w+v "split verticaly
    :split | ctrl+w+s "split horizontaly
    ctrl+w+J,r,L "switch splits
    :so $MYVIMRC "reload .vimrc
    :so % "if editing
    :terminal "start terminal in vim
    :vertical terminal "start terminal in vertical split
    :term ./%< "run sourcecode in terminal
    :%s/foo/bar/g "substitute
    :ls "list buffers
    :buffers "list buffers
    :b "switch to buffer
    :bnext "switch to buffer
    :bprevious "switch to buffer
    :buffer <number> "switch to buffer
    :buffer <tab> "switch to buffer
    ctrl-w s ctrl-w T "buffers to tabs
    :tab ba "buffers to tabs
    :bufdo tab split "buffers to tabs
    gt "switch tabs
    :w !sudo tee % "write to read only
    :E rename files inside vim
    :set invlist #invisible characters in vim
    %s/ /^M/g #replace space with newline in vim (^M is Control-V Enter)
    C-v I# ESC #comment block
    C-o #paste in insert mode
    :Ex[plore] #open current file's directory in vim
    :noh #unhighlight search in vim
    :term # ctrl-w N terminal scrollback buffer!
    vim -c ':term ++curwin' #start vim as terminal in full screen

    ## VIM INSERT IN VSCODE AND PYCHARM ##
    # Ctrl-o h move cursor left
    # Ctrl-o l move cursor right
    # Ctrl-o j move cursor down
    # Ctrl-o k move cursor up
    # Ctrl-h backspace/delete
    # Ctrl-o x delete
    # Ctrl-o R replace mode
    # Ctrl-c or Esc exit replace mode
    # Ctrl-t indent
    # Ctrl-d unindent

    # VIM NORMAL IN VSCODE
    # f find forward, also works with df
    # F find backward, also works with dF
    # Ctrl-o, Ctrl-i jumplist (Ctrl-i brings you back)
    # Ctrl-/ to quickly comment/uncomment in vscode

    ## VSCODE ##
    # %% to create a notebook like cell in a python file in vscode, create new cell with Shift+Enter
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)
    # "justMyCode": false, to step into external modules
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # Ctrl+Shift+P toggleVim temporaly disable Vim keybindings
    # Ctrl+Shift+V render markdown, double click to switch back. disable vim keybindings first
    # Ctrl+K V view rendered markdown side by side

    ## PYCHARM ##
    Alt+4 # Focus Run window
    Ctrl-0 (mapped) # Run File
    Alt-= (mapped) # Focus Terminal
    Alt-Shift-E # execute curent line in terminal
    Ctrl+TAB # Focus and switch through open files...

    ## EMACS ##
    C-s #incremental search
    C-g #quit menu
    C-x b #switch buffer
    q #quit undo-tree
    C-x C-b #list buffers
    C-x 1 #close windows except cursor
    TAB #select from completion
    C-TAB #view list of M-x commands
    C-x k #kill buffer
    C-x o #switch to other window of buffers
    M-b #vims *, beginning of word
    C-s C-w #select word
    C-w #further selection of word if underscore
    C-s # ...

    ## BASH ##
    ctrl-r #search history
    ctrl-r #cycle
    @@ -16,4 +101,23 @@ ctrl+arrow up/down #pan in feh
    ^a [ #scroll buffer (vim style navigation) screen
    ^ l #clearscreen (cmd-k clears every region) screen

    ^b :set -g status off #disable statusbar in tmux
    ^b :set -g status off #disable statusbar in tmux

    ## MAC OS ##
    cmd shift . #show hidden files in open dialog

    NVAC (MCP79/MCP7A) #codename graphic card for nouveau driver

    ## Windows ##
    # starting/switching windows with Win-<num> in the order pinned to your taskbar
    # Win-` to open quake mode windows terminal
    # Delete windows installed keyboard:
    # https://superuser.com/questions/957552/how-to-delete-a-keyboard-layout-in-windows-10
    # use us international keyboard for umlauts:
    # " is dead key, use for ä,ü,ö,Ä,Ü,Ö,
    # right Alt-s for ß and right Alt-5 for €
    # Disable Zone Identifier
    # gpedit.msc User Configuration/Administrative Templates/Windows Components/Attachment Manager
    # "Do not preserve zone information in file attachments", Enabled

    cmd-shift-` #_switch between app-windows (german keyboard)
    5 changes: 2 additions & 3 deletions macos → macos.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ brew install bash #enable autocd in macos ...
    echo /usr/local/bin/bash >> /etc/shells # ...
    chsh #change login shell #New shell: /usr/local/bin/bash ...
    mysql.server start #start mysql
    cmd shift . #show hidden files in open dialog

    xcrun -find #show path of commands inside Xcode
    /System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass <cmd> #operate on files in Timemachine
    cd /private/var/log/asl #speed up terminal in osx ...
    @@ -52,5 +52,4 @@ sips -g pixelWidth -g pixelHeight [image-file] #get picture dimensions
    /Applications/Utilities/Network Utility.app/Contents/Resources/stroke #mac os built-in port scanner
    defaults -currentHost write -globalDomain AppleFontSmoothing -int 2 #font smoothing
    defaults write com.apple.finder AppleShowAllFiles TRUE #show hidden files in finder and timemachine ...
    killall Finder # ...

    killall Finder # ...
    File renamed without changes.
    File renamed without changes.
    15 changes: 6 additions & 9 deletions powershell → powershell.ps1
    Original file line number Diff line number Diff line change
    @@ -21,14 +21,11 @@ kali run vi /mnt/c/Users/<user>/<file> # Edit file in powershell with vi in kali

    # Powershell in Linux
    # In /etc/ssh/sshd_config:
    Subsystem powershell /usr/bin/pwsh --sshs -NoLogo -NoProfile
    # In PS on Windows:
    New-PSSession -hostname <IP address> -username <username>
    # Enter Session:
    Enter-PSSession <Sessionnumber>
    # Close Session:
    Stop-Process -Id <ProcessId>
    # Remote Command:
    Invoke-Command -Session(Get-PSSession <Sessionnumber>) -ScriptBlock { uname -a }
    # Subsystem powershell /usr/bin/pwsh --sshs -NoLogo -NoProfile
    New-PSSession -hostname <IP address> -username <username> # In PS on Windows
    Enter-PSSession <Sessionnumber> # Enter Session
    Stop-Process -Id <ProcessId> # Close Session
    Invoke-Command -Session(Get-PSSession <Sessionnumber>) -ScriptBlock { uname -a } # Remote Command

    Expand-Archive <drive>\<path>\<file>.zip -DestinationPath <drive>\<path>\<directory> # unzip
    docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id #get IP address of container
    3 changes: 1 addition & 2 deletions system → system.sh
    Original file line number Diff line number Diff line change
    @@ -35,8 +35,7 @@ dpkg-query -W -f='${Status} ${Version}\n' ... #check if package is installed or
    cat /etc/issue #show linux distro
    lsb_release -a #show linux distro
    debconf-show #show configuration
    cmd-shift-` #_switch between app-windows (german keyboard)
    NVAC (MCP79/MCP7A) #codename graphic card for nouveau driver

    ps -p $$ #display current shell name
    lsblk #list partition inside WSL
    bpf_probe_read() #protects Linux from arbitrary memory
    10 changes: 0 additions & 10 deletions windows
    Original file line number Diff line number Diff line change
    @@ -1,10 +0,0 @@
    # starting/switching windows with Win-<num> in the order pinned to your taskbar
    # Win-` to open quake mode windows terminal
    # Delete windows installed keyboard:
    # https://superuser.com/questions/957552/how-to-delete-a-keyboard-layout-in-windows-10
    # use us international keyboard for umlauts:
    # " is dead key, use for ä,ü,ö,Ä,Ü,Ö,
    # right Alt-s for ß and right Alt-5 for €
    # Disable Zone Identifier
    # gpedit.msc User Configuration/Administrative Templates/Windows Components/Attachment Manager
    # "Do not preserve zone information in file attachments", Enabled
  5. miron revised this gist May 27, 2022. 2 changed files with 28 additions and 33 deletions.
    42 changes: 9 additions & 33 deletions cli → cli.sh
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,6 @@ shopt #shell options
    bind -P #print keybindings
    bash -x #print shellscript before executing, execute commands from file
    help #brief summaries of builtin commands
    ctrl-r #search history
    ctrl-r #cycle
    <cr> #run
    ←, → #edit
    ctrl-g #quit search
    fc #open last commandline in editor
    kill -HUP $(ps -A -ostat,ppid | grep -e '[zZ]'| awk '{ print $2 }') #kill zombie processes
    echo $0 #show if login shell or not, login shell has -bash
    @@ -31,8 +26,6 @@ man std::-->tab #c++ manpages
    base64 #encode and decode using base64 representation
    jq -r 'map(.Value | @base64d)' < file.json #decode base64 string of Value object
    pdftotext my.pdf - | grep 'pattern' #grep through pdfs without writing txt file
    arrow up/down #zoom in feh
    ctrl+arrow up/down #pan in feh
    yes foo > bar.txt #repeat some text (default is y) infinetly and save it to a file
    strings #find the printable strings in a object, or other binary, file
    mkfifo --mode=0666 /tmp/namedPipe #load SQL commands ...
    @@ -52,33 +45,16 @@ xpath #xml parser
    xmllint #xml parser
    locate -r "^\(.*/\)*header\.inc\.php$" #exact match
    sqlite3 #sqlite cli interface ...
    .databases #view databases ...
    .open FILENAME #connect to database file ...
    .tables #show tabes ...
    .mode html #switch to html mode ...
    .once FILENAME.html #query output to file ...
    SELECT * FROM TABLE; # write content from table to FILENAME.html...
    .quit #quit sqlite database ...
    .databases #view databases ...
    .open FILENAME #connect to database file ...
    .tables #show tabes ...
    .mode html #switch to html mode ...
    .once FILENAME.html #query output to file ...
    SELECT * FROM TABLE; # write content from table to FILENAME.html...
    .quit #quit sqlite database ...
    project.cj add overtone dep #overtone audio live coding
    lein deps # ...
    gibber #audiovisual live coding framework in javascript
    xclip -sel clip < ~/.ssh/id_rsa.pub #copy from file to clipboard

    # Start an ssh-server on a WSL client and remotely connect to it:
    sudo service start ssh start # on your wsl machine, starts the ssh daemon

    # Install gh in Kali, download deb:
    https://github.com/cli/cli/releases/latest
    apt install <packet>

    #screen
    ^a | #split verticaly in screen
    ^a TAB #switch region screen
    ^a c #create session screen
    ^a " #choose session screen
    ^a X #close region screen
    ^a Q #close all regions beside actual one screen
    ^a [ #scroll buffer (vim style navigation) screen
    ^ l #clearscreen (cmd-k clears every region) screen

    ^b :set -g status off #disable statusbar in tmux
    sudo service start ssh start # start ssh daemon on WSL client and remotely connect to it
    apt install <packet> # install gh in Kali, download deb: https://github.com/cli/cli/releases/latest
    19 changes: 19 additions & 0 deletions kb_misc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    ## BASH ##
    ctrl-r #search history
    ctrl-r #cycle
    ctrl-g #quit search

    arrow up/down #zoom in feh
    ctrl+arrow up/down #pan in feh

    #screen
    ^a | #split verticaly in screen
    ^a TAB #switch region screen
    ^a c #create session screen
    ^a " #choose session screen
    ^a X #close region screen
    ^a Q #close all regions beside actual one screen
    ^a [ #scroll buffer (vim style navigation) screen
    ^ l #clearscreen (cmd-k clears every region) screen

    ^b :set -g status off #disable statusbar in tmux
  6. miron revised this gist May 22, 2022. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions editors
    Original file line number Diff line number Diff line change
    @@ -61,10 +61,11 @@ vim -c ':term ++curwin' #start vim as terminal in full screen
    # Ctrl+K V view rendered markdown side by side

    ## PYCHARM ##
    # Focus Run window: Alt+4
    # Run File: Ctrl-0 (mapped)
    # Focus Terminal: Alt-= (mapped)
    # Alt-Shift-E execute curent line in terminal
    Alt+4 # Focus Run window
    Ctrl-0 (mapped) # Run File
    Alt-= (mapped) # Focus Terminal
    Alt-Shift-E # execute curent line in terminal
    Ctrl+TAB # Focus and switch through open files...

    ## EMACS ##
    C-s #incremental search
  7. miron revised this gist May 21, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    git reset --hard ABC # hash before commit, destroys any local modifications!
    git stash # save local modifications
    git reset --hard 26b6d18 # hash before commit, destroys any local modifications!
    git push --force (or git push -f) # all commits after reset will be deleted from history
    git stash pop # reapply

    git rm #remove file from repository
    git svn clone ... ... # get the latest source from SVN ...
  8. miron revised this gist May 21, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    git reset --hard ABC # hash before commit
    git reset --hard ABC # hash before commit, destroys any local modifications!
    git push --force (or git push -f) # all commits after reset will be deleted from history

    git rm #remove file from repository
  9. miron revised this gist May 8, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    git reset --hard ABC # hash before commit
    git push --force (or git push -f) # all commits after reset will be deleted from history

    git rm #remove file from repository
    git svn clone ... ... # get the latest source from SVN ...
  10. miron revised this gist May 7, 2022. 7 changed files with 22 additions and 25 deletions.
    2 changes: 0 additions & 2 deletions bpf
    Original file line number Diff line number Diff line change
    @@ -1,2 +0,0 @@
    bpf_probe_read() #protects Linux from arbitrary memory
    BPF_PROG_LOAD #verify and load a BPF program
    18 changes: 17 additions & 1 deletion cli
    Original file line number Diff line number Diff line change
    @@ -65,4 +65,20 @@ gibber #audiovisual live coding framework in javascript
    xclip -sel clip < ~/.ssh/id_rsa.pub #copy from file to clipboard

    # Start an ssh-server on a WSL client and remotely connect to it:
    sudo service start ssh start # on your wsl machine, starts the ssh daemon
    sudo service start ssh start # on your wsl machine, starts the ssh daemon

    # Install gh in Kali, download deb:
    https://github.com/cli/cli/releases/latest
    apt install <packet>

    #screen
    ^a | #split verticaly in screen
    ^a TAB #switch region screen
    ^a c #create session screen
    ^a " #choose session screen
    ^a X #close region screen
    ^a Q #close all regions beside actual one screen
    ^a [ #scroll buffer (vim style navigation) screen
    ^ l #clearscreen (cmd-k clears every region) screen

    ^b :set -g status off #disable statusbar in tmux
    1 change: 0 additions & 1 deletion docker
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id #get IP address of container
    11 changes: 0 additions & 11 deletions muxer
    Original file line number Diff line number Diff line change
    @@ -1,11 +0,0 @@
    #screen
    ^a | #split verticaly in screen
    ^a TAB #switch region screen
    ^a c #create session screen
    ^a " #choose session screen
    ^a X #close region screen
    ^a Q #close all regions beside actual one screen
    ^a [ #scroll buffer (vim style navigation) screen
    ^ l #clearscreen (cmd-k clears every region) screen
    #tmux
    ^b :set -g status off #disable statusbar in tmux
    5 changes: 1 addition & 4 deletions powershell
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,4 @@ Stop-Process -Id <ProcessId>
    # Remote Command:
    Invoke-Command -Session(Get-PSSession <Sessionnumber>) -ScriptBlock { uname -a }
    Expand-Archive <drive>\<path>\<file>.zip -DestinationPath <drive>\<path>\<directory> # unzip




    docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id #get IP address of container
    4 changes: 3 additions & 1 deletion system
    Original file line number Diff line number Diff line change
    @@ -38,4 +38,6 @@ debconf-show #show configuration
    cmd-shift-` #_switch between app-windows (german keyboard)
    NVAC (MCP79/MCP7A) #codename graphic card for nouveau driver
    ps -p $$ #display current shell name
    lsblk #list partition inside WSL
    lsblk #list partition inside WSL
    bpf_probe_read() #protects Linux from arbitrary memory
    BPF_PROG_LOAD #verify and load a BPF program
    6 changes: 1 addition & 5 deletions windows
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,4 @@
    # right Alt-s for ß and right Alt-5 for €
    # Disable Zone Identifier
    # gpedit.msc User Configuration/Administrative Templates/Windows Components/Attachment Manager
    # "Do not preserve zone information in file attachments", Enabled

    # Install gh in Kali, download deb:
    https://github.com/cli/cli/releases/latest
    apt install <packet>
    # "Do not preserve zone information in file attachments", Enabled
  11. miron renamed this gist May 7, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  12. miron revised this gist May 7, 2022. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions editors
    Original file line number Diff line number Diff line change
    @@ -53,11 +53,9 @@ vim -c ':term ++curwin' #start vim as terminal in full screen
    # %% to create a notebook like cell in a python file in vscode, create new cell with Shift+Enter
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)
    # "pythonArgs: ["-i"], in launch.json launches script in interactive console
    # "justMyCode": false, to step into external modules
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # --ignore=E731 Autopep8 Args, don't format my lambdas
    # Ctrl+Shift+P toggleVim temporaly disable Vim keybindings
    # Ctrl+Shift+V render markdown, double click to switch back. disable vim keybindings first
    # Ctrl+K V view rendered markdown side by side
  13. miron revised this gist May 7, 2022. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions CLI
    Original file line number Diff line number Diff line change
    @@ -63,9 +63,6 @@ project.cj add overtone dep #overtone audio live coding
    lein deps # ...
    gibber #audiovisual live coding framework in javascript
    xclip -sel clip < ~/.ssh/id_rsa.pub #copy from file to clipboard
    ^Z, fg # go from python interpreter to bash and back again.

    # Start an ssh-server on a WSL client and remotely connect to it:
    sudo service start ssh start # on your wsl machine, starts the ssh daemon


    sudo service start ssh start # on your wsl machine, starts the ssh daemon
  14. miron revised this gist May 7, 2022. 3 changed files with 10 additions and 10 deletions.
    8 changes: 6 additions & 2 deletions CLI
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    # create alias: gh alias set cheat 'gist view 4997128'
    # gh cheat | grep cheat -C 3, shows 3 lines before and after,
    # Windows Powershell: gh cheat | Select-String cheat

    bind -p | grep -v '^#\|self-insert\|^$' #list bash vim keybindings
    shopt #shell options
    bind -P #print keybindings
    @@ -62,6 +63,9 @@ project.cj add overtone dep #overtone audio live coding
    lein deps # ...
    gibber #audiovisual live coding framework in javascript
    xclip -sel clip < ~/.ssh/id_rsa.pub #copy from file to clipboard
    ^Z, fg # go from python interpreter to bash and back again.

    # Start an ssh-server on a WSL client and remotely connect to it:
    sudo service start ssh start # on your wsl machine, starts the ssh daemon


    # python interpreter:
    # ^Z, fg go to bash and back again.
    11 changes: 3 additions & 8 deletions powershell
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,7 @@
    wmic diskdrive list brief #list available disks
    wsl --mount <DiskPath> --bare #make disk available to wsl2
    lsblk #list partition inside WSL
    Get-WmiObject Win32_DiskDrive #list available disks
    Select-String cheat # powershell equivalent of grep

    $(ls dir/*.ext) # pass all files in dir as argument to cli-tool

    # Start an ssh-server on a WSL client and remotely connect to it:
    sudo service start ssh start # on your wsl machine, starts the ssh daemon
    wsl --mount <DiskPath> --bare #make disk available to wsl2
    $(ls dir/*.ext) # pass all files in dir as argument to cli-tools

    # forwards traffic from port 2222 on host to sshd port 22 on wsl client
    netsh interface portproxy add v4tov4 listenport=2222 listenaddress=0.0.0.0 connectport=22 connectaddress=localhost
    1 change: 1 addition & 0 deletions system
    Original file line number Diff line number Diff line change
    @@ -38,3 +38,4 @@ debconf-show #show configuration
    cmd-shift-` #_switch between app-windows (german keyboard)
    NVAC (MCP79/MCP7A) #codename graphic card for nouveau driver
    ps -p $$ #display current shell name
    lsblk #list partition inside WSL
  15. miron revised this gist May 7, 2022. 5 changed files with 8 additions and 11 deletions.
    11 changes: 4 additions & 7 deletions CLI
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    # grepable with inline comments.
    # create alias: gh alias set cheat 'gist view 4997128'
    # gh cheat | grep cheat -C 3, shows 3 lines before and after,
    # Windows Powershell: gh cheat | Select-String cheat
    bind -p | grep -v '^#\|self-insert\|^$' #list bash vim keybindings
    shopt #shell options
    bind -P #print keybindings
    @@ -18,10 +22,6 @@ export HISTTIMEFORMAT="%h/%d - %H:%M:%S " #shows date in historyfile
    printf \t \n ... #formated print with tab and newline
    grep -A 2 -B 3 foo README.txt # 2 lines before, 3 lines after
    grep -C 3 foo README.txt # 3 lines before and after
    # grepable with inline comments.
    # create alias: gh alias set cheat 'gist view 4997128'
    # gh cheat | grep cheat -C 3, shows 3 lines before and after,
    # Windows Powershell: gh cheat | Select-String cheat
    xprop |grep WM_CLASS #get x11 window classname
    echo "scale=2; x+y" | bc #calculations from cli, 2 decimals
    echo "x*y" | bc -l #calculations from cli
    @@ -41,9 +41,6 @@ java -version #java version
    javac -version #java compiler version
    ant -version #java make tool version
    mvn #java project management tool
    git #version control
    gitk #gui for git
    svn #subversion
    rcs #revision control system
    tee #pipe to STDOUT and file
    cal #display calendar
    1 change: 0 additions & 1 deletion commands
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@

    2 changes: 1 addition & 1 deletion gcc
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,4 @@ readelf --debug-dump=frames a.out #show table content
    hexdump -C a.out #ELF string
    readelf -hW a.out #ELF header
    g++ file.cpp -v #compilation flags
    readelf -lW a.out #ELF segments
    readelf -lW a.out #ELF segments
    1 change: 1 addition & 0 deletions git
    Original file line number Diff line number Diff line change
    @@ -12,3 +12,4 @@ git grep -z --full-name -l '.' | xargs -0 sed -i -e 's/old-text/new-text/ig' # f
    git branch -m old_branch new_branch # Rename branch locally ...
    git push origin :old_branch # Delete the old branch ...
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote ...
    gitk #gui for git
    4 changes: 2 additions & 2 deletions jekyll
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    bundle update github-pages #update to newest gems for github-pages inside repo ...
    gem update github-pages # dito ...
    bundle info --path minima #show where gem is located in procect
    bundle info --path minima #show where gem is located in project
    https://api.github.com/emojis # markdown emojis :om:
    git clone git@github.com:4997128.git #clone gist over ssh, add files like images, commit, push
    git clone git@github.com:4997128.git #clone gist over ssh, add files like images, commit, push
  16. miron revised this gist May 7, 2022. 3 changed files with 71 additions and 70 deletions.
    70 changes: 70 additions & 0 deletions CLI
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    bind -p | grep -v '^#\|self-insert\|^$' #list bash vim keybindings
    shopt #shell options
    bind -P #print keybindings
    bash -x #print shellscript before executing, execute commands from file
    help #brief summaries of builtin commands
    ctrl-r #search history
    ctrl-r #cycle
    <cr> #run
    ←, → #edit
    ctrl-g #quit search
    fc #open last commandline in editor
    kill -HUP $(ps -A -ostat,ppid | grep -e '[zZ]'| awk '{ print $2 }') #kill zombie processes
    echo $0 #show if login shell or not, login shell has -bash
    rm/cd ./-somefileordir #rm or cd file or dir with hyphen
    type #type of command
    type -a program #show path to all versions of program
    export HISTTIMEFORMAT="%h/%d - %H:%M:%S " #shows date in historyfile
    printf \t \n ... #formated print with tab and newline
    grep -A 2 -B 3 foo README.txt # 2 lines before, 3 lines after
    grep -C 3 foo README.txt # 3 lines before and after
    # grepable with inline comments.
    # create alias: gh alias set cheat 'gist view 4997128'
    # gh cheat | grep cheat -C 3, shows 3 lines before and after,
    # Windows Powershell: gh cheat | Select-String cheat
    xprop |grep WM_CLASS #get x11 window classname
    echo "scale=2; x+y" | bc #calculations from cli, 2 decimals
    echo "x*y" | bc -l #calculations from cli
    sudo -s #stay in directory when sudo
    man std::-->tab #c++ manpages
    base64 #encode and decode using base64 representation
    jq -r 'map(.Value | @base64d)' < file.json #decode base64 string of Value object
    pdftotext my.pdf - | grep 'pattern' #grep through pdfs without writing txt file
    arrow up/down #zoom in feh
    ctrl+arrow up/down #pan in feh
    yes foo > bar.txt #repeat some text (default is y) infinetly and save it to a file
    strings #find the printable strings in a object, or other binary, file
    mkfifo --mode=0666 /tmp/namedPipe #load SQL commands ...
    gzip --stdout -d file.gz > /tmp/namedPipe #from gzipped file ...
    LOAD DATA INFILE '/tmp/namedPipe' INTO TABLE tableName; #into database ...
    java -version #java version
    javac -version #java compiler version
    ant -version #java make tool version
    mvn #java project management tool
    git #version control
    gitk #gui for git
    svn #subversion
    rcs #revision control system
    tee #pipe to STDOUT and file
    cal #display calendar
    tidy #html parser
    fmt #format text (TEX)
    textutil #convert document-files
    xpath #xml parser
    xmllint #xml parser
    locate -r "^\(.*/\)*header\.inc\.php$" #exact match
    sqlite3 #sqlite cli interface ...
    .databases #view databases ...
    .open FILENAME #connect to database file ...
    .tables #show tabes ...
    .mode html #switch to html mode ...
    .once FILENAME.html #query output to file ...
    SELECT * FROM TABLE; # write content from table to FILENAME.html...
    .quit #quit sqlite database ...
    project.cj add overtone dep #overtone audio live coding
    lein deps # ...
    gibber #audiovisual live coding framework in javascript
    xclip -sel clip < ~/.ssh/id_rsa.pub #copy from file to clipboard

    # python interpreter:
    # ^Z, fg go to bash and back again.
    23 changes: 0 additions & 23 deletions bash
    Original file line number Diff line number Diff line change
    @@ -1,23 +0,0 @@
    bind -p | grep -v '^#\|self-insert\|^$' #list bash vim keybindings
    shopt #shell options
    bind -P #print keybindings
    bash -x #print shellscript before executing, execute commands from file
    help #brief summaries of builtin commands
    ctrl-r #search history
    ctrl-r #cycle
    <cr> #run
    ←, → #edit
    ctrl-g #quit search
    fc #open last commandline in editor
    kill -HUP $(ps -A -ostat,ppid | grep -e '[zZ]'| awk '{ print $2 }') #kill zombie processes
    echo $0 #show if login shell or not, login shell has -bash
    rm/cd ./-somefileordir #rm or cd file or dir with hyphen
    type #type of command
    type -a program #show path to all versions of program
    export HISTTIMEFORMAT="%h/%d - %H:%M:%S " #shows date in historyfile
    printf \t \n ... #formated print with tab and newline
    grep -A 2 -B 3 foo README.txt # 2 lines before, 3 lines after
    grep -C 3 foo README.txt # 3 lines before and after

    # python interpreter:
    # ^Z, fg go to bash and back again.
    48 changes: 1 addition & 47 deletions commands
    Original file line number Diff line number Diff line change
    @@ -1,47 +1 @@
    # grepable with inline comments.
    # create alias: gh alias set cheat 'gist view 4997128'
    # gh cheat | grep cheat -C 3, shows 3 lines before and after,
    # Windows Powershell: gh cheat | Select-String cheat
    xprop |grep WM_CLASS #get x11 window classname
    echo "scale=2; x+y" | bc #calculations from cli, 2 decimals
    echo "x*y" | bc -l #calculations from cli
    sudo -s #stay in directory when sudo
    man std::-->tab #c++ manpages
    base64 #encode and decode using base64 representation
    jq -r 'map(.Value | @base64d)' < file.json #decode base64 string of Value object
    pdftotext my.pdf - | grep 'pattern' #grep through pdfs without writing txt file
    arrow up/down #zoom in feh
    ctrl+arrow up/down #pan in feh
    yes foo > bar.txt #repeat some text (default is y) infinetly and save it to a file
    strings #find the printable strings in a object, or other binary, file
    mkfifo --mode=0666 /tmp/namedPipe #load SQL commands ...
    gzip --stdout -d file.gz > /tmp/namedPipe #from gzipped file ...
    LOAD DATA INFILE '/tmp/namedPipe' INTO TABLE tableName; #into database ...
    java -version #java version
    javac -version #java compiler version
    ant -version #java make tool version
    mvn #java project management tool
    git #version control
    gitk #gui for git
    svn #subversion
    rcs #revision control system
    tee #pipe to STDOUT and file
    cal #display calendar
    tidy #html parser
    fmt #format text (TEX)
    textutil #convert document-files
    xpath #xml parser
    xmllint #xml parser
    locate -r "^\(.*/\)*header\.inc\.php$" #exact match
    sqlite3 #sqlite cli interface ...
    .databases #view databases ...
    .open FILENAME #connect to database file ...
    .tables #show tabes ...
    .mode html #switch to html mode ...
    .once FILENAME.html #query output to file ...
    SELECT * FROM TABLE; # write content from table to FILENAME.html...
    .quit #quit sqlite database ...
    project.cj add overtone dep #overtone audio live coding
    lein deps # ...
    gibber #audiovisual live coding framework in javascript
    xclip -sel clip < ~/.ssh/id_rsa.pub #copy from file to clipboard

  17. miron revised this gist May 7, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions editors
    Original file line number Diff line number Diff line change
    @@ -58,6 +58,9 @@ vim -c ':term ++curwin' #start vim as terminal in full screen
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # --ignore=E731 Autopep8 Args, don't format my lambdas
    # Ctrl+Shift+P toggleVim temporaly disable Vim keybindings
    # Ctrl+Shift+V render markdown, double click to switch back. disable vim keybindings first
    # Ctrl+K V view rendered markdown side by side

    ## PYCHARM ##
    # Focus Run window: Alt+4
  18. miron revised this gist Apr 29, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions powershell
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,8 @@ Enter-PSSession <Sessionnumber>
    Stop-Process -Id <ProcessId>
    # Remote Command:
    Invoke-Command -Session(Get-PSSession <Sessionnumber>) -ScriptBlock { uname -a }
    Expand-Archive <drive>\<path>\<file>.zip -DestinationPath <drive>\<path>\<directory> # unzip




  19. miron revised this gist Apr 29, 2022. 1 changed file with 0 additions and 60 deletions.
    60 changes: 0 additions & 60 deletions python
    Original file line number Diff line number Diff line change
    @@ -1,60 +0,0 @@
    # Making IPython more bearable
    ipython --TerminalInteractiveShell.editing_mode=vi # selfexplaining
    from IPython.terminal.prompts import Prompts, Token
    class MyPrompt(Prompts):
    def in_prompt_tokens(self, cli=None):
    return [ ( Token.Prompt, "λ ",), ]
    def out_prompt_tokens(self, cli=None):
    return []
    ip = get_ipython()
    ip.prompts = MyPrompt(ip) # A minimal prompt

    from subprocess import run, sys; run([sys.executable, '-m', 'pip', 'install', '<packagename>']) # install module from within python shell
    from subprocess import run; run('pip install <packagename>', shell=True) # shorter version
    from subprocess import run; run(['pip', 'install', '<packagename>']) # yes, shorter
    import os; f = os.path.join.(os.getcwd(), 'file.txt'); os.chmod(f, 0o600) # change file to rw for owner only

    import psutil; psutil.Process().memory_info().rss/(1024 ** 2) # show memory size of running python shell in MB
    import os; os.getcwd() # view current directory
    send2trash.exe # python programm that sends files to trash instead of deleting it permanently
    curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 # Install latest pip, python3-pip has dependencies to python3 packages
    python -m site # show site-package directories

    import this # Zen of Python
    import antigravity # You are flying! How?
    os.environ['HOME'] # Get environment variable
    os.environ.get('HOME') # sam, but different, but same
    os.getenv('HOME') # Wrapper to os.environ.get('HOME')

    pydoc <modulename> # offline documentation in the terminal like help() in the python shell

    with open('filename') as f:
    read_data = f.read()
    with open('filename', 'w') as f:
    f.write("#First Line\n" + read_data) # insert at beginning of file

    @classmethod # class method constructor with cls as parameter
    @staticmethod # a static method with no arguments
    @dataclass # define fields to include parameters and methods like __init__(), __repr__, ___eq___, some default to true already. Less typing
    youtube-dl -f bestvideo-bestaudio "url" # download best versions of your videos
    print("\033c", end='') # clear screen in REPL
    set editing-mode vi in .inputrc, clear screen with ESC Ctrl-L in REPL

    # max() with lambda function as key parameter, list comprehension, str.split() and dict.get(), - before dict reverses order
    max([word for word in 'Who is the richest, Bill Gates, Jeff Bezos, Warren Buffet, Mark Zuckerberg or Elon Musk?'.split()],
    key=lambda k: {'Warren': 124.3, 'Bill': 132.3, 'Elon': 264.6, 'Jeff': 177.5, 'Mark': 75.2}.get(k,0))

    import string; [ord(char) for char in string.ascii_uppercase] # show unicode code point values (order)

    (lambda p: (w := [c.lower()for c in p if c.isalpha()]) == w[::-1])('') # palindrome checker, put string in last parenthesis
    (lambda p: (w := [c.lower()for c in p if c.isalpha()]).__eq__(w[::-1]))('')
    (lambda p: (w := [map(str.lower, (c for c in p if c.isalpha()))]) == w[::-1])('')

    print("You have", coins:=5, f'coin{"s" if coins !=1 else ""}') # singular/plural
    sum([num < 0 for num in [-1, -2, 3, 4]]) # occurencies of negative numbers

    python -im pdb /dev/null # just start the python debugger
    python -im pdb nul # same in powershell
    {str(n):n for n in range(1,11)} # generate dict of numbers with string of number as keys
    {**{str(n):n for n in range(2,11)},'A': [11,1], 'K': 10, 'Q': 10, 'J': 10} # unpack dict into dict
    {k: {'a':1, 'b':2, 'c':3, 'd':4}[k] for k in ['b','d']} # filter dict with keys in list
  20. miron revised this gist Apr 29, 2022. 1 changed file with 6 additions and 8 deletions.
    14 changes: 6 additions & 8 deletions python
    Original file line number Diff line number Diff line change
    @@ -33,12 +33,12 @@ with open('filename') as f:
    with open('filename', 'w') as f:
    f.write("#First Line\n" + read_data) # insert at beginning of file

    @classmethod # class method constructor with cls as parameter
    @staticmethod # a static method with no arguments
    @dataclass # define fields to include parameters and methods like __init__(), __repr__, ___eq___, some default to true already. Less typing
    youtube-dl -f bestvideo-bestaudio "url" # download best versions of your videos
    print("\033c", end='') # clear screen in REPL
    set editing-mode vi in .inputrc, clear screen with ESC Ctrl-L in REPL
    @classmethod # class method constructor with cls as parameter
    @staticmethod # a static method with no arguments
    @dataclass # define fields to include parameters and methods like __init__(), __repr__, ___eq___, some default to true already. Less typing
    youtube-dl -f bestvideo-bestaudio "url" # download best versions of your videos
    print("\033c", end='') # clear screen in REPL
    set editing-mode vi in .inputrc, clear screen with ESC Ctrl-L in REPL

    # max() with lambda function as key parameter, list comprehension, str.split() and dict.get(), - before dict reverses order
    max([word for word in 'Who is the richest, Bill Gates, Jeff Bezos, Warren Buffet, Mark Zuckerberg or Elon Musk?'.split()],
    @@ -58,5 +58,3 @@ python -im pdb nul # same in powershell
    {str(n):n for n in range(1,11)} # generate dict of numbers with string of number as keys
    {**{str(n):n for n in range(2,11)},'A': [11,1], 'K': 10, 'Q': 10, 'J': 10} # unpack dict into dict
    {k: {'a':1, 'b':2, 'c':3, 'd':4}[k] for k in ['b','d']} # filter dict with keys in list


  21. miron revised this gist Apr 29, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions python
    Original file line number Diff line number Diff line change
    @@ -57,4 +57,6 @@ python -im pdb /dev/null # just start the python debugger
    python -im pdb nul # same in powershell
    {str(n):n for n in range(1,11)} # generate dict of numbers with string of number as keys
    {**{str(n):n for n in range(2,11)},'A': [11,1], 'K': 10, 'Q': 10, 'J': 10} # unpack dict into dict
    {k: {'a':1, 'b':2, 'c':3, 'd':4}[k] for k in ['b','d']} # filter dict with keys in list


  22. miron revised this gist Apr 29, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions python
    Original file line number Diff line number Diff line change
    @@ -56,3 +56,5 @@ sum([num < 0 for num in [-1, -2, 3, 4]]) # occurencies of negative numbers
    python -im pdb /dev/null # just start the python debugger
    python -im pdb nul # same in powershell
    {str(n):n for n in range(1,11)} # generate dict of numbers with string of number as keys
    {**{str(n):n for n in range(2,11)},'A': [11,1], 'K': 10, 'Q': 10, 'J': 10} # unpack dict into dict

  23. miron revised this gist Apr 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion python
    Original file line number Diff line number Diff line change
    @@ -55,4 +55,4 @@ sum([num < 0 for num in [-1, -2, 3, 4]]) # occurencies of negative numbers

    python -im pdb /dev/null # just start the python debugger
    python -im pdb nul # same in powershell

    {str(n):n for n in range(1,11)} # generate dict of numbers with string of number as keys
  24. miron revised this gist Apr 28, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions python
    Original file line number Diff line number Diff line change
    @@ -53,4 +53,6 @@ import string; [ord(char) for char in string.ascii_uppercase] # show unicode cod
    print("You have", coins:=5, f'coin{"s" if coins !=1 else ""}') # singular/plural
    sum([num < 0 for num in [-1, -2, 3, 4]]) # occurencies of negative numbers

    python -im pdb /dev/null # just start the python debugger
    python -im pdb nul # same in powershell

  25. miron revised this gist Apr 27, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion python
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,7 @@ import string; [ord(char) for char in string.ascii_uppercase] # show unicode cod
    (lambda p: (w := [c.lower()for c in p if c.isalpha()]).__eq__(w[::-1]))('')
    (lambda p: (w := [map(str.lower, (c for c in p if c.isalpha()))]) == w[::-1])('')

    print("You have", coins:=5, f'coin{"s" if coins !=1 else ""}') # singular/plural
    print("You have", coins:=5, f'coin{"s" if coins !=1 else ""}') # singular/plural
    sum([num < 0 for num in [-1, -2, 3, 4]]) # occurencies of negative numbers


  26. miron revised this gist Apr 27, 2022. 2 changed files with 6 additions and 9 deletions.
    15 changes: 6 additions & 9 deletions editors
    Original file line number Diff line number Diff line change
    @@ -53,21 +53,18 @@ vim -c ':term ++curwin' #start vim as terminal in full screen
    # %% to create a notebook like cell in a python file in vscode, create new cell with Shift+Enter
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)

    ## PYCHARM
    # Focus Run window: Alt+4
    # Run File: Ctrl-0 (mapped)
    # Focus Terminal: Alt-= (mapped)
    # Alt-Shift-E execute curent line in terminal



    # "pythonArgs: ["-i"], in launch.json launches script in interactive console
    # "justMyCode": false, to step into external modules
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # --ignore=E731 Autopep8 Args, don't format my lambdas

    ## PYCHARM ##
    # Focus Run window: Alt+4
    # Run File: Ctrl-0 (mapped)
    # Focus Terminal: Alt-= (mapped)
    # Alt-Shift-E execute curent line in terminal

    ## EMACS ##
    C-s #incremental search
    C-g #quit menu
    Empty file removed emacs
    Empty file.
  27. miron revised this gist Apr 27, 2022. 3 changed files with 29 additions and 21 deletions.
    5 changes: 4 additions & 1 deletion bash
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,7 @@ type -a program #show path to all versions of program
    export HISTTIMEFORMAT="%h/%d - %H:%M:%S " #shows date in historyfile
    printf \t \n ... #formated print with tab and newline
    grep -A 2 -B 3 foo README.txt # 2 lines before, 3 lines after
    grep -C 3 foo README.txt # 3 lines before and after
    grep -C 3 foo README.txt # 3 lines before and after

    # python interpreter:
    # ^Z, fg go to bash and back again.
    31 changes: 25 additions & 6 deletions editors
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,7 @@ vim -c ':term ++curwin' #start vim as terminal in full screen
    # Ctrl-c or Esc exit replace mode
    # Ctrl-t indent
    # Ctrl-d unindent

    # VIM NORMAL IN VSCODE
    # f find forward, also works with df
    # F find backward, also works with dF
    @@ -50,17 +51,35 @@ vim -c ':term ++curwin' #start vim as terminal in full screen

    ## VSCODE ##
    # %% to create a notebook like cell in a python file in vscode, create new cell with Shift+Enter
    # Pycharm:
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)

    ## PYCHARM
    # Focus Run window: Alt+4
    # Run File: Ctrl-0 (mapped)
    # Focus Terminal: Alt-= (mapped)
    # Alt-Shift-E execute curent line in terminal
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)
    # python interpreter:
    # ^Z, fg go to bash and back again.



    # "pythonArgs: ["-i"], in launch.json launches script in interactive console
    # "justMyCode": false, to step into external modules
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # --ignore=E731 Autopep8 Args, don't format my lambdas
    # --ignore=E731 Autopep8 Args, don't format my lambdas

    ## EMACS ##
    C-s #incremental search
    C-g #quit menu
    C-x b #switch buffer
    q #quit undo-tree
    C-x C-b #list buffers
    C-x 1 #close windows except cursor
    TAB #select from completion
    C-TAB #view list of M-x commands
    C-x k #kill buffer
    C-x o #switch to other window of buffers
    M-b #vims *, beginning of word
    C-s C-w #select word
    C-w #further selection of word if underscore
    C-s # ...
    14 changes: 0 additions & 14 deletions emacs
    Original file line number Diff line number Diff line change
    @@ -1,14 +0,0 @@
    C-s #incremental search
    C-g #quit menu
    C-x b #switch buffer
    q #quit undo-tree
    C-x C-b #list buffers
    C-x 1 #close windows except cursor
    TAB #select from completion
    C-TAB #view list of M-x commands
    C-x k #kill buffer
    C-x o #switch to other window of buffers
    M-b #vims *, beginning of word
    C-s C-w #select word
    C-w #further selection of word if underscore
    C-s # ...
  28. miron revised this gist Apr 27, 2022. 2 changed files with 27 additions and 29 deletions.
    35 changes: 27 additions & 8 deletions vim → editors
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ## VIM ##
    :make|!./%< "compile and execute programm
    :vsplit | ctrl+w+v "split verticaly
    :split | ctrl+w+s "split horizontaly
    @@ -30,18 +31,36 @@ C-o #paste in insert mode
    :term # ctrl-w N terminal scrollback buffer!
    vim -c ':term ++curwin' #start vim as terminal in full screen

    # Vim insert mode in vscode and pycharm:
    ## VIM INSERT IN VSCODE AND PYCHARM ##
    # Ctrl-o h move cursor left
    # Ctrl-o l move cursor right
    # Ctrl-o j move cursor down
    # Ctrl-o k move cursor up
    # Ctrl-h backspace/delete
    # Ctrl-o x delete
    # Ctrl-o R replace mode
    Ctrl-c or Esc exit replace mode
    Ctrl-t indent
    Ctrl-d unindent
    Vim normal mode in vscode:
    f find forward, also works with df
    F find backward, also works with dF
    Ctrl-o, Ctrl-i jumplist (Ctrl-i brings you back)
    # Ctrl-c or Esc exit replace mode
    # Ctrl-t indent
    # Ctrl-d unindent
    # VIM NORMAL IN VSCODE
    # f find forward, also works with df
    # F find backward, also works with dF
    # Ctrl-o, Ctrl-i jumplist (Ctrl-i brings you back)
    # Ctrl-/ to quickly comment/uncomment in vscode

    ## VSCODE ##
    # %% to create a notebook like cell in a python file in vscode, create new cell with Shift+Enter
    # Pycharm:
    # Focus Run window: Alt+4
    # Run File: Ctrl-0 (mapped)
    # Focus Terminal: Alt-= (mapped)
    # Alt-Shift-E execute curent line in terminal
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)
    # python interpreter:
    # ^Z, fg go to bash and back again.
    # "pythonArgs: ["-i"], in launch.json launches script in interactive console
    # "justMyCode": false, to step into external modules
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # --ignore=E731 Autopep8 Args, don't format my lambdas
    21 changes: 0 additions & 21 deletions python
    Original file line number Diff line number Diff line change
    @@ -9,27 +9,6 @@ class MyPrompt(Prompts):
    ip = get_ipython()
    ip.prompts = MyPrompt(ip) # A minimal prompt


    # %% to create a notebook like cell in a python file in vscode, create new cell with Shift+Enter
    # Pycharm:
    # Focus Run window: Alt+4
    # Run File: Ctrl-0 (mapped)
    # Focus Terminal: Alt-= (mapped)
    # Alt-Shift-E execute curent line in terminal
    Pycharm, vscode
    Ctrl-/ to quickly comment/uncomment in vscode
    # vscode:
    # ctrl-1 focus editor
    # ctrl=w j focus terminal (vim keybindings)
    # python interpreter:
    # ^Z, fg go to bash and back again.
    # "pythonArgs: ["-i"], in launch.json launches script in interactive console
    # "justMyCode": false, to step into external modules
    # "cwd": "${fileDirname}", run debugger in directory of script
    # "stopOnEntry": true, break at entry point of script
    # --ignore=E731 Autopep8 Args, don't format my lambdas


    from subprocess import run, sys; run([sys.executable, '-m', 'pip', 'install', '<packagename>']) # install module from within python shell
    from subprocess import run; run('pip install <packagename>', shell=True) # shorter version
    from subprocess import run; run(['pip', 'install', '<packagename>']) # yes, shorter
  29. miron revised this gist Apr 25, 2022. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions powershell
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,17 @@ cd \\wsl$\kali-linux # go to directory of wsl distro

    kali run vi /mnt/c/Users/<user>/<file> # Edit file in powershell with vi in kali wsl

    # Powershell in Linux
    # In /etc/ssh/sshd_config:
    Subsystem powershell /usr/bin/pwsh --sshs -NoLogo -NoProfile
    # In PS on Windows:
    New-PSSession -hostname <IP address> -username <username>
    # Enter Session:
    Enter-PSSession <Sessionnumber>
    # Close Session:
    Stop-Process -Id <ProcessId>
    # Remote Command:
    Invoke-Command -Session(Get-PSSession <Sessionnumber>) -ScriptBlock { uname -a }



  30. miron revised this gist Apr 25, 2022. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions windows
    Original file line number Diff line number Diff line change
    @@ -8,3 +8,7 @@
    # Disable Zone Identifier
    # gpedit.msc User Configuration/Administrative Templates/Windows Components/Attachment Manager
    # "Do not preserve zone information in file attachments", Enabled

    # Install gh in Kali, download deb:
    https://github.com/cli/cli/releases/latest
    apt install <packet>