Skip to content

Instantly share code, notes, and snippets.

@elmotec
elmotec / gdb-thread.md
Last active September 27, 2025 22:18
Advanced GDB Cheat Sheet (threading)

GDB Threading Cheat Sheet

Designed for multi-threaded, multi-process, and advanced use cases. Convert with:

pandoc -o gdb-advanced.odt gdb-advanced.md

and play with the odt until happy, then export as .pdf.


@elmotec
elmotec / gdb.md
Last active September 27, 2025 21:07
starter GDB cheat sheet

GDB Cheat Sheet

Starting & Running

Command Description
gdb <program> Start GDB with the specified program.
gdb -q Start quietly (no intro).
run [args] Run program with optional args.
start Run until main() and break.
attach <pid> Attach to a running process.
@elmotec
elmotec / json.cxx
Last active February 19, 2022 14:27
/** Convenience functions to stream output from std:: data structures.
*
* Useful when you do not have a debugger. See test below to get a sense of
* what's available.
*
*/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@elmotec
elmotec / outlook shortcuts.md
Last active February 18, 2022 14:22
List of outlook shortcuts.

Outlook shortcuts

If you remember only one shortcut!

  • Insert Flag email (will show in your todo), then cycle un/complete.
  • Alt+Insert: remove flag.
  • Shift+F10 brings up the context menu (works everywhere)
  • F3 or Ctrl+E: search

Actions

@elmotec
elmotec / logfile.fio.ini
Last active November 15, 2019 10:32
Simulate clients writing log files to a drive
; Simulate clients writing log files to a drive with fio (see https://bsdio.com/fio/)
;
; numbjobs: number of clients
; rate_iops: number of writes per seconds
; bs: size of the log entry
; size: total size of the log file
;
; Normally, the iops reported by fio should be rate_iops x numbjobs
[global]
@elmotec
elmotec / notebook_first_cell.py
Last active July 19, 2019 11:24
First/top cell in my Jupyter notebook
import numpy as np
import numexpr as ne
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
%load_ext autoreload
%autoreload 2
%matplotlib inline
import pandas as pd
def top(df, n, columns=None):
"""Returns top and bottom n elements subset of input dataframe.
Args:
df: input dataframe.
n: number of elements to return (n / 2 on top and on the bottom).
columns: list of columns to consider for sorting, defaults to use
head and tail.
@elmotec
elmotec / add_data_frame_equality_func
Last active April 19, 2018 01:26
Handles pandas.DataFrame in unittest.TestCase.assertEqual()
def add_data_frame_equality_func(test):
"""Define test class to handle assertEqual with `pandas.DataFrame`."""
def frame_equal(lhs, rhs, msg=None):
"""Adapter for pandas.testing.assert_frame_equal."""
if msg:
try:
pdt.assert_frame_equal(lhs, rhs)
except AssertionError as err:
raise test.failureException(msg)
else:
-- creates fdw to the database quotes in a schema quotes_s
create extension if not exists postgres_fdw;
create server prod_s foreign data wrapper postgres_fdw options (host 'servername', dbname 'quotes', port '5432');
create user mapping for public server prod_s options (user 'name', password 'secret');
create schema quotes_s;
sns.set(style='whitegrid', context='notebook', font_scale=1.5)
sns.pairplot(df[cols])
plt.show()