Skip to content

Instantly share code, notes, and snippets.

View shinnya's full-sized avatar

Shinya Yamaoka shinnya

  • Japan
View GitHub Profile
@shinnya
shinnya / failure_detector1.erl
Created May 8, 2020 00:50
Implementing the weakest failure detector for solving consensus Mikel Larrea, Antonio Fernández Anta, Sergio Arévalo
%% This module implements f-Resilient ♦S failure detector described in
%% "Implementing the weakest failure detector for solving consensus
%% Mikel Larrea, Antonio Fernández Anta, Sergio Arévalo"
-module(failure_detector).
-behaviour(gen_statem).
%% API
-export([start_link/3,
get_leader/0,
@shinnya
shinnya / amazon.md
Created November 9, 2019 05:59 — forked from terabyte/amazon.md
Amazon's Build System

Prologue

I wrote this answer on stackexchange, here: https://stackoverflow.com/posts/12597919/

It was wrongly deleted for containing "proprietary information" years later. I think that's bullshit so I am posting it here. Come at me.

The Question

Amazon is a SOA system with 100s of services (or so says Amazon Chief Technology Officer Werner Vogels). How do they handle build and release?

@shinnya
shinnya / futures_ext.rs
Created February 13, 2019 06:24
An example of CompletableFuture with fibers-rs
use fibers::{sync::oneshot, time::timer};
use futures::{Async, Future, Poll, Select};
use futures::future::Either;
use std::marker::PhantomData;
use std::time::Duration;
// your custom error type.
use Error;
type BoxFuture<T, E> = Box<Future<Item = T, Error = E> + Send + 'static>;
@shinnya
shinnya / create_buckets.sh
Last active December 7, 2018 09:10
frugalos 50 nodes
#!/usr/bin/env bash
CURL=curl
API_BASE=http://frugalos1
$CURL -X PUT -d '{"dispersed": {"id": "vod", "device":"root", "tolerable_faults": 1, "data_fragment_count": 2}}' $API_BASE/v1/buckets/vod
/*
* GTK - The GIMP Toolkit
* Copyright (C) 2002 Owen Taylor
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
[Desktop Entry]
Version=1.0
Type=Application
Name=CLion
Icon=/opt/clion-2018.2.2/bin/clion.svg
Exec="/opt/clion-2018.2.2/bin/clion.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-clion
@shinnya
shinnya / index.md
Created October 29, 2018 07:02
rust rfc2535

2535-or-patterns -

Summary

パターンマッチ内で任意にネストした形式で |(or pattern) を使えるようにする。 記法は Some(A(0) | B(1 | 2)) のようになる。

以前は Some(A(0)) | Some(B(1)) | Some(B(2)) のように書かなければならなかった。

Motivation

@shinnya
shinnya / List.cpp
Created July 10, 2018 15:50
Incorrect Doubly Linked List
#include <memory>
#include <string>
#include <iostream>
using namespace std;
template <typename K, typename V>
struct Node
{
K key;
@shinnya
shinnya / thread.ml
Created April 7, 2018 01:15 — forked from eatonphil/thread.ml
Basic thread logic based on condition variables in Poly/ML
(*
* Tested in Poly/ML. To compile: `polyc thread.ml && ./a.out`
*
* Heavily influenced by: http://pages.cs.wisc.edu/~remzi/OSTEP/threads-cv.pdf
* Poly/ML Thread documentation here: http://www.polyml.org/documentation/Reference/Threads.html
* Poly/ML Thread implementation here: https://github.com/polyml/polyml/blob/master/basis/Thread.sml
*)
val done = ref false;
val m = Thread.Mutex.mutex();