Skip to content

Instantly share code, notes, and snippets.

View AaronFlower's full-sized avatar
💭
I may be slow to respond.

AaronFlower

💭
I may be slow to respond.
View GitHub Profile
@AaronFlower
AaronFlower / WhatIsStrictAliasingAndWhyDoWeCare.md
Created November 16, 2021 07:54 — forked from shafik/WhatIsStrictAliasingAndWhyDoWeCare.md
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
# remap C-b to C-a
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# reload the conf file on the fly
bind r source-file ~/.tmux.conf
# who knows what this does, but I can now scroll in a tmux pane
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
@AaronFlower
AaronFlower / json_cleaner.py
Created March 25, 2019 06:51 — forked from liftoff/json_cleaner.py
Allow comments and trailing commas in JSON files using two simple Python functions to clean them up before parsing
#!/usr/bin/env python
"""
An example of how to remove comments and trailing commas from JSON before
parsing. You only need the two functions below, `remove_comments()` and
`remove_trailing_commas()` to accomplish this. This script serves as an
example of how to use them but feel free to just copy & paste them into your
own code/projects. Usage::
json_cleaner.py some_file.json
@AaronFlower
AaronFlower / linux_fun.md
Created March 6, 2019 17:09 — forked from zlorb/linux_fun.md
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Install figlet [3] via : sudo apt-get install figlet
  4. Make sure you have Ruby installed via : ruby -v
  5. Install the lolcat [2] via : gem gem install lolcat
  6. (option) Add to .bash_profile and/or .bashrc
@AaronFlower
AaronFlower / README.md
Created December 13, 2018 03:13 — forked from omidraha/README.md
Authentication and Authorization Concepts for MicroServices

auth with microservices

Authorization and Authentication are hard. when you only have to implement them once (as you do within a monolith) instead of over and over again, it makes the developer happy :-), and maybe leads to less implementation failures.

When you have a bunch of microservices, this is something that has to be considered.

Implement it once or in every microservice, or something in between?

@AaronFlower
AaronFlower / Matrix.md
Created September 25, 2018 07:05 — forked from nadavrot/Matrix.md
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

#include <iostream>
#include <vector>
using namespace std;
void print(const vector<int>& vec) {
vector<int>::const_iterator it = vec.begin();
while(it < (vec.end() - 1)) {
cout << *it << ',';
advance(it, 1);
}
@AaronFlower
AaronFlower / iterm2-solarized.md
Created March 18, 2018 01:37 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

<?php
class Singleton
{
protected static $instance = null;
protected function __construct()
{
# Thou shalt not construct that which is unconstructable!
}
protected function __clone()
{