Skip to content

Instantly share code, notes, and snippets.

View lilobase's full-sized avatar

Arnaud LEMAIRE lilobase

View GitHub Profile
namespace App\Membership\Infrastructure\Doctrine;
use App\Membership\Domain\Membership;
trait MembershipObjectMapper
{
static function fromDoctrine(MembershipDoctrineEntity $entity): Membership
{
$instance = new self();

Keybase proof

I hereby claim:

  • I am lilobase on github.
  • I am lilobase (https://keybase.io/lilobase) on keybase.
  • I have a public key ASDTMYQWBwf0xz5BBC2vJmW3cGsDYr00Qb0yzC4AvhxRxQo

To claim this, I am signing this object:

const http = require('http');
const url = require('url');
const server = http.createServer(({url: path}, res) => {
const {pathname, query} = url.parse(path);
const date = new Date(query.split('=')[1]);
const response = content => {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify(content));
@lilobase
lilobase / 0_reuse_code.js
Created July 26, 2017 14:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@lilobase
lilobase / JooqObjectReflexionMapper.java
Last active June 12, 2017 09:18
Basic repository for CQRS system
public abstract class JooqObjectReflexionMapper<R> extends JooqObjectMapper<R> {
public JooqObjectReflexionMapper(ObjectMapper jackson) {
super(jackson);
}
@Override
public R map(Record record) {
HashMap<String, Class<?>> types = mapFieldsToTypes();
R instance = newInstance();
@lilobase
lilobase / FizzBuzzPBTTest.java
Last active September 2, 2016 09:18
Property Based Testing Java with Quickcheck, Code made for the PBT session at SoCraTes Soltau 2016
import com.pholser.junit.quickcheck.*;
import com.pholser.junit.quickcheck.runner.*;
import org.junit.runner.*;
import static org.assertj.core.api.Java6Assertions.*;
import static org.hamcrest.core.IsEqual.*;
import static org.junit.Assume.*;
@RunWith(JUnitQuickcheck.class)
public class FizzBuzzPropertiesTest {
const boxes = [[2, 3, 4], [1, 1, 10]];
const sides = ([a, b, c], acc = []) => (acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b]));
const total_box_surface = (acc, box) => (b => acc + b.reduce((a, b) => a + b) * 2 + Math.min(...b))(sides(box));
const total_surface_area = boxes => boxes.reduce(total_box_surface, 0);
console.log(total_surface_area(boxes));
const boxes = [[2, 3, 4], [1, 1, 10]];
const sides = ([a, b, c], acc = []) => (acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b]));
const box_surface = (acc, side) => (acc + side) ;
function total_surface_area(boxes) {
return boxes.reduce((acc, box) =>
(b => acc + b.reduce(box_surface) * 2 + Math.min(...b))(sides(box)), 0);
}
const boxes = [[2, 3, 4], [1, 1, 10]];
const apply = (f, i) => (f(i));
const sides = ([a, b, c], acc = []) => (acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b]));
const box_surface = (acc, side) => (acc + side) ;
function total_surface_area(boxes) {
return boxes.reduce((acc, box) =>
apply((b) => acc + b.reduce(box_surface) * 2 + Math.min(...b), sides(box)), 0);
const boxes = [[2, 3, 4], [1, 1, 10]];
const sides = ([a, b, c], acc = []) => (acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b]));
const box_surface = (acc, side) => (acc + side) ;
function total_surface_area(boxes) {
return boxes.reduce((acc, box) => {
const box_sides = sides(box)
return acc + box_sides.reduce(box_surface) * 2 + Math.min(...box_sides);
}, 0);