Skip to content

Instantly share code, notes, and snippets.

View blainerothrock's full-sized avatar

Blaine Rothrock blainerothrock

View GitHub Profile
@blainerothrock
blainerothrock / flexible-sample.json
Last active August 29, 2022 19:30
flexible-sample.json
{
"id": "flexible-sample",
"schema_version": "1.0",
"created_at": "2022-04-13T22:11:39.000Z",
"updated_at": "2022-04-13T22:11:39.000Z",
"tags": ["development"],
"ble_registered_devices": [
{
"name": "Polar H10 821A5D29",
"services": ["heart-rate", "battery"],
{
"name": "allegations",
"children": [
{
"name": "Bribery / Official Corruption",
"children": [
{
"name": "An Act To Circumvent Criminal Prosecution",
"value": 1
},
{
"name": "allegations",
"children": [
{
"name": "Bribery / Official Corruption",
"children": [
{
"name": "An Act To Circumvent Criminal Prosecution",
"value": 25
},
category year count
Bribery / Official Corruption 2004 1
Bribery / Official Corruption 2006 1
Bribery / Official Corruption 2007 3
Bribery / Official Corruption 2008 2
Bribery / Official Corruption 2009 1
Bribery / Official Corruption 2014 2
Bribery / Official Corruption 2015 2
Conduct Unbecoming (Off-Duty) 2000 4
Conduct Unbecoming (Off-Duty) 2001 15
Bribery / Official Corruption 2004 1
Bribery / Official Corruption 2006 1
Bribery / Official Corruption 2007 3
Bribery / Official Corruption 2008 2
Bribery / Official Corruption 2009 1
Bribery / Official Corruption 2014 2
Bribery / Official Corruption 2015 2
Conduct Unbecoming (Off-Duty) 2000 4
Conduct Unbecoming (Off-Duty) 2001 15
category year count
Bribery / Official Corruption 2002 1
Bribery / Official Corruption 2003 2
Bribery / Official Corruption 2005 1
Bribery / Official Corruption 2006 1
Bribery / Official Corruption 2007 2
Bribery / Official Corruption 2008 2
Bribery / Official Corruption 2009 2
Bribery / Official Corruption 2010 2
Bribery / Official Corruption 2011 3
category year count
Bribery / Official Corruption 2000 27
Bribery / Official Corruption 2001 21
Bribery / Official Corruption 2002 13
Bribery / Official Corruption 2003 13
Bribery / Official Corruption 2004 6
Bribery / Official Corruption 2005 14
Bribery / Official Corruption 2006 20
Bribery / Official Corruption 2007 36
Bribery / Official Corruption 2008 36
@blainerothrock
blainerothrock / Array+boundedLookup.swift
Created September 6, 2018 15:20
Swift Safe Array Lookup
import Foundation
extension Array {
subscript (lookup index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
let array = [1,2,3,4,5]
array[lookup: 7] // nil
@blainerothrock
blainerothrock / salesforce15to18.swift
Last active June 22, 2017 14:10
Salesforce 15 character case sensitive Id to 18 character case insensitive Id in Swift 3
import Foundation
extension String {
func isUppercased(at: Index) -> Bool {
let range = at..<self.index(after: at)
return self.rangeOfCharacter(from: .uppercaseLetters, options: [], range: range) != nil
}
}
extension Character {
@blainerothrock
blainerothrock / gen.swift
Last active July 12, 2018 15:56
A Very Simple Genetic Algorithm Written in Swift 3
#!/usr/bin/env xcrun swift -O
/*
gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3
-------------------- https://gist.github.com/cfdrake/973505 ---------------------
gen.swift implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
The parameters of the simulation can be changed by modifying one of the many