Skip to content

Instantly share code, notes, and snippets.

View franckverrot's full-sized avatar
📚
🥋

Franck Verrot franckverrot

📚
🥋
View GitHub Profile
@franckverrot
franckverrot / lock.mzn
Last active April 23, 2020 19:59
MiniZinc version of the lock problem
var 0..9: POS_1;
var 0..9: POS_2;
var 0..9: POS_3;
constraint (
% 682 one correct and well placed
(
(POS_1 == 6 /\ (not (POS_2 in {8, 2})) /\ (not (POS_3 in {8, 2})))
\/ (POS_2 == 8 /\ (not (POS_1 in {6, 2})) /\ (not (POS_3 in {6, 2})))
@franckverrot
franckverrot / lock.pl
Created April 12, 2020 04:43
Lock code
solution(POS_1, POS_2, POS_3) :-
member(POS_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
member(POS_2, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
member(POS_3, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
/* 682 one correct and well placed */
( POS_1 = 6; POS_2 = 8; POS_3 = 2),
/* 614 one correct not well placed */
(
@franckverrot
franckverrot / sendRawEth.c
Created March 28, 2020 16:49 — forked from austinmarton/sendRawEth.c
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
@franckverrot
franckverrot / Zero_knowledge_db.md
Created March 22, 2019 18:35 — forked from thiloplanz/Zero_knowledge_db.md
Zero-knowledge databases

Zero knowledge databases

The idea

The idea is to provide a database as a service to end users in such a way that no one except the user herself can access the data, not even the hosting provider or the database administrator.

Advantages

  • A privacy- and/or security-conscious user will have more trust in such a setup.
  • The service provider cannot be coerced to release the data they were trusted with, and he cannot be held responsible for the content he is storing.
@franckverrot
franckverrot / latency.markdown
Created September 16, 2018 17:42 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@franckverrot
franckverrot / latency.txt
Created September 16, 2018 17:37 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
require 'fiddle'
require 'minitest/autorun'
class RubyVM
class InstructionSequence
address = Fiddle::Handle::DEFAULT['rb_iseq_load']
func = Fiddle::Function.new(address, [Fiddle::TYPE_VOIDP] * 3, Fiddle::TYPE_VOIDP)
define_singleton_method(:load) do |data, parent = nil, opt = nil|
func.call(Fiddle.dlwrap(data), parent, opt).to_value
@franckverrot
franckverrot / gist:dc870fb763b785308bb5ea715185902c
Created January 17, 2018 05:01 — forked from bobzhen/gist:b03329713db40f80b4e70922ede8704b
Phoenix Framework v1.3: Brunch Install Bootstrap 4.0.0-beta with Font-Awesome

Install Dependencies

npm install --save jquery popper.js tether bootstrap@4.0.0-beta font-awesome // popper.js for bootstrap 4 dependency

Copy font-awesome fonts to assets/static/fonts folder

cp -r assets/node_modules/font-awesome/fonts to assets/static
@franckverrot
franckverrot / poolboy_demo.ex
Created January 13, 2018 15:14 — forked from henrik/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000
@franckverrot
franckverrot / ladder.md
Created June 20, 2017 03:24 — forked from jamtur01/ladder.md
Kickstarter Engineering Ladder