Skip to content

Instantly share code, notes, and snippets.

View cderv's full-sized avatar

Christophe Dervieux cderv

View GitHub Profile
snippet module
${1:name}UI <- function(id){
ns <- NS(id)
tagList(
)
}
${1:name} <- function(input, output, session){
#devtools::install_github("cloudyr/aws.ec2")
# devtools::install_github("cloudyr/aws.ec2", ref = devtools::github_pull(38))
# ^ Must actually install PR 38. Some broken code in the main repo
#devtools::install_github("cloudyr/aws.signature")
library(aws.signature)
library(aws.ec2)
library(furrr)
aws.signature::use_credentials()
# 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")
@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)
#!/bin/bash
TODAY=`date +%Y-%m-%d`
TODAY_MD=`date +%B\ %d,\ %Y`
YEAR=`date +%Y`
PACKAGENAME=$1
##
## CHANGE ME!!!
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)
library(rvest)
library(ore)
library(tidyverse)
library(jericho)
options("HTTPUserAgent"="hrbrbot")
pg <- read_html("https://help.github.com/")
html_nodes(pg, "a") %>%
@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
@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.
@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