Skip to content

Instantly share code, notes, and snippets.

@ssilva
Last active February 20, 2018 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssilva/e835a355683a4f0db2d92dde03a3d139 to your computer and use it in GitHub Desktop.
Save ssilva/e835a355683a4f0db2d92dde03a3d139 to your computer and use it in GitHub Desktop.

Command-line

Sum of numbers

Pipe to awk '{s+=$1} END {print s}' or paste -s -d+ - | bc (here paste joins the numbers into one line)

vim

  • { extends the selection until the next empty line

Macros

  • Start recording: q + a letter, say m
  • Finish recording: q
  • Run macro: @ + m
  • Re-run macro: @ + @

gvim

  • Shift + click a word to show all occurences

Useful Unicode chars

Char    Code    Description
---     ----    -----------
—       2014    Em dash
…       2026    Horizontal ellipsis
⋮      22EE    Vertical ellipsis
→       2192    Right arrow

In Vim (insert mode): Ctrl-v + u + the code. E.g. Ctrl-v + u2026 for ellipsis.

Elsewhere: Ctrl-Shift-u, enter the code, hit space.

Parent and child processes

When a child process terminates, a SIGCHLD signal is sent to its parent. The kernel retains the child process with its exit status so that the parent can retrieve it by calling wait() on it. While that doesn't occur, the child is a zombie process.

By default, SIGCHLD signals are ignored.

TODO: add sample code

Examining a core dump

gdb app-binary path-to-core-dmp
(gdb) bt

Install GKT+ 3 on CentOS

$ sudo yum install gtk3-devel

C++

C++-style casts

  • static_cast: general purpose, equivalent to the C-style cast; at compile-time
  • const_cast: casts away const and volatile; at run-time
  • dynamic_cast: safe cast across the inheritance hierarchy (prevents incorrect downcasting); at run-time
  • reinterpret_cast: converts ints to and from pointers and any pointer type to and from any pointer type. Unsafe and unportable. (compile-time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment