Skip to content

Instantly share code, notes, and snippets.

View Alexandre-Herve's full-sized avatar

Alexandre Hervé Alexandre-Herve

View GitHub Profile
@Alexandre-Herve
Alexandre-Herve / typesafe-routes-proxy.ts
Last active September 20, 2022 18:51
A Typesafe version of @denisborovikov's routes proxy wrapper
// Tweaked from https://gist.github.com/denisborovikov/3e6e772d9d1897c150639872467d214f
const routes = {
home: '/',
transactions: '/transactions',
transactionDetails: '/transactions/:uuid/:optional?',
transfer: '/transfer/:type(bank|card)?/:id?'
} as const // prevents Typescript from widening the path types to string.
type Routes = typeof routes;
@Alexandre-Herve
Alexandre-Herve / Main.elm
Last active May 15, 2017 09:48
A way to handle cross-pages shared actions in Elm
module Main exposing (main)
import Model exposing (Model, initialModel)
import Html exposing (Html, div, text, button)
import Html.Events exposing (onClick)
import Shared
import Page
import Debug
@Alexandre-Herve
Alexandre-Herve / saveAllPublications.js
Last active December 23, 2015 16:21
resolving all promise and saving
function postFb(asker) {
return new Promise((resolve) => {
fb.setAccessToken(asker.token);
fb.post(
"/feed",
{ message: answerLink },
function(err, res) {
asker.success = !err;
asker.details = asker.success ? res.id : err.message + ', fbtrace_id = ' + err.fbtrace_id;
resolve(asker);
@Alexandre-Herve
Alexandre-Herve / redirection.js
Last active January 9, 2016 09:03
Custom client redirection after social authentication using passport, koa and koa-router
/**
* This is how I configure koa-router
* with passport to redirect the user
* to exactly where they were in the
* application after a successful
* social authentification.
*/
// store client-provided redirection url
// in session cookie to retrieve it later.