Skip to content

Instantly share code, notes, and snippets.

Matt Kline mrkline

Block or report user

Report or block mrkline

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mrkline
mrkline / parent-polymorphism.cpp
Last active Jan 20, 2017
Sean Parent's polymorphism demo
View parent-polymorphism.cpp
// See http://sean-parent.stlab.cc/presentations/2016-10-10-runtime-polymorphism/2016-10-10-runtime-polymorphism.pdf
// or an earlier version, "Inheritance Is The Base Class of Evil"
#include <iostream>
#include <memory>
#include <string>
#include <vector>
using namespace std;
@mrkline
mrkline / llswap.cpp
Last active Aug 29, 2015
Swapping linked list pairs with two pointers
View llswap.cpp
#include <cstdio>
struct Node {
int data;
Node* next;
};
Node* makeList(int count)
{
Node* const head = new Node();
View getline.c
// MSVC apparently doesn't have C's getline
// This is a poor man's implementation of it using fgets.
// See the man page at
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html
size_t getline(char** buf, size_t* bufLen, FILE* f)
{
if (buf == nullptr || bufLen == nullptr)
{
errno = EINVAL;
return -1;
@mrkline
mrkline / exceptions.md
Last active Aug 29, 2015
Why Exceptions?
View exceptions.md

Exceptions are used over return codes/errnos to handle errors, as they are the idiomatic error handling mechanism in modern C++ code.

  • First and foremost, an uncaught exception exits the program. This is a Good Thing™. Exceptions should only be thrown in the first place when an problem occurs that cannot be handled in the current scope. If this problem is not handled at some scope above the current one, the program should exit, regardless of what error handling paradigm is being used.
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs
@mrkline
mrkline / c_sharp_for_python.md
Last active Feb 7, 2020
An intro to C# for a Python developer. Made for one of my coworkers.
View c_sharp_for_python.md

C# For Python Programmers

Syntax and core concepts

Basic Syntax

  • Single-line comments are started with //. Multi-line comments are started with /* and ended with */.

  • C# uses braces ({ and }) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,

@mrkline
mrkline / nix_on_windows.md
Last active Sep 21, 2019
An overview of setting up *nix tools on Windows using MSYS
View nix_on_windows.md

*nix on Windows

Options

If you would like to use *nix tools on Windows, you have two main options:

  • Cygwin offers your typical Linux toolset (bash, ls, cd, grep, and the other core utilities) and a DLL that provides some Linux system emulation (signals, etc.). However, Cygwin tends to take the "everything but the kitchen sink" approach, so I generally prefer the second option, MSYS.
View git_intro.md

##The Basics

###Installation

####Windows Users

First off, get msysgit (download here). It is the official Windows Git distribution, and comes with a terminal that has your standard bash commands as well as Git.

You can’t perform that action at this time.