Skip to content

Instantly share code, notes, and snippets.

View chipoglesby's full-sized avatar
🏠
Working from home

Chip Oglesby chipoglesby

🏠
Working from home
View GitHub Profile
### plotTweets.r
### Plot out tweets
### Requires you have authenticated in auth.R and processed in tweetdata.R
### 15th June 2014
### Mark Edmondson @HoloMarkeD
###
library(ggplot2)
######################################################################
@MarkEdmondson1234
MarkEdmondson1234 / r-installation-debain-wheezy
Last active February 10, 2016 14:43
Installation of R, Rstudio, OpenCPU on GCE Debain Wheezy image, details on how to in the blogpost http://markedmondson.me/run-r-rstudio-and-opencpu-on-google-compute-engine-free-vm-image
### r-installation-debain-wheezy
#### setup commands to setup R, RStudio and OpenCPU on a Google Compute Engine Wheezy instance
#### Mark Edmondson 29 June 2014
##
## No original work, all taken from these sources:
## https://github.com/jeroenooms/opencpu-deb/blob/master/build-on-debian.md
## https://support.rstudio.com/hc/communities/public/questions/200651456-RStudio-server-not-installable-on-Debian-Wheezy-just-released-this-week-
## http://cran.r-project.org/bin/linux/debian/README.html
# need to be sudo for all below
@jennybc
jennybc / 2014-10-12_stop-working-directory-insanity.md
Last active August 7, 2025 01:00
Stop the working directory insanity

There are packages for this now!

2017-08-03: Since I wrote this in 2014, the universe, specifically Kirill Müller (https://github.com/krlmlr), has provided better solutions to this problem. I now recommend that you use one of these two packages:

  • rprojroot: This is the main package with functions to help you express paths in a way that will "just work" when developing interactively in an RStudio Project and when you render your file.
  • here: A lightweight wrapper around rprojroot that anticipates the most likely scenario: you want to write paths relative to the top-level directory, defined as an RStudio project or Git repo. TRY THIS FIRST.

I love these packages so much I wrote an ode to here.

I use these packages now instead of what I describe below. I'll leave this gist up for historical interest. 😆

@sckott
sckott / bitly_r.md
Last active August 29, 2015 14:07
Querying bitly from R

Querying bitly from R

library('httr')
btoken <- '<token>' # go to https://bitly.com/a/oauth_apps and generate token
args <- list(query='obama', domain='nytimes.com', limit=2, access_token = btoken)
req <- GET("https://api-ssl.bitly.com/v3/search", query=args) 
content(req)
@hrbrmstr
hrbrmstr / shinyapp.sh
Last active October 3, 2016 21:45
Small script to help in creating one-click R+Shiny apps on OS X
#!/bin/bash
#
# v1.0 - Initial release - @hrbrmstr
#
# Script to turn a R+Shiny gist into a one-click OS X application
#
# Just enter in the gist ID and the app name you want, optionally providing
# a custom icns file and also optionally code-signing the built app
#
# It does rudimentary checking to ensure the gist id is, in fact a Shiny app.
@briandconnelly
briandconnelly / setup_rstudio.sh
Last active April 13, 2021 21:46
Setup RStudio Server on a Google Compute Engine Instance (Debian)
#!/bin/bash
# Install RStudio Server on a Google Compute Engine instance running Debian
# Wheezy
CRAN_MIRROR='cran.rstudio.com'
pushd /tmp
# Install up-to-date version of R ---------------------------------------------
@arikfr
arikfr / fabfile.py
Last active February 19, 2021 10:03
re:dash fabfile
#!/usr/bin/env python
# vim: ts=4:sw=4:expandtab:autoindent:
import os
import sys
import requests
import filecmp
from fabric.context_managers import hide, settings, prefix
from fabric.api import sudo, task, run, cd, env
from fabric.contrib.console import confirm
from fabric.colors import green
### Function for generating the posterior of Robo's position ###
landscape <- c(rep("plain", 50), rep("mountain", 25), rep("forest", 45))
landscape_color <- c(mountain = "black", forest = "green", plain = "yellow")
cover_cost <- c(mountain = 10, forest = 5, plain = 1)
posterior_sample <- function(n) {
dist_i <- sample(3, n, replace = TRUE, c(18, 17, 65))
mu <- c(15, 40, 90)
function main() {
MccApp.accounts().withCondition("Cost > 1.00").forDateRange("YESTERDAY").withLimit(50).executeInParallel('runOnEachAccount', 'finished');
}
function runOnEachAccount() {
Logger.log('Starting on: '+AdWordsApp.currentAccount().getCustomerId());
var results = getAccountReport();
Logger.log(results);
return JSON.stringify(results);
}
@chipoglesby
chipoglesby / google_sheets.txt
Last active September 13, 2022 07:25
Common Google Spreadsheet Formulas
1. Identifying Cells by Type in Google Spreadsheets
=if(index(split(D1, "::"),1) = "mobileapp", "Mobile", "Website")
-------
2. Get the root domain url of a cell in Google Spreadsheets
For sites with one TLD or one TLD and one subdomain: ie: xx.com or xx.xx.com
=iferror(join(".", index(split(A2, "."),2),index(left(split(A2, "."),3),3)), join(".", index(split(A2, "."),1),index(left(split(A2, "."),3),2)))