Skip to content

Instantly share code, notes, and snippets.

@xvrdm
xvrdm / table.md
Last active January 28, 2019 10:10
Comparaison Table: fs / base / shell

dir_

fs base shell
dir_ls("/path") list.files("/path") ls /path
dir_info("/path") do.call(rbind, lapply(list.files("/path"), file.info)) ls -al /path
dir_copy("/path", "/new-path") dir.create("/new-path"); file.copy("/path", "/new-path", recursive=TRUE) cp /path /new-path
dir_create("/path") dir.create("/path") mkdir /path
dir_delete("/path") unlink("/path", recursive = TRUE) rm -rf /path
dir_exists("/path") dir.exists("/path") if [ -d "/path" ]; then ... ; fi
##################################################################
## Function ##
##################################################################
fish <- function(l, keys, .dflt = NULL, missing.rm = FALSE) {
if(!is.list(keys)) stop("The keys to search should be given as a list.")
modified_names <- names(keys) %||% rep("", length(keys)) %>%
str_replace("^$", as.character(NA))
library(tidycensus)
library(mapdeck)
library(tidyverse)
token <- "your mapbox token"
hv <- get_acs(geography = "tract",
variables = "B25077_001",
state = "CA",
geometry = TRUE) %>%
@xvrdm
xvrdm / useR2018.md
Created July 11, 2018 13:31 — forked from HanjoStudy/useR2018.md
useR2018 Material

I am looking forward to meeting you at the Tuesday AM (10th of July) tutorial session at useR2018!. We will be discussing a subject that I am very passionate about: Web Scraping!

The slides can be found here:

To ensure that we can be immediately productive on Tuesday morning, I would like you to get the following set up on your machines beforehand:

europe <- c("France", "United Kingdom", "Belgium", "Italy", "Spain",
"Luxembourg", "Ireland", "Netherlands", "Portugal", "Andorra",
"Denmark", "Sweden", "Finland","Germany", "Poland", "Greece",
"Macedonia", "Bosnia-Herzegovina", "Serbia", "Croatia", "Bulgaria",
"Romania", "Hungary", "Czech Republic", "Lithuania", "Estonia",
"Austria", "Slovakia", "Slovenia", "Albania", "Latvia", "Moldova",
"Switzerland", "Belarus")
readr::read_csv("~/Desktop/week13_alcohol_global.csv") %>%
dplyr::select(-total_litres_of_pure_alcohol, -spirit_servings) %>%
# Get Country 3 letters ISO code and correct the ones not mapping to FIFA data
iso_url <- "https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3"
iso_html <- xml2::read_html(iso_url)
iso_country <- iso_html %>%
rvest::html_table(fill=TRUE) %>%
.[2:4] %>%
dplyr::bind_rows() %>%
purrr::set_names(c("code","country")) %>%
dplyr::mutate(country=if_else(country=="Côte d'Ivoire",
"Ivory Coast", country),
@xvrdm
xvrdm / Emacs.md
Created April 10, 2018 14:10 — forked from redinger/Emacs.md
Setting up Emacs daemon on OS X

Setting up Emacs daemon on OS X

Tired of waiting for emacs to start on OS X? This step by step guide will teach you how to install the latest version of emacs and configure it to start in the background (daemon mode) and use emacsclient as your main editor.

Install Cocoa Emacs

Download the latest pretest version of [Emacs for Mac OS X]: http://emacsformacosx.com/builds

@xvrdm
xvrdm / init.lua
Last active September 28, 2022 08:54 — forked from alexander-clark/init.lua
Hammerspoon - switch Mac Input Source / keyboard layout on Kinesis Advantage connect / disconnect
usbWatcher = nil
function usbDeviceCallback(data)
if (data["productName"] == "Kinesis Keyboard Hub") then
if (data["eventType"] == "added") then
hs.keycodes.setLayout("U.S. International - PC")
elseif (data["eventType"] == "removed") then
hs.keycodes.setLayout("Swiss French")
end
end
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugin
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@xvrdm
xvrdm / osx-for-hackers.sh
Created April 29, 2016 09:15 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'