Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
actively open-sourcing

Gaetano Checinski nikhedonia

💭
actively open-sourcing
View GitHub Profile
View symbolic.fs
// Type definitions
type BinaryOP =
| Add
| Sub
| Div
| Mult
type Expr< ^T> =
| Binary of BinaryOP * Expr< ^T> * Expr< ^T>
| Value of ^T
View dual.fs
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 Mar 16, 2020
tests normalized vs denormalized+gzip data
View denormalized.js
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
View keybase.md

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:

View maybe-builder.cpp
#include <iostream>
#include <optional>
struct Unit{};
struct Entry {
auto operator()(){
return std::optional<Unit>{};
}
View backend.tf
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
View golden-print.cpp
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;
View ratiosWithPrecission.cpp
auto ratiosWithPrecission = []{
return zip([](auto prev, auto next){
return tuple{next, next - prev};
},
fibRatios(),
fibRatios() >> drop(1)
);
};
View fib-ratios-composed.cpp
auto fibRatios = [] {
return fib() >> scan(1, [](auto a, auto b){
return b/(double)a;
});
};
View fib-consume-10.cpp
int main() {
int i = 0;
for (auto x: fibRatios()) {
cout << x << endl;
if(++i != 10) break;
}
}
You can’t perform that action at this time.