Skip to content

Instantly share code, notes, and snippets.

View erikerlandson's full-sized avatar

Erik Erlandson erikerlandson

View GitHub Profile
@erikerlandson
erikerlandson / gist:2878348
Created June 5, 2012 22:03
Condor log file
# at config time, it tells me it sees configuration to allow 'test1':
06/05/12 14:46:08 IPVERIFY: allow WRITE: eje@localhost.localdomain, condor@localhost.localdomain, root@localhost.localdomain, test1@localhost.localdomain, test1@192.168.1.102, test1@192.168.1.2 (from config value ALLOW_WRITE)
# I'm interested in what this means:
06/05/12 14:46:08 Authorizations yet to be resolved:
06/05/12 14:46:08 allow WRITE: eje@localhost.localdomain/* condor@localhost.localdomain/* root@localhost.localdomain/* test1@localhost.localdomain/* test1@192.168.1.102/* test1@192.168.1.2/*
# When the rubber hits the road, it resolves as 'deny':
06/05/12 14:46:55 Adding to resolved authorization table: test1/192.168.1.2: DENY_ADMINISTRATOR
@erikerlandson
erikerlandson / gist:4731965
Created February 7, 2013 16:09
examples of consumption policy use cases
# spoof some cores
NUM_CPUS = 20
# declare an extensible resource for a 'claim-based' consumption policy
MACHINE_RESOURCE_tokens = 3
# startd-wide consumption policy config
# defaults for cpus/memory/disk consumption
CONSUMPTION_POLICY = True
SLOT_WEIGHT = Cpus
@erikerlandson
erikerlandson / gist:7217401
Created October 29, 2013 15:58
Test code for introspection and concept checking
/*******
edit_distance: STL and Boost compatible edit distance functions for C++
Copyright (c) 2013 Erik Erlandson
Author: Erik Erlandson <erikerlandson@yahoo.com>
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE or copy at
http://www.boost.org/LICENSE_1_0.txt
@erikerlandson
erikerlandson / create_member_check.cpp
Last active December 27, 2015 02:19
Annotated example for defining a class membership checking predicate template
/*******
Demonstrate a Boost/MPL style macro to create predicate templates for class member checking
Copyright (c) 2013 Erik Erlandson
Author: Erik Erlandson <erikerlandson@yahoo.com>
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE or copy at
http://www.boost.org/LICENSE_1_0.txt
@erikerlandson
erikerlandson / invoke.cpp
Created November 2, 2013 15:27
Demo of using an 'invoke' shim with SFINAE and enable_if<> to conditionally specialize templates based on whether a given expression is defined for a parameter class type
#include <boost/utility/enable_if.hpp>
#include <boost/typeof/std/utility.hpp>
using boost::false_type;
using boost::true_type;
using boost::enable_if;
// always evaluates to true, as long as expression that generated 'X' compiled
template <typename X> struct invoke : public true_type {};
@erikerlandson
erikerlandson / boost_parameter_return_type.cpp
Last active December 27, 2015 11:39
Demonstrate referring to an argument type in the BOOST_PARAMETER_FUNCTION macro
#include <boost/parameter/name.hpp>
#include <boost/parameter/preprocessor.hpp>
BOOST_PARAMETER_NAME(b)
BOOST_PARAMETER_NAME(c)
BOOST_PARAMETER_FUNCTION(
// Deduce return type from an argument type
// This is not documented, but seems like it could be officially supported:
(typename boost::parameter::value_type<Args, tag::c, int>::type),
@erikerlandson
erikerlandson / feature_enabling.cpp
Created November 13, 2013 20:20
Demonstrate integrated support for both run-time and compile-time enabling or disabling of a feature. Note, should be compiled optimized for best results.
#include <iostream>
#include <boost/parameter/name.hpp>
#include <boost/parameter/preprocessor.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/utility/enable_if.hpp>
using boost::is_same;
using boost::false_type;
using boost::true_type;
@erikerlandson
erikerlandson / gist:8446284
Created January 15, 2014 22:47
A cmake macro, check_gnu_linker_flag(), for checking if the GNU toolchain linker supports a given argument
# This macro is designed to work with the GNU toolchain,
# where the linker is called indirectly via 'gcc'
# You can invoke it as in this example:
# check_gnu_linker_flag("-pie", cxx_linker_pie)
# to test if the linker supports '-pie', and store the result in
# variable 'cxx_linker_pie', in the same fashion as check_cxx_compiler_flag()
# Note, some versions of gnu linker will accept some unknown arguments
# for example -z <arg> may succeed whether <arg> is supported or not,
# although I've found this to work in newer GNU versions.
// initialize this with the maximum possible distance:
Dbest = M+N;
P = 0;
while (true) {
// the minimum possible distance for the current P value
Dmin = 2*(P-1) + delta;
// if the minimum possible distance is >= our best-known distance, we can halt
if (Dmin >= Dbest) return Dbest;
@erikerlandson
erikerlandson / sizes.cpp
Created March 29, 2014 19:11
dump sizes of atomic numeric types in c/c++
#include <iostream>
using namespace std;
#define showsize(tname) cout << #tname << ": " << sizeof(tname) << endl
int main(int argv, char** argc) {
showsize(char);
showsize(short);
showsize(int);