Skip to content

Instantly share code, notes, and snippets.

@k-nut
Last active July 13, 2020 12:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-nut/41292af91a4f1c80324230c35cdb9c28 to your computer and use it in GitHub Desktop.
Save k-nut/41292af91a4f1c80324230c35cdb9c28 to your computer and use it in GitHub Desktop.
Knowledge I have gained throughout the years

vim

  • <n>G to jump to nth row
  • ctrl+o to jump to last curor position
  • ctrl+n to highlight word, again to jump to next one, ctrl-x to skip one ctrl-p to go back-
    • with plugin: c to change the selection
  • q: to get a window of all last commands <CR> to execute them
  • J to move the following line to the end of this line
  • <leader>s to substitute word under cursor
  • "<char>dd deleted line into register
  • "<char>p pastes file from register
  • :s/\%V\(.*\)\%V/<a href="#\1">\1<\/a>/ to surround visual selection
  • :nohlsearch to no longer highlight search matches
  • :grep <word> to find. then :cw in search results to open in quickfix window
  • ctrl+a increments the next number by one, ctrl+x decrements it http://vim.wikia.com/wiki/Increasing_or_decreasing_numbers
  • :e <path e.g. "."> opens a file browser that can be searched and used to edit files

zsh

  • ctrl+r to serach history
  • ctrl+l to replace clear
  • ctrl+z to suspend process, bg to list them, fg to bring it back to the foreground, disown to separate process from terminal
  • $? holds the exit status of the last executed command
  • ^foo^bar takes the last command from the history and replaces foo with bar

unix command line tools

- echo {"some": "json"} | python -m json.tool pretty prints json on the cmd line

  • grep -A12 -B15 gives the matching lines and 12after, 15 before
  • man 2 open lets you inspect level 2 (system) calls like open
  • htop has a -d option which lets you set the refesh interval (in tenths of seconds). htop -d 5 sets it to two times a second
  • less -S turns off line wraping which is useful if you have long tabular text (like the output of csvlook)
  • renameutils allows you to easily change file names with the editor that you are used to
  • sort has the -h flag which sorts by human readble values (such as the one produced by du -h) which might include KB, MB etc

python

  • dir() shows all properties/methods of an object
  • ptpython is a nice command line replacement for ipython
  • import ipdb; ipdb.set_trace() gives you an interactive debugging session
  • ctrl + [ or ctrl + ] to indent/unindent in ipython
  • _ gives you the last evaluted result in (i)Python, __ the second last and so on
  • You can user python -c to execute python lineline in a shell. Example: echo 'hello cool arguments ' | python -c 'import sys; print sys.stdin.read().split()'
  • IPython's input mode can be switched to vim or emacas mode. To switch it to vim mode create a config file (ipython profile create) and set c.TerminalInteractiveShell.editing_mode = 'vi' in the ipython_config.py file that is created. Then you can hit escape and move around like you are used to from vim. (reference)1

Browser devtools

inspect($(".points")) in the console to select the element in the Elements panel debug(YourLibrary.someFunction) or monitor(YourLibrary.someFunction) to be notified when function is called

Webdevelopment

Change describe or it to fdescdribe or fit to only run those tests with jasmine

Git

  • git reset --soft origin/master
    • This will rollback your branch to the same commit as origin/master but it keeps all the changes you have done
  • git stash --patch to let you choose what you want to stash and what not
  • git bisect and then git good or git bad to go on the hunt for a bug in the history
  • Add -S to git commit (as in git commit -S -m 'my signed commit') to use GPG to sign your commit. It will then show up with a checkmark on the github.com///commits page
  • diff so fancy for nicer highlighting and colors in diffs

psql

  • \e to edit the last executed command in default text editor
  • run \watch after a query to run this query every two seconds (just like the default unix watch)

tools

  • alex checks text for non inclusive language
  • httpie Replaces wget/curl
  • webcoach to measure performance of webpages and get advice
  • tldr as an example-driven alternative to man
  • thefuck corrects commands that you mistyped in the console

macOS

  • sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff to change mac address of wifi card (useful if throttled by mac address) (maybe make sure to store your original one and reset back to it after you are done to avoid side effects)
  • ⌘-E finds currently selected text (in some tools)
  • Apple has a long support doucment on keyborad shortcuts

heroku

  • heroku pg:ps to see all running postgres processes
  • heroku pg:killall to kill all running postgres processes

fish

  • alt-e to edit the current line in $EDITOR (see this commit)

JetBrains Editors

  • The Rainbow Brackets Plugin colorizes matching parantheses

iTerm2

  • if you install the iTerm2 shell integration you get convenient features such as being able to jump back to the previous command in the history with cmd-shift-up (reference)2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment