Skip to content

Instantly share code, notes, and snippets.

View John-Colvin's full-sized avatar

John Colvin John-Colvin

  • Wiltshire, UK
  • 14:40 (UTC +01:00)
View GitHub Profile
/**
* Explaination comments taken from:
* http://wiki.openstreetmap.org/wiki/PBF_Format#Design
*
* This gives a very basic parsing of osm.pbf files. The purpose was several
* fold.
*
* - Read PBF files
* - Learn the file layout
* - Verify the bytes match
@John-Colvin
John-Colvin / TypeTupleOf.d
Last active August 29, 2015 14:18
TypeTupleOf
import std.range : isInputRange;
import std.array : front, empty, popFront;
template TypeTupleOf(TL...)
if (TL.length == 1 && isInputRange!(typeof(TL[0])))
{
import std.typetuple : TT = TypeTuple;
enum r = TL[0];
static if (r.empty)
alias TypeTupleOf = TT!();
@John-Colvin
John-Colvin / TransformMembers.d
Last active August 29, 2015 14:24
Messing with types
import std.typetuple;
import std.typecons;
import std.traits;
struct Pack(TL...)
{
alias expand = TL;
enum length = TL.length;
@disable this();
}
2015-08-13 17:13:41 +0100
python3
setup.py
build
--fcompiler=gnu95
lapack_opt_info:
openblas_lapack_info:
C compiler: cc

A draft example of kahan sum as an input/forward range (I'm using double just to make it a simple example):

struct KahanSum(R)
{
    R r;
    double sum = 0.0;
    double c = 0.0;
    this(R r)
    {
        this.r = r;
@John-Colvin
John-Colvin / pairWise.d
Last active October 1, 2015 15:14
pairWise summation for input ranges
/++
$(LUCKY Pairwise summation) algorithm. Range must be a finite range.
+/
private F sumPairwise(Range, F = Unqual!(ForeachType!Range))(Range data)
if (isInputRange!Range && !isInfinite!Range)
{
import core.bitop : bsf;
// Works for r with length < 2^^64, in keeping with the use of size_t
// elsewhere in std.algorithm and std.range on 64 bit platforms.
F[64] store = F.max;
@John-Colvin
John-Colvin / pairwiseFast.d
Created October 4, 2015 17:34
fast pairwise
import std.range, std.traits;
import core.bitop : bsf;
import std.stdio;
/++
$(LUCKY Pairwise summation) algorithm. Range must be a finite range.
+/
F sumPairwise(F, R)(R data)
if(isInputRange!R && !isInfinite!R)
@John-Colvin
John-Colvin / tube_dist.html
Created November 12, 2015 18:35
most isolated tube stops in zone 1, as the crow files
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>Closest</th>
<th>dist</th>
</tr>
</thead>
<tbody>
<tr>
2015-11-21 14:03:29 +0000
cmake
..
-DCMAKE_C_FLAGS_RELEASE=
-DCMAKE_CXX_FLAGS_RELEASE=
-DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/scalapack/2.0.2_4
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_FIND_FRAMEWORK=LAST
-DCMAKE_VERBOSE_MAKEFILE=ON
@John-Colvin
John-Colvin / sigmoidContrast.py
Last active April 19, 2016 18:22
contrast function based on the error function
def sigmoidContrastGetRawSlope(bias, slope):
'''Get a value for rawSlope (as used in sigmoidContrast)'''
import scipy.optimize
import scipy.special
assert slope >= 1, "slope must be in [1, oo]"
if slope == 1:
return 0