Skip to content

Instantly share code, notes, and snippets.

View matthew-d-jones's full-sized avatar

Matthew D Jones matthew-d-jones

View GitHub Profile
@matthew-d-jones
matthew-d-jones / tictoc.h
Created February 27, 2020 07:26
MATLAB-style tictoc, simple timing functions for C++
#pragma once
#include <chrono>
#include <iostream>
using Clock = std::chrono::high_resolution_clock;
static Clock::time_point t0 = Clock::now();
void tic() { t0 = Clock::now(); }
@matthew-d-jones
matthew-d-jones / offsets_for_times.py
Created July 2, 2019 08:45
Query the offsets for a specified Kafka topic at a specified time
from confluent_kafka import Consumer, TopicPartition
from datetime import datetime
import uuid
import argparse
"""
Query the offsets for a specified topic at a specified time
Example use: offsets_for_times.py -b obito:9092 -t IMAT_sampleEnv -q 2019-06-30T09:00:00
@matthew-d-jones
matthew-d-jones / Eigen Cheat sheet
Created May 2, 2018 17:07 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
# Oversized Pancake Flipper
# https://code.google.com/codejam/contest/3264486/dashboard#s=p0
def read_test_cases_from_file(filename):
with open(filename) as file_object:
file_object.readline()
for test_case_line in file_object:
test_case_string = test_case_line.split(' ')
yield test_case_string[0], int(test_case_string[1])
import datetime
from datatypes.RunInfo import RunInfo
from datatypes.RunStart import RunStart
from datatypes.RunStop import RunStop
from datatypes.InfoTypes import InfoTypes
from confluent_kafka import Consumer, KafkaError, TopicPartition
"""
Print published run information from Kafka stream
"""
@matthew-d-jones
matthew-d-jones / PowerShell Customization.md
Created January 19, 2018 22:59 — forked from jchandra74/PowerShell Customization.md
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

@matthew-d-jones
matthew-d-jones / FindLibRDKafka.cmake
Last active November 10, 2019 19:08
CMake find module for the librdkafka library, includes version check
# - Try to find LibRDKafka headers and libraries.
#
# Usage of this module as follows:
#
# find_package(LibRDKafka)
#
# A minimum required version can also be specified, for example:
#
# find_package(LibRDKafka 0.11.1)
#
@matthew-d-jones
matthew-d-jones / clangformat-precommit-hook
Last active July 24, 2017 09:27
A git pre-commit hook to reject changes which would result in non clang-formatted files
#!/bin/sh
#
# This pre-commit hook checks if any versions of clang-format
# are installed, and if so, uses the installed version to reject
# un-clang-formatted commits
maj_min=1
maj_max=3
base=clang-format
@matthew-d-jones
matthew-d-jones / ansible_setup_users_ssh.yml
Created May 19, 2016 10:40
Setup a sudo-enabled user with ssh access on all Ansible hosts
--
- hosts: all
user: root
vars:
createuser: 'username'
createpassword: 'myamazingpassword'
publickey_path: '/home/username/.ssh/id_rsa.pub'
tasks:
- name: Setup | create user
command: useradd -m {{ createuser }} creates=/home/{{ createuser }}
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as pl
df = pd.DataFrame()
df["name"] = ["Protocol Buffers",
"Flat Buffers",
"Apache Avro",
"Apache Thrift",
"BSON"]