Skip to content

Instantly share code, notes, and snippets.

View GuillaumePressiat's full-sized avatar

GuillaumePressiat

View GitHub Profile
@GuillaumePressiat
GuillaumePressiat / pmsi_rust_rsa.rs
Last active December 5, 2023 23:31
rust pola.rs example for fwf file
use polars::prelude::*;
use std::{
env
};
pub fn main(){
configure_the_environment();
@GuillaumePressiat
GuillaumePressiat / main_tantivy_test.rs
Created November 26, 2023 21:53
Tantivy test en Rust, slop, phraseQuery, fuzzyTerm
#[macro_use]
extern crate tantivy;
use tantivy::query::QueryParser;
use tantivy::schema::*;
use tantivy::ReloadPolicy;
use tempfile::TempDir;
use tantivy::query::FuzzyTermQuery;
use tantivy::query::PhraseQuery;
use tantivy::query::TermQuery;
use tantivy::collector::{Count, TopDocs};
@GuillaumePressiat
GuillaumePressiat / underscrape_and_RSelenium.R
Last active August 14, 2023 21:55
Using Selenium in R to scrape JS tables
# https://stackoverflow.com/q/67021563/10527496
# java -jar selenium-server-standalone-3.9.1.jar
library(RSelenium)
library(tidyverse)
library(rvest)
@GuillaumePressiat
GuillaumePressiat / municipales_lecture_data_.R
Created February 18, 2021 21:18
Lire et passer fichier data.gouv ministère intérieur commune > 1000 hab. 1er tour
library(readr)
library(dplyr)
# 1er tour
# https://www.data.gouv.fr/fr/datasets/elections-municipales-2020-resultats-1er-tour/#_
u <- read_tsv('~/Downloads/2020-05-18-resultats-communes-de-1000-et-plus.txt',
locale = locale(encoding = "latin1"),
col_types = cols(
.default = col_character(),
`Code du département` = col_double(),
@GuillaumePressiat
GuillaumePressiat / covid_sidep_sursaud_down.R
Last active October 14, 2020 08:47
Collecter les csv covid SI-DEP et SURSAUD de SPF depuis data.gouv.fr en interrogeant son api, résultat un fichier excel, ici filtré sur la Bretagne
library(dplyr, warn.conflicts = FALSE)
liste_url <- list(
indicateurs = list(url_web = "https://www.data.gouv.fr/fr/datasets/indicateurs-de-suivi-de-lepidemie-de-covid-19/",
url_stable = "https://www.data.gouv.fr/fr/datasets/r/4acad602-d8b1-4516-bc71-7d5574d5f33e",
url_api = "https://www.data.gouv.fr/api/1/datasets/5ee9df5003284f565d561278/",
titre = "Indicateurs de suivi de l’épidémie de COVID-19",
# file_pattern = "indicateurs-covid19-dep",
file_pattern = "indicateurs-open-data-dep",
delim = ",",
library(sf)
library(spatstat)
library(sp)
library(maptools)
library(raster)
library(cartography)
library(SpatialPosition)
## import dataset
feat <- sf::st_read("https://gist.githubusercontent.com/rCarto/747164575e3f216a123c3092d0ce9162/raw/f12390464f255b5f9760c577ab6bf5456cf61a40/iris75.geojson")
install_github_with_proxy <- function(package = "GuillaumePressiat/pmeasyr", proxy_port = "<host>:<port>/", ...){
u <- rstudioapi::askForPassword('User for proxy authentification')
p <- rstudioapi::askForPassword('Password for proxy authentification')
Sys.setenv(ALL_PROXY = paste0("http://", u, ":", p, "@", proxy_port))
remotes::install_github(package, ...)
}
library(leaflet)
library(sf)
library(rmapshaper)
library(dplyr, warn.conflicts = FALSE)
library(smoothr)
library(shiny)
u <- httr::GET('https://www.data.gouv.fr/api/1/datasets/5e7e104ace2080d9162b61d8/')
url_search <- httr::content(u)$resources
@GuillaumePressiat
GuillaumePressiat / fix_exfat_drive.md
Created January 10, 2020 21:05 — forked from scottopell/fix_exfat_drive.md
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
@GuillaumePressiat
GuillaumePressiat / make_er_file.R
Last active April 18, 2019 09:59
write .er entity relation Database file with R for erd https://github.com/BurntSushi/erd
library(dplyr, warn.conflicts = FALSE)
con_obj <- odbc::dbConnect(odbc::odbc(), "mydatabase")
liste_tables <- DBI::dbListTables(con_obj) %>% .[grepl('some|filter', .)]
erd_write <- function(tab){
d <- capture.output(glimpse(tbl(con_obj, tab)))
noms <- d %>% stringr::str_extract_all('^\\$ .+\\s*\\<') %>%