Skip to content

Instantly share code, notes, and snippets.

View Vermeille's full-sized avatar

Guillaume "Vermeille" Sanchez Vermeille

View GitHub Profile
@Vermeille
Vermeille / split1.cpp
Created December 24, 2016 10:49
A Good, Idiomatic, STL-like split algorithm?
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <utility>
/*
This split impl has a nice prototype and isn't callback / continuation
oriented. However, it has two major drawbacks
1) Iterating over it is a bit painful. See below.
@Vermeille
Vermeille / structural_polymorphism.cpp
Created November 14, 2017 14:09
structural polymorphism in C++
#include <iostream>
#include <memory>
#include <vector>
/*
* This snippet is demonstrating a powerful technique enabling local and
* concept-based polymorphism. Think of it as interfaces on steroids:
* They're local, non intrusive, which means you don't have to think of them
* ahead, they don't make virtual calls when you don't want to use them, etc.
*
@Vermeille
Vermeille / main.js
Last active February 5, 2018 22:22
Facebook plugin: Screenshot this thread
// code for Custom Javascript for Websites 2
// External library needed: https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js
// and jQuery 3
function delay(t, v) {
return new Promise(function(resolve) {
setTimeout(resolve.bind(null, v), t);
});
}
@Vermeille
Vermeille / encrypt.js
Last active February 10, 2018 23:04
facebook messenger encryption
// configure with jQuery 3
async function aesGcmEncrypt(plaintext, password) {
const pwUtf8 = new TextEncoder().encode(password); // encode password as UTF-8
const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8); // hash the password
const iv = crypto.getRandomValues(new Uint8Array(12)); // get 96-bit random iv
const alg = { name: 'AES-GCM', iv: iv }; // specify algorithm to use
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Bootstrap "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" disable for pathogen
filetype plugin off
" call pathogen
call plug#begin('~/.vim/plugged')
#!/bin/bash
content=$(curl -s http://feeds.feedburner.com/PornstarBirthdays | egrep 'title|link' | sed 's/<.*>\([^<]*\)<\/.*>/\1/' | tail -n+6)
idx=$(($RANDOM % ($(echo "$content" | wc -l) / 2) ))
renderer="./catimg/build/bin/catimg -r 1 -w 40"
echo "$content" | tail -n"$(($idx * 2 + 2))" | head -n2 | while read i ; do
case $i in
*http*) curl -s $(echo "$i" | tr -d '[:space:]') \
@Vermeille
Vermeille / I_hate_props_drilling.md
Last active March 5, 2018 11:11
React thoughts

I hate props drilling (my background)

I hate props drilling. I despise it. Is spent the last years writing C++ and fighting hard with my code habits to have a code that is not just working, but also semantically correct. Having code that makes sense is hard, but has all the possible qualities good code can have: since the concerns are well delimited, each class / component / module tends to be independant, reusable, and easily testable. Your code just makes sense. It's also simpler, because the design is just good. The maintainability is greater. And all sorts of things.