Skip to content

Instantly share code, notes, and snippets.

View cderv's full-sized avatar

Christophe Dervieux cderv

View GitHub Profile
@potterzot
potterzot / Makefile
Last active October 10, 2017 18:11
Using Make to compile multiple Rmd files in a directory
# This lets you type `make`
# and will pandoc all *.Rmd files in the letters directory
# into pdfs stored in the output directory
all: readme letters
#generate all letters
SRC=$(wildcard letters/*.Rmd)
OUT=$(patsubst letters/%.Rmd, output/%.pdf, $(SRC))
letters: $(OUT)
# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
# Originally seen at http://spatial.ly/2014/08/population-lines/
# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,
# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after
# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.
# The result of the code below can be seen at http://imgur.com/ob8c8ph
library(tidyverse)
@MilesMcBain
MilesMcBain / r_devlibs.sh
Last active August 6, 2017 13:14
Install dev libs to install tidyverse on Ubuntu
#!/bin/bash
sudo apt-get update
sudo apt-get install \
libxml2-dev \
libsqlite-dev \
libcurl4-openssl-dev \
libssl-dev \
libmagick++-dev
@hadley
hadley / shiny-oauth.r
Last active November 2, 2024 01:26
Sketch of shiny + oauth
library(shiny)
library(httr)
# OAuth setup --------------------------------------------------------
# Most OAuth applications require that you redirect to a fixed and known
# set of URLs. Many only allow you to redirect to a single URL: if this
# is the case for, you'll need to create an app for testing with a localhost
# url, and an app for your deployed app.
@brookinc
brookinc / stashstaged.sh
Last active November 23, 2021 09:34
A script to `git stash` only the currently staged changes.
#!/usr/bin/env bash
# This script stashes the currently staged changes, and leaves everything else in the working directory as-is.
# (source: https://stackoverflow.com/questions/14759748/stashing-only-staged-changes-in-git-is-it-possible/39644782#39644782)
# Prompt for the desired repo path
REPOPATH=
read -p "Enter the repo path, or press ENTER for current dir: " REPOPATH
# Read the desired stash description from the command line, or prompt the user for it if necessary
library(rvest)
library(ore)
library(tidyverse)
library(jericho)
options("HTTPUserAgent"="hrbrbot")
pg <- read_html("https://help.github.com/")
html_nodes(pg, "a") %>%
library(DBI)
library(dplyr)
library(pool)
pool <- dbPool(drv = RPostgres::Postgres(),
dbname = "rstudioconftweets",
host = "rstudioconf-tweets.c0azx4micevq.us-east-1.rds.amazonaws.com",
user = "guest",
password = "guest",
port = 5432)
#!/bin/bash
TODAY=`date +%Y-%m-%d`
TODAY_MD=`date +%B\ %d,\ %Y`
YEAR=`date +%Y`
PACKAGENAME=$1
##
## CHANGE ME!!!
@sadatnfs
sadatnfs / xarray_to_r.r
Last active January 6, 2023 10:49
Extracting an xarray based netcdf file to use in R
require(ncdf4)
require(ncdf4.helpers)
require(data.table)
## Get the name of the value vars in the nc file
get_nc_value_name <- function(nc_file) {
## Get names
nc_obj <- nc_open(nc_file)
name<-names(nc_obj$var)
# This example demonstrates running furrr code distributed on 2 AWS instances ("nodes").
# The instances have already been created.
library(future)
library(furrr)
# Two t2.micro AWS instances
# Created from http://www.louisaslett.com/RStudio_AMI/
public_ip <- c("34.205.155.182", "34.201.26.217")