Skip to content

Instantly share code, notes, and snippets.

@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()
sns.set(style='whitegrid', context='notebook', font_scale=1.5)
cm = np.corrcoef(df[cols].values.T)
hm = sns.heatmap(cm, cbar=True, annot=True, square=True, fmt='.2f',
annot_kws={'size': 15}, yticklabels=cols, xticklabels=cols)
plt.show()
@elmotec
elmotec / __main__.py
Last active July 19, 2019 10:47
A convenience test runners for unittest.
#!/usr/bin/env python
# vim: set encoding=utf-8
"""
My convenience test runners for unittest.
Place it in your tests folder and use it with python -m <test folder>.
(Requires click, and colorama (if you want colors)).
Allows one to run your tests in your tests folder in a spartain way: