Skip to content

Instantly share code, notes, and snippets.

@sebn
sebn / life.exs
Created June 17, 2021 06:56
Game of Life rules implementation in ~20 lines of Elixir
#!/usr/bin/env elixir
defmodule Life do
def step(live_cells) do
live_cells
|> Enum.flat_map(&neighbours(&1))
|> Enum.frequencies()
|> Enum.filter(fn {cell, live_neighbours} ->
was_live = MapSet.member?(live_cells, cell)
live_neighbours == 3 || (live_neighbours == 2 && was_live)

Keybase proof

I hereby claim:

  • I am sebn on github.
  • I am sebn0 (https://keybase.io/sebn0) on keybase.
  • I have a public key ASAsQ-6FFTkgvKiQpOqIK6kejVizwJtSvi8r7JuYZoRpFgo

To claim this, I am signing this object:

$ go test -v ./...
? cozy/cozy-stack [no test files]
? cozy/cozy-stack/cmd [no test files]
? cozy/cozy-stack/cmd/browser [no test files]
git : 'daemon' n'est pas une commande git. Voir 'git --help'.
panic: exit status 1
goroutine 51 [running]:
panic(0xa07e60, 0xc4201b1520)
@sebn
sebn / api.js
Last active September 6, 2016 09:14
Promisified startScan() and stopAfter()
const Scan = {
stopAfter: (timeout) => {
return new Promise(resolve => {
setTimeout(() => {
ReactNativeBluetooth.stopScan.then(resolve);
}, timeout);
})
}
}
@sebn
sebn / test.js
Created November 25, 2013 13:52
Test Tumblr
var test = function() {
return 0;
}
@sebn
sebn / index.html
Last active December 28, 2015 07:39
<form class="well" ng-submit="addEntryLine()" name="new_entry_form" novalidate>
<input ng-model="form.date" class="input-small" type="text" required rb-focus-on-event="focus-date" ng-disabled="firstLineEntered()" placeholder="Date" ui-date rb-on-select-focus="*[ng-model='form.line.account']">
<input ng-model="form.line.account" type="text" required rb-focus-on-event="focus-account" placeholder="Compte" name="account" ng-pattern="/^\d{3}.*$/">
...
</form>
<?php
/**
* ownCloud setup wizard
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either