Skip to content

Instantly share code, notes, and snippets.

View blackheaven's full-sized avatar

Gautier DI FOLCO blackheaven

View GitHub Profile
RMFLAGS = -f
REAL = main.c
OBJ = $(REAL:.c=.o)
EXE = tpthreads
EFFACE = clean
RM = rm
COMP = gcc
EDL = gcc
LIBS = -pthread -O3 -ffast-math
API =
@blackheaven
blackheaven / policy_telldontask.rb
Created August 11, 2013 19:59
Some thoughts on OOP principles
class Ctrl
def close
user = User.new # load from somewhere
CloseAccountPolicy.new(user).apply!
puts user.inspect
end
end
# Nearly an AnemicDomainModel because some of it's behavor is externalized
class User
@blackheaven
blackheaven / gist:8131479
Created December 26, 2013 09:05
Why I don't like dynamic types systems.
<?php
// web/index.php in Silex
// ..
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
'locale' => array('fr'), // Instead of 'locale' => 'fr',
));
-module(list).
-export([merger/0, atomic_sort/0, accumulator/0, last/1, init/0, add/2, get/1]).
atomic_sort() ->
receive
{L, Accumulator, Merger, Last} ->
Accumulator ! {lists:sort(L), Merger, Last},
atomic_sort()
end.
module Gol where
import Text
import Graphics.Input as Input
import Dict
import Set
import Benchmark (..)
import Data.Function
import Data.List
import Data.Maybe
import Control.Monad
data XmlElement =
RegularNode String [XmlElement]
| EndNode String
| TextNode String
deriving (Show, Eq)
import Data.List(groupBy, sortBy)
import Data.Maybe(listToMaybe)
import Control.Applicative((<|>))
data Trie k v = RootTrie [Trie k v]
| NodeTrie k [Trie k v]
| EndTrie v
| EmptyTrie
toTrie :: (Eq k, Ord k) => [([k], v)] -> Trie k v
@blackheaven
blackheaven / Kata.hs
Created June 1, 2018 21:25
Coding Dojo (18-05-30) on K-means
module Kata
( kmeans
, randV
, prettifier
) where
import Data.List(groupBy, sortBy, minimumBy, unfoldr)
import Data.Function(on)
import System.Random(newStdGen, randomRs)
module Y2018.M11.D26.Exercise where
import qualified Data.Set as S
import Control.Monad(foldM)
import Data.List(sort)
{--
An IQ puzzler:
Four (A, B, C and D) suspects were interrogated:
@blackheaven
blackheaven / CassandraModSeqProvider.java
Created January 29, 2019 14:41
Mono.defer allow to be replayable
private Mono<ModSeq> handleRetries(CassandraId mailboxId) {
return Mono.defer(() -> tryFindThenUpdateOnce(mailboxId))
.retry(maxModSeqRetries);
}