Skip to content

Instantly share code, notes, and snippets.

View bmharper's full-sized avatar

Ben Harper bmharper

  • WeFi
  • Stellenbosch, South Africa
  • X @rogojin
View GitHub Profile
@bmharper
bmharper / 01-blend.ispc
Created December 20, 2019 10:11
ISPC function to blend Freetype glyph onto RGBA surface
typedef unsigned int8 uint8;
extern const float sRGBToLinear[1 << 8];
// BlendSRGB blends a uint8 alpha-channel mask onto an RGBA uint8 destination surface, using the OVER operater,
// and with gamma-correct blending. The alpha channel is modulated by an RGB color.
//
// This function was built to draw glyphs that are produced by Freetype.
//
// nPix: number of pixels to blend
@bmharper
bmharper / notes.txt
Created August 6, 2019 13:41
IMQS docstore 3rd try
3 Initialize Go project
8 DB design (DocMeta, DocBlob, Share, Link)
Migration
16 Use native Go/Mongo driver - SELECT ALL on everything except Blob
8 Test migrations on infraqa, imqsrc, demo
While migration is taking place, service must respond to ping.
Use regular migration system to ensure correctness.
@bmharper
bmharper / gist:86ca7fc477688baf02494b13ffb15c8a
Created February 23, 2019 07:11
Demonstrate value/reference copy/assignment semantics of LibTorch at::Tensor
/*
Output:
operator= reference copy (same memory)
copy_ value copy (different memory)
operator= of operator[] value copy (different memory)
slice reference copy (same memory)
*/
@bmharper
bmharper / least-squares-quadratic.cpp
Last active June 28, 2018 12:14
C++ least squares fit of N points, onto quadratic
void FitQuadratic(const std::vector<std::pair<double, double>>& xy, double& a, double& b, double& c) {
// http://mathforum.org/library/drmath/view/72047.html
/*
Now all you have to do is take your data (your eight points) and
evaluate the various sums
n
Sj0 = sum x_i^j
i=1
@bmharper
bmharper / with-angled-point.png
Last active October 13, 2017 09:32
Mapnik angled-point marker placement mode
Images illustrating mode:
@bmharper
bmharper / gist:6078376
Created July 25, 2013 09:56
windows password generator
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "Advapi32")
const int CorpusSize = 26 * 2 + 10;
const char Corpus[CorpusSize + 1] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int main(int argc, char** argv)
{