Skip to content

Instantly share code, notes, and snippets.

View warrenrentlytics's full-sized avatar
⛰️
One must imagine Sisyphus happy.

Warren Henning warrenrentlytics

⛰️
One must imagine Sisyphus happy.
  • @rentlytics
View GitHub Profile
@warrenrentlytics
warrenrentlytics / birthdays.cpp
Created February 27, 2019 11:15
naive birthday collision calculations: a raw quadratic loop seems faster than sorting
#include <iostream>
#include <vector>
#include <random>
int main() {
const int experiment_cnt = 1000;
std::random_device rd;
std::mt19937 generator(rd());
std::uniform_int_distribution<int> distribution(1, 365);
@warrenrentlytics
warrenrentlytics / gist:c9a1836a40d4fcbba28a7e29357dad7d
Created October 25, 2018 07:48
Working example of using Boost Geometry for k-nearest neighbors search with an R-tree
/* compile with:
clang++ -std=c++2a -I . -Ofast -march=native rtree_nearest_neighbor_test.cpp -o rtree_nearest_neighbor_test
adjust the -I parameter depending on where boost is located.
*/
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/index/rtree.hpp>
@warrenrentlytics
warrenrentlytics / Cargo.toml
Last active February 16, 2022 23:43
Simple example of using rust-postgres with chrono + chrono date arithmetic and UTC -> local time conversion with UTC dt stored properly in postgres
[package]
name = "postgres_test"
version = "0.1.0"
authors = ["Warren Henning <warren@rentlytics.com>"]
edition = "2018"
[dependencies]
chrono = { version = "0.4", features = ["serde"] }
postgres = { version = "0.15", features = ["with-time", "with-chrono"] }
@warrenrentlytics
warrenrentlytics / pcg32.rs
Created October 10, 2018 05:34
Working PCG32 generator, updated from https://github.com/EricIO/pcg-rust
// Copyright 2015 Eric Skoglund
//
// Licensed 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
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
gnatmake -Wall -Wextra -Wshadow -Werror -Wfatal-errors -pedantic -m64 -Wcast-align -Wstrict-overflow=5 -Winline -Wshadow -Wstrict-aliasing=2 -O3 -gnatp main.adb
@warrenrentlytics
warrenrentlytics / greeter_client.py
Created August 20, 2018 23:02
gRPC file evaluation example
# Copyright 2015 gRPC authors.
#
# Licensed 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@warrenrentlytics
warrenrentlytics / JavaFXLayoutTimingTest.java
Last active August 15, 2018 21:32
Shows a faster, better way of updating a set of string labels. The comments have a slower version that completely redraws the screen and is massively slower: > 30 ms vs 0-2 ms
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;