Skip to content

Instantly share code, notes, and snippets.

View gilesvangruisen's full-sized avatar

Giles Van Gruisen gilesvangruisen

View GitHub Profile
@gilesvangruisen
gilesvangruisen / Publisher.h
Last active June 10, 2020 19:02
Basic pub/sub with Objective-C
@interface Publisher : NSObject
- (void)subscribe:(void(^)(id object))subscriptionBlock;
- (void)publish:(id)object;
@end
def _highest_density_interval(self, pmf, p=.9, title=''):
# If we pass a DataFrame, just call this recursively on the columns
if(isinstance(pmf, pd.DataFrame)):
return pd.DataFrame([self._highest_density_interval(pmf[col], title=str(col)) for col in pmf],
index=pmf.columns)
# Broadcast the probability distribution to an artificial set of samples by
# repeating each index value N times where N = probability sample_precision
sample_precision = 1000000
samples_repeats = np.array(pmf.values * sample_precision)#.astype(int)
@gilesvangruisen
gilesvangruisen / ci.yml
Created April 5, 2020 15:58
Ruby/Rails GitHub Actions CI
name: rspec
on:
pull_request:
branches:
- "master"
push:
branches:
- "master"
Start Date,End Date,# Days,Location
12/30/2014,1/1/2015,2,"Quechee, VT"
1/1/2015,1/4/2015,3,"Newport, RI"
1/4/2015,1/13/2015,9,"Somerville, MA"
1/13/2015,1/17/2015,4,"San Francisco, CA"
1/18/2015,1/22/2015,4,"Somerville, MA"
1/22/2015,1/27/2015,5,"Newport, RI"
1/27/2015,2/7/2015,11,"Somerville, MA"
2/7/2015,2/8/2015,1,"Newport, RI"
2/8/2015,2/18/2015,10,"Somerville, MA"
@gilesvangruisen
gilesvangruisen / LocalStore.swift
Last active August 29, 2015 14:17
StorableValue protocol for encoding/decoding a value type and StoredValue object for boxing up a StorableValue to be cached. (Value types can't conform to NSCoding because it's a class-protocol.)
//
// LocalStore.swift
// FPAPI
//
// Created by Giles Van Gruisen on 3/23/15.
// Copyright (c) 2015 Remarkable.io. All rights reserved.
//
import Foundation
import AwesomeCache
infix operator --> { associativity left precedence 160 }
func --><T, S>(argument: T?, body: (T) -> (S)) -> S? {
if let value = argument {
return body(value) as S
} else {
return nil
}
}
@gilesvangruisen
gilesvangruisen / binarySearch
Last active August 29, 2015 14:11
Swift generic binary search
// Binary search
func binarySearch<T: Comparable>(target: T, collection: [T]) -> Int {
var min = 0
var max = countElements(collection) - 1
return binaryMakeGuess(min, max, target, collection)
}