Skip to content

Instantly share code, notes, and snippets.

View fchabouis's full-sized avatar

Francis Chabouis fchabouis

  • France
View GitHub Profile
@fchabouis
fchabouis / gist:58a297d263d52678ddd0da026adea214
Last active October 14, 2021 13:53
Elixir Livebook : GTFS to GeoJson conversion using Oban

Oban

Objectif

Lancer via Oban un job de conversion d'un GTFS en GeoJson.

On passe l'url du GTFS au worker. Celui ci le télécharge et le convertit en GeoJson, le sauvegarde dans un fichier et notifie le process principal lorsqu'il a terminé en lui indiquant l'emplacement du résultat.

@fchabouis
fchabouis / stream.ex
Last active March 31, 2022 05:12
Elixir : Stream a paginated API to a Postgres database, all included
Mix.install([
{:ecto_sql, "~> 3.7.0"},
{:postgrex, "~> 0.15.0"},
{:httpoison, ">= 0.0.0"},
{:jason, ">= 0.0.0"}
])
require Logger
# SETUP DATABASE, THANKS TO https://github.com/wojtekmach/mix_install_examples
@fchabouis
fchabouis / gist:53e6d17145ab9b0eca10a6a741d37062
Last active September 15, 2021 08:34
Example output of a gtfs to geojson conversion
{
"type": "FeatureCollection",
"features": [
{
"geometry": {
"coordinates": [
-0.325292095610137,
47.8370966038058
],
"type": "Point"
@fchabouis
fchabouis / main.rs
Created January 19, 2021 16:29
Actix-web example : return errors as json
// This example is meant to show how to automatically generate a json error response when something goes wrong.
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::io;
use actix_web::http::StatusCode;
use actix_web::{get, web, App, HttpServer, ResponseError};
use serde::Serialize;
use serde_json::{json, to_string_pretty};
// We create a custom structure for the error
@fchabouis
fchabouis / main.rs
Created January 7, 2021 14:51
Rust Actix simple Actor communication - Arc Version
use actix::prelude::*;
use std::sync::Arc;
/// Define message
#[derive(Message)]
#[rtype(result = "Result<Arc<String>, std::io::Error>")]
struct WhatsYourName;
#[derive(Message)]
#[rtype(result = "()")]
@fchabouis
fchabouis / main.rs
Created January 7, 2021 14:44
Rust Actix simple Actor communication
use actix::prelude::*;
/// Define message
#[derive(Message)]
#[rtype(result = "Result<String, std::io::Error>")]
struct WhatsYourName;
#[derive(Message)]
#[rtype(result = "()")]
struct SetYourName {
@fchabouis
fchabouis / gist:39d77ae07fc96d12833a5be7cd9cbbf0
Created December 18, 2020 15:48
Run cypress tests with vuejs and docker
version: 2.1
jobs:
build_and_test:
docker:
- image: cypress/included:3.2.0
environment:
## this enables colors in the output
TERM: xterm
steps:
- checkout