Skip to content

Instantly share code, notes, and snippets.

View briatte's full-sized avatar

François Briatte briatte

View GitHub Profile
library(httr)
adresse <- "8 bd du port"
resultraw <- httr::GET(utils::URLencode(paste0('https://api-adresse.data.gouv.fr/search/?q=', adresse)))
result <-jsonlite::fromJSON(httr::content(resultraw, "text"))
result$features
@briatte
briatte / update.sh
Created June 4, 2017 00:07
update website files – checks certain files from a given folder, diff them against their online versions, and update the online version if they are not in sync; find and fill in all instances of '###' before running
#!/bin/sh
ONLINE='###WEBSITE_ADDRESS###'
OFFLINE='###WEBSITE_OFFLINE_ADDRESS###'
FTP_ADDRESS='###FTP_ADDRESS###'
FTP_FOLDER='###FTP_ROOT_FOLDER###'
FTP_USER='###FTP_USERNAME###'
FTP_PASS='###FTP_PASSWORD###'
cd $OFFLINE
@briatte
briatte / import_me.opml
Created May 24, 2017 01:13
OPML template to import feeds that are too heavy for the default 'Add Feed' mechanism in Digg Reader
<?xml version="1.0" encoding="iso-8859-1"?>
<opml version="1.0">
<head>
<title>Sample OPML file</title>
</head>
<body>
<outline title="Gists: dsparks" text="" type="rss" version="RSS" xmlUrl="https://gist.github.com/dsparks.atom" htmlUrl="https://gist.github.com/dsparks"/>
</body>
</opml>
# Original by Kevin Ushey:
# https://raw.githubusercontent.com/kevinushey/etc/master/dotfiles/.Rprofile
.First <- function() {
# only run in interactive mode
if (!interactive())
return()
# create .Rprofile env
{
"user": {
"id": "1234567890",
"screen_name": "example"
},
"timeline": [
{
"headline": "Sh*t People Say",
"type": "default",
"text": "People say stuff",

Keybase proof

I hereby claim:

  • I am briatte on github.
  • I am briatte (https://keybase.io/briatte) on keybase.
  • I have a public key whose fingerprint is CF1D 937F 13FD 11F4 9060 57C7 EC0B 0E46 6A4C 4EDE

To claim this, I am signing this object:

@briatte
briatte / conswing.R
Created April 24, 2017 20:45 — forked from chrishanretty/conswing.R
Analysis of swings in Conservative and Labour-held seats, BES data
library(foreign) ## for data import
library(dplyr) ## for chaining ops together
library(ggplot2) ## for plotting
library(reshape2) ## for reshaping
library(hrbrthemes) ## for pretty pictures
library(survey) ## for... uh, survey data
party.colours <- c("#0087DC","#D50000","#FDBB30","#FFFF00","#008142","#99CC33","#70147A","#DDDDDD")
bes <- read.spss("~/Dropbox/2017-forecasting/data/individual/BES2015_W10_Panel_v0.3.sav")
@briatte
briatte / ess.do
Last active April 8, 2017 12:44
Stata code to estimate likelihood of having voted in last election by income quintile, controlling for age and sex. Estimation performed on French citizens who responded to ESS rounds 4 (c.2008) and 5 (c.2010), roughly one and three years after the last national election. Baseline for age group = 18-34 year-olds. File ess2014.do does the same th…
cap log close
log using /Users/fr/Desktop/ess.log, replace
use data/ess0810 if cntry == "FR" & ctzcntr == 1, clear
fre vote
gen voted = (vote == 1) if vote < 3 & !mi(vote)
prop voted if essround == 4 [pw = dweight] // 2008
prop voted if essround == 5 [pw = dweight] // 2010
@briatte
briatte / 00_README.md
Last active March 28, 2017 10:30
code and data for 'Macron, combien de défections ?' – https://politbistro.hypotheses.org/4606
@briatte
briatte / code.r
Last active March 18, 2017 19:45
comparaison parrainages 2017 / vote Hollande 2012 – voir ce billet : https://politbistro.hypotheses.org/4505
library(readr)
library(dplyr)
library(ggplot2)
# résultats Hollande 2012
p12 <- read_csv("p12_vote_hollande.csv")
p12$metropole <- nchar(p12$dept_code) < 3 & p12$dept_code != "99"
p12 <- group_by(p12, metropole, dept_name) %>%
summarise(
pc_fh_t1 = 100 * sum(t1fh) / sum(t1ex),