Skip to content

Instantly share code, notes, and snippets.

View fosterbrereton's full-sized avatar

Foster Brereton fosterbrereton

View GitHub Profile
@fosterbrereton
fosterbrereton / keybase.md
Created September 9, 2019 17:15
keybase.md

Keybase proof

I hereby claim:

  • I am fosterbrereton on github.
  • I am fosterb (https://keybase.io/fosterb) on keybase.
  • I have a public key whose fingerprint is 3D63 FF51 712A 9F44 3D43 D7BD D1AA 5CD5 92E3 14A7

To claim this, I am signing this object:

@fosterbrereton
fosterbrereton / better_macros_better_flags.cpp
Last active April 28, 2024 15:20
Companion source code for the article "Better Macros, Better Flags."
/*
MIT License
Copyright 2019 Foster T. Brereton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@fosterbrereton
fosterbrereton / chmodr.sh
Created April 4, 2018 06:33 — forked from francisbyrne/chmodr.sh
Recursive chmod script for dirs and/or files
#!/bin/sh
#
# chmodr.sh
#
# author: Francis Byrne
# date: 2011/02/12
#
# Generic Script for recursively setting permissions for directories and files
# to defined or default permissions using chmod.
#

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM0AAAD NCAMAAAAsYgRbAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5c cllPAAAABJQTFRF3NSmzMewPxIG//ncJEJsldTou1jHgAAAARBJREFUeNrs2EEK gCAQBVDLuv+V20dENbMY831wKz4Y/VHb/5RGQ0NDQ0NDQ0NDQ0NDQ0NDQ 0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0PzMWtyaGhoaGhoaGhoaGhoaGhoxtb0QGho aGhoaGhoaGhoaGhoaMbRLEvv50VTQ9OTQ5OpyZ01GpM2g0bfmDQaL7S+ofFC6x v3ZpxJiywakzbvd9r3RWPS9I2+MWk0+kbf0Hih9Y17U0nTHibrDDQ0NDQ0NDQ0 NDQ0NDQ0NTXbRSL/AK72o6GhoaGhoRlL8951vwsNDQ0NDQ1NDc0WyHtDTEhD Q0NDQ0NTS5MdGhoaGhoaGhoaGhoaGhoaGhoaGhoaGposzSHAAErMwwQ2HwRQ AAAAAElFTkSuQmCC" alt="beastie.png">

@fosterbrereton
fosterbrereton / firemap.sh
Last active June 21, 2016 20:07
Using US Forest Service WMS servers to fetch fire maps
#!/bin/bash
# Original lat/long is near Azusa, California, the location of the 2016 Jun 20
# Fish fire.
LAT=34.177043
LON=-117.921503
LATMIN=`bc <<< $LAT-.2`
LATMAX=`bc <<< $LAT+.2`
@fosterbrereton
fosterbrereton / bad_banana.cpp
Created April 19, 2016 22:27
How do I fix banana?
#include <iostream>
#include <typeinfo>
struct banana_t {
template <typename T>
explicit banana_t(const T& x) :
impl_m{new impl<T>(x)}
{ }
struct base_t {
@fosterbrereton
fosterbrereton / elevator_saga.js
Created January 13, 2016 08:06
Elevator Saga (play.elevatorsaga.com)
{
init: function(elevators, floors) {
var closestToFloor = function (floor) {
var elevator = null;
var distance = 1000;
console.log("Call to floor " + floor + "...");
elevators.forEach(function (cur_elevator) {
var cur_distance = Math.abs(cur_elevator.currentFloor() - floor);
@fosterbrereton
fosterbrereton / rectangle_fitting.cpp
Last active August 29, 2015 13:55
Rectangle Fitting
#include <iostream>
struct rect_t
{
float top_m;
float left_m;
float bottom_m;
float right_m;
float height() const { return bottom_m - top_m; }
@fosterbrereton
fosterbrereton / Preferences.sublime-settings
Last active July 27, 2017 00:01
SublimeText 3 Settings
{
"always_show_minimap_viewport": true,
"auto_complete_commit_on_tab": true,
"auto_match_enabled": false,
"caret_style": "phase",
"color_scheme": "Packages/Colorsublime - Themes/cache/Colorsublime-Themes-master/themes/BBEdit.tmTheme",
"copy_with_empty_selection": false,
"create_window_at_startup": false,
"detect_indentation": false,
"draw_minimap_border": true,
@fosterbrereton
fosterbrereton / boost_in_git.sh
Last active December 29, 2015 13:49
Working with Boost in git
#!/bin/bash
# Boost is now using git submodules, where each Boost library has its own. These are coalesced
# into a top-level boost repository. Grabbing a snapshot of boost, then, involves cloning the
# top-level repo and using bjam to build the familiar top-level boost/ headers directory.
git clone --recursive git@github.com:boostorg/boost.git
cd boost