Skip to content

Instantly share code, notes, and snippets.

View nikhedonia's full-sized avatar
💭
actively open-sourcing

Gaetano Checinski nikhedonia

💭
actively open-sourcing
View GitHub Profile
// Type definitions
type BinaryOP =
| Add
| Sub
| Div
| Mult
type Expr< ^T> =
| Binary of BinaryOP * Expr< ^T> * Expr< ^T>
| Value of ^T
type ^T Dual
when ^T: (static member (+): ^T * ^T -> ^T)
and ^T: (static member (-): ^T * ^T -> ^T)
and ^T: (static member (*): ^T * ^T -> ^T)
and ^T: (static member (/): ^T * ^T -> ^T)
(real: ^T, imag: ^T) =
member inline this.x = real
member inline this.y = imag
static member inline (+) (lhs: Dual< ^T>, rhs: Dual< ^T>) =
@nikhedonia
nikhedonia / denormalized.js
Last active March 16, 2020 10:56
tests normalized vs denormalized+gzip data
const {writeFileSync} = require('fs');
const { normalize, schema } = require('normalizr');
const faker = require('faker');
const murmur = require("murmurhash-js");
const genId = (data) => murmur(JSON.stringify(data));
// Define a users schema
const user = new schema.Entity('users', undefined, {
idAttribute: genId

Keybase proof

I hereby claim:

  • I am nikhedonia on github.
  • I am nikhedonia (https://keybase.io/nikhedonia) on keybase.
  • I have a public key ASBu9ecCWZVB-9qRvRf9spFQthdecGFP8m5Uh8ejopz4EQo

To claim this, I am signing this object:

#include <iostream>
#include <optional>
struct Unit{};
struct Entry {
auto operator()(){
return std::optional<Unit>{};
}
provider "aws" {
region = "eu-west-1"
}
terraform {
backend "s3" { # will handle correctly multiple workspaces
bucket = "project"
region = "eu-west-1"
key = "project/terraform.tfstate"
dynamodb_table = "project-terraform-lock" # to prevent race conditions, table needs to be created manually
double golden(double epsilon=0.00001) {
int a = 0;
int b = 1;
double ratio = 0;
while (1) {
tie(a, b) = tuple{b, a+b};
auto delta = b / (double)a - ratio;
ratio = b / (double)a;
cout << ratio << endl;
auto ratiosWithPrecission = []{
return zip([](auto prev, auto next){
return tuple{next, next - prev};
},
fibRatios(),
fibRatios() >> drop(1)
);
};
auto fibRatios = [] {
return fib() >> scan(1, [](auto a, auto b){
return b/(double)a;
});
};
int main() {
int i = 0;
for (auto x: fibRatios()) {
cout << x << endl;
if(++i != 10) break;
}
}