Skip to content

Instantly share code, notes, and snippets.

Tristram Gräbener Tristramg

Block or report user

Report or block Tristramg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View put.js
<html>
<head>
<script>
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
View sparql.rs
macro_rules! select_variables (
() => {""};
($head:ident $($tail:ident)*) => {
concat!(" ?", stringify!($head), select_variables!($($tail)*));
};
);
macro_rules! fmt(
($a:tt) => {stringify!($a)};
(?$a:tt) => {concat!("?", stringify!($a))};
View sparql.rs
macro_rules! select_variables (
() => {""};
($head:ident $($tail:ident)*) => {
concat!(" ?", stringify!($head), select_variables!($($tail)*));
};
);
macro_rules! fmt(
($a:tt) => {stringify!($a)};
(?$a:tt) => {concat!("?", stringify!($a))};
View large.sql
ALTER
TABLE countries
DROP COLUMN IF EXISTS width,
DROP COLUMN IF EXISTS height,
ADD COLUMN width float,
ADD COLUMN height float;
WITH parts AS (
select gid, (st_dump(geog::geometry)).geom AS geom FROM countries
),
View Extraire un jeu de données d’un GTFS aggrégé.txt
# Identifier le réseau à extraire
* Dans le GTFS, choisir le réseau à isoler à partir du fichier agency.txt
* Notez le `agency_id`
* Par exemple pour Carabus, `CAR:Authority:1`
# Utilisez l’outil OneBusAway
* Téléchargez sur http://developer.onebusaway.org/modules/onebusaway-gtfs-modules/1.3.4-SNAPSHOT/onebusaway-gtfs-transformer-cli.html
* Executez:
`java -jar onebusaway-gtfs-transformer-cli-1.3.4-20150503.062227-12.jar --transform='{"op": "retain", "match": {"file": "agency.txt", "agency_id": "CAR:Authority:1"}}' naq-aggregated-gtfs.zip carabus.zip`
View frechet.rs
use std::f64;
#[derive(Clone)]
pub struct Point {
pub lat: f64, // plutôt y (cf le pâté en bas)
pub lon: f64, // plutôt x
}
// la convention est plutôt d’avoir juste new. Point::new est moins redondant que Point::new_point
// Cependant, tout particulièrement dans le cas des coordonnées l’ordre est source de confusion.
View gist:7bb2cf7fb172d74b3fcae6e8e6367cd8
[error] GenServer Transport.ImportDataWorker terminating
** (Ecto.MultipleResultsError) expected at most one result but got 2 in query:
from r0 in Transport.Resource,
where: r0.url == ^"http://www.metromobilite.fr/data/Horaires/SEM-GTFS.zip"
(ecto) lib/ecto/repo/queryable.ex:69: Ecto.Repo.Queryable.one/3
(transport) lib/transport/resource.ex:84: Transport.Resource.save/2
(transport) lib/transport/resource.ex:55: Transport.Resource.validate_and_save/1
(transport) lib/transport/import_data_worker.ex:37: Transport.ImportDataWorker.handle_cast/2
View insert.sql
WITH grenoble AS (
SELECT id from dataset where spatial = 'Grenoble-Alpes Métropole'
)
INSERT into resource
(dataset_id, url, format, title)
SELECT grenoble.id, resource.* FROM (VALUES
('https://app-be8e53a7-9b77-4f95-bea0-681b97077017.cleverapps.io/gtfs_rt', 'gtfs-rt', 'Flux temps réel GTFS RT'),
('https://app-be8e53a7-9b77-4f95-bea0-681b97077017.cleverapps.io/', 'siri-lite', 'API temps réel Siri Lite')
) as resource, grenoble;
@Tristramg
Tristramg / aom_insee.tsv
Created Dec 7, 2018
Mapping each insee code to the corresponding AOM
View aom_insee.tsv
201 80001
201 80029
201 80051
201 80078
201 80099
201 80110
201 80135
201 80146
201 80163
201 80171
View actix_actor_web.rs
extern crate actix;
use actix::{Actor, Addr, Context, Handler, Message};
use std::time::Duration;
extern crate futures;
use actix::AsyncContext;
use futures::Future;
extern crate actix_web;
use actix_web::{http, server, App, AsyncResponder, Error, State};
struct MyActor {
You can’t perform that action at this time.