Skip to content

Instantly share code, notes, and snippets.

View sboysel's full-sized avatar

Sam Boysel sboysel

View GitHub Profile
@jennybc
jennybc / 2014-10-12_stop-working-directory-insanity.md
Last active September 23, 2022 04:43
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. 😆

@cheerfulstoic
cheerfulstoic / gist:7e8ec61f9104017430af
Last active April 12, 2022 18:36
Examining what is possible for StackOverflow with a graph database

Analyzing StackOverflow with Neo4j and Clojure

Joining multiple disparate data-sources, commonly dubbed Master-Data-Management (MDM), is usually not a fun exercise. I would like to show you how using a graph database (Neo4j) and an interesting dataset (developer-oriented collaboration sites) to put the fun back into MDM. This approach will allow you to quickly and sensibly merge data from different sources into a consistent picture and query across the data efficiently to answer your most pressing questions.

You can read the associated blog posts on my blog. The blog posts cover the hows and whys of the project, while this and other GraphGists will examine how to answer specific questions of the data.

@jexp
jexp / bulk-neo4j-import-original.sh
Last active May 10, 2021 20:29
Panama Papers Import Scripts for Neo4j
export NEO4J_HOME=${NEO4J_HOME-~/Downloads/neo4j-community-3.0.1}
if [ ! -f data-csv.zip ]; then
curl -OL https://cloudfront-files-1.publicintegrity.org/offshoreleaks/data-csv.zip
fi
export DATA=${PWD}/import
rm -rf $DATA
@dannguyen
dannguyen / csvkit-sql-cli-readme.md
Last active May 8, 2020 04:32
Using bash, csvkit, and SQLite to analyze San Francisco restaurant health inspection data

How to download, import, and analyze San Francisco restaurant inspection data using SQLite3 and csvkit from the command-line.

A quick example of doing data wrangling from the command-line, as well as getting to know one of San Francisco's data sets: the San Francisco restaurant inspections, courtesy of the SF Department of Public Health. I don't normally do database work from the command-line, but importing bulk data into SQLite is pretty frustrating using the available GUIs or just the shell.

So thank goodness for Christopher Groskopf's csvkit, a suite of Unix-like tools that use Python to robustly handle CSV files. There's a lot of great tools in csvkit, but for this gist, I just use csvsql, which can parse a CSV and turn it into properly-flavored SQL to pass directly into your database app of choice.

@etcwilde
etcwilde / ght-restore-psql
Last active September 3, 2019 19:26
Restore the GHTorrent database to postgres instead of mysql (based on mysql-2017-01-19 image)
#!/usr/bin/env bash
# Evan Wilde <etcwilde@uvic.ca>
# July 20, 2017
# defaults
user="postgres"
passwd=""
host="localhost"
db="ghtorrent"
tmpdir='/tmp'
@hrbrmstr
hrbrmstr / themes.R
Last active April 16, 2018 19:48
various themes
theme_map <- function(base_size=9, base_family="") {
require(grid)
theme_bw(base_size=base_size, base_family=base_family) %+replace%
theme(
axis.line=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank(),
axis.title=element_blank(),
panel.background=element_blank(),
panel.border=element_blank(),
@dholstius
dholstius / rgdal-install-with_homebrew.R
Last active April 13, 2018 19:44
rgdal installation on OS X
install_from_source <- function (pkg, args = NULL, repos = "http://cran.rstudio.com", overwrite = FALSE, ...) {
if (!overwrite) {
if (pkg %in% installed.packages()) {
message(pkg, " is already installed")
return()
}
}
install.packages(
@leeper
leeper / gender.R
Last active October 11, 2017 18:37
Gender API Example https://gender-api.com/en/
#' Gets gender by name or email address, optionally by country or IP address.
library("httr")
library("XML")
#' @import httr
#' @import rjson
#' @param name A character string containing a first name, or a character vector containing first names. One must specify name or email.
#' @param email A character string containing an email address with a first name. One must specify name or email.
#' @param country An optional character string containing a two-letter country name, as listed here: https://gender-api.com/en/api-docs