Skip to content

Instantly share code, notes, and snippets.

View termoose's full-sized avatar

Ole Andre Birkedal termoose

  • Oslo
View GitHub Profile
@termoose
termoose / LostCitiesBot
Last active December 31, 2015 01:09
Lost Cities player using Monte-Carlo methods in F#
// The cards color type
type Color =
| Blue
| Red
| Green
| White
| Yellow
// The cards type
type Type =
std::vector<int> range(int a, int b)
{
std::vector<int> result(b-a);
std::iota(std::begin(result), std::end(result), a);
return result;
}
for(int i : range(5, 10))
{
template<typename T> using Index = typename T::iterator::difference_type;
template<typename T>
std::pair<typename T::iterator::difference_type, T> prefix_match(T a, T b)
{
auto mismatch = std::mismatch(a.cbegin(), a.cend(), b.cbegin());
auto index = std::distance(a.cbegin(), mismatch.first);
return std::make_pair(index, T(a.cbegin(), mismatch.first));
}
# Deleter.ex
defmodule Ekko.Deleter do
use GenServer
def start_link() do
GenServer.start_link(__MODULE__, [], name: Deleter)
end
def handle_call(:delete, from) do
IO.puts "handle_call in Deleter called"
@termoose
termoose / gist:4eb507c9f4817d4d8b9f
Created April 10, 2015 10:02
Variadic templates
void Add() { }
void Add(std::string data)
{
vector.push_back(data);
}
template<typename... Args>
void Add(std::string first, Args... args)
{
0x055cEa822bf636Efc9B3d85F24A2c2fb8a6d45b9
0x055cEa822bf636Efc9B3d85F24A2c2fb8a6d45b9
@termoose
termoose / callback.ex
Created July 23, 2018 17:31
Elixir callbacks
defmodule Mod do
use GenServer
def start_link(_args) do
GenServer.start_link(__MODULE__, :ok)
end
def init(:ok) do
send(self(), :work)
{:ok, :ok}

Keybase proof

I hereby claim:

  • I am termoose on github.
  • I am termos (https://keybase.io/termos) on keybase.
  • I have a public key whose fingerprint is 798A 2030 AFF6 D9E3 1F85 ADC9 A3E1 C76D 709C 9C92

To claim this, I am signing this object:

.........398.............551.....................452..................712.996.................646.40...1.....875..958.553...................
..................................661..-844......*.../781...835..#163....*.......698.239.........*.....*.............*............*57.......
.....................&...............*......+..139..................................*.........-.......282......................301..........
........518..........918..-....472..172....776......207............38........................860..............274..945.....162..............
........@..........#.....845..*........................*.............*....896...+.....153................@......*...*.......#.........441...
..................740.21.....303...744.........190......173.395...729...-....&..925....@..5..............172...566..193...........#.........
...598...967*.........*...........*.......164.=......91......*...........192................292...........................414=.215..........
.............238.......661.....-.149.