Skip to content

Instantly share code, notes, and snippets.

@antiagainst
Last active October 7, 2017 10:54
Show Gist options
  • Save antiagainst/9437718 to your computer and use it in GitHub Desktop.
Save antiagainst/9437718 to your computer and use it in GitHub Desktop.
Tips for Development Tools

git

How to show the tracking relationship between local and remote branches?

git branch -vv

How to change remote tracking branch?

git branch --set-upstream-to origin/somebranch

How to commit without commit message?

git commit --allow-empty-message -m ''

Vim

Disply file in binary format

:%!xxd

How to set indent per file?

vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

How to get the type of the current file?

:set ft?

How to scrol screen relative to cursor?

zt
zz
zb

Python

How to flatten a list of lists?

itertools.chain():
itertools.chain(list1, list2, list3)

itertools.chain.from_iterable():
iterables = [list1, list2, list3]
itertools.chain.from_iterable(iterables)

naming conventions

  • _X: not imported by a from module import * statement
  • __X__: system-defined names that have special meaning to the interpreter
  • __X: localized (“mangled”) to enclosing classes
  • _: retaining the result of the last expression when working interactively

gdb

How to print the type of a variable?

ptype aVariable

bash

How to write both stdout and stderr to files using tee?

command > >(tee stdout.log) 2> >(tee stderr.log >&2)
  • based on process substitution and named pipe.
  • <(cmd) expression tells the command interpreter to run cmd and make its output appear as a file.
  • >(cmd) captures output that would normally go to a file, and redirects it to the input of cmd.
  • > >(...) redirects stdout of command to the FIFO that the first tee is listening on.
  • 2> >(... >&2) redirects stderr of command to the FIFO that the second tee is listening on, and redirects the second tee's stdout to command's stderr.

tmux

How to change two windows into two panes of one window?

join-pane -s 2 -t 1 # move the second window as a pane to the 1st window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment