Skip to content

Instantly share code, notes, and snippets.

💭
actively open-sourcing

Gaetano Checinski nikhedonia

💭
actively open-sourcing
Block or report user

Report or block nikhedonia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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;
}
}
View golden-fib-composed.cpp
auto ratios = []{
 return fib() >> scan(1, [](auto prev, auto next){
  return next / prev; 
  });
};
int main() {
  auto fiveFibs = fib() >> take(5); // 0, 1, 1, 2, 3
  auto ratiosTenToTwenty = ratios() 
  >> drop(1
View golden-fib.cpp
int main () {
  int n=100;
  auto prevRatio = 0.0;
  for (auto ratio: fibRatios()) {
  cout << ratio << endl;
  auto delta =  ratio - prevRatio;
  if (n==0 || delta < 0.0001)
  break;
  prevRatio = ratio;
  n- - ;
View fib.cpp
auto fib() -> seq<int> {
  int a = 0;
  int b = 1;
 
  while (1) {
  co_yield a;
  tie(a, b) = tuple{b, a+b};
  }
}
You can’t perform that action at this time.