Skip to content

Instantly share code, notes, and snippets.

View mattyclarkson's full-sized avatar

Matt Clarkson mattyclarkson

View GitHub Profile
@mattyclarkson
mattyclarkson / mingw-build.py
Created July 30, 2013 13:09
Gets the mingw-builds archive URL
#!/usr/bin/python
# encoding: UTF-8
try:
import urllib.request as urlrequest
except ImportError:
import urllib as urlrequest
def get_mingw_versions(repo_url = 'http://downloads.sourceforge.net/project/'
'mingwbuilds/host-windows/repository.txt'):
@mattyclarkson
mattyclarkson / main.c
Last active December 17, 2015 16:58
A test to set some thresholds
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
struct threshold_t {
uint8_t upper;
uint8_t lower;
};
struct threshold_abc_t {
@mattyclarkson
mattyclarkson / LICENSE
Last active November 11, 2023 20:28
Compile time Murmur3_32 implementation using C++11 constexpr
The MIT License (MIT)
Copyright (c) <year> <copyright holders>
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:
@mattyclarkson
mattyclarkson / gist:5309098
Created April 4, 2013 09:37
A C++11 routine to create a safe temporary file name.
const constexpr SizeT junk = 'z' - 'a';
Char buffer[L_tmpnam + junk] = {'\0'};
// cppcheck-suppress obsoleteFunctionstmpnam
std::tmpnam(buffer);
SizeT len = std::strlen(buffer);
std::random_device rd;
for (SizeT i = len; i < (L_tmpnam + junk - 1); ++i) {
buffer[i] = std::max('a', std::min<Char>('z',
'a' + (i - len) + (rd() & 0xF)));
}
@mattyclarkson
mattyclarkson / pimpl-performance-test.cpp
Created January 24, 2013 17:08
Are the benefits of private implementations worth the performance trade offs.
#include <cassert>
#include <chrono>
#include <iostream>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <unordered_map>
///////////////////////////////////////////////////////////////////////////////
#ifdef ENABLE_LOGGING
# define LOG(x) std::clog << x << std::endl
@mattyclarkson
mattyclarkson / setting.xml
Created November 17, 2011 16:19
Maven NAR settings
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at