Skip to content

Instantly share code, notes, and snippets.

@cattleguard
cattleguard / gist:40699d08b524a0eaac71
Last active August 29, 2015 14:26
Reproducible Research with RSelenium
Anthony Towry

You want to get users of your R script as close to the data used for analysis as you can, but download.file() isn't going to cut it. There's no obvious direct link to the CSV and what you're left with is an anchor tag backed by a javascript function.

So, we need to click this element to initiate a download.

Enter RSelenium, an R package that interfaces with the browser driving selenium.

First, get curl and java.

@cattleguard
cattleguard / NES_feeling_lucky.sh
Created April 22, 2016 21:35
Adds a game to your retropie NES called 'Feeling Lucky' which launches a random game from your collection.
#!/bin/bash
# Description:
# Adds a game to your retropie NES called 'Feeling Lucky' which launches a random game from your collection
# INSTALL: Point your nes launcher in /etc/emulationstation/es_systems.cfg
# to this script. (e.g. /home/pi/NES_feeling_lucky.sh %ROM%)
flag="$HOME/RetroPie/roms/nes/Feeling Lucky.nes"
@cattleguard
cattleguard / lognormal_hhs_hacking_incidents.R
Created May 26, 2016 05:31
Using poweRlaw package to test power law against HHS Hacking/IT Incidents Individuals Affected
library(poweRlaw)
# csv is just a dump from the breach website with a filter applied for Hacking/IT Incidents and the date range.
hhs.data <- read.csv("~/Downloads/hhs_hacking_01012010thru12312015.csv", header = T, stringsAsFactors = FALSE)
hhs.data <- hhs.data[!is.na(hhs.data$Individuals.Affected),]
hhs.data$Date.Submitted <- strptime(hhs.data$Breach.Submission.Date, "%m/%d/%Y")
hhs.data <- subset(hhs.data, Date.Submitted > "2010-01-01" & Date.Submitted < "2015-01-01")
m <- displ$new(hhs.data$Individuals.Affected)
m$setXmin(estimate_xmin(m))
m$setPars(estimate_pars(m))
library(rvest)
winners <- read_html("https://www.bigtexan.com/72oz-hall-fame/")
count <- winners %>%
html_nodes(xpath = '//*[@id="post-371"]/div/div[3]/div/div/div/table/tbody//tr/td[1]') %>%
html_text()
date <- winners %>%
html_nodes(xpath = '//*[@id="post-371"]/div/div[3]/div/div/div/table/tbody//tr/td[2]') %>%
library(gsubfn)
library(magrittr)
big.texan.recordbook <- read.csv("/bigtexan.csv", stringsAsFactors = FALSE)
# Fixing dates that arent't.
# > grep("[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,2}", big.texan.recordbook$date, value = TRUE, invert = TRUE)
# [1] "*1965" "*1966" "*1968" "*1972" "*1972" "1/??/98" "8/??/2004"
# [8] "4/?/10" "101 4/5" " " "7/210/15" " "
@cattleguard
cattleguard / pod_speeder.rb
Created January 3, 2018 01:11
script leverages sox (Sound eXchange) to speed up most podcasts in itunes directory
#!/usr/local/bin/ruby
# Must have ruby later ruby to use Dir.children()
require 'date'
require 'shellwords'
origin_folder = '~/Music/iTunes/iTunes Media/Podcasts/'
Dir.chdir(File.expand_path(origin_folder))
contents = Dir.glob('*')
contents.each {|folder|
@cattleguard
cattleguard / Conferences by Speaker Support.md
Last active June 21, 2018 02:45
Just a place to keep notes on CFPs
@cattleguard
cattleguard / auto_git_query
Created September 2, 2019 18:47 — forked from nullenc0de/auto_git_query
Automated Github Queries (Can open 29 tabs at a time)
https://github.com/search?q=BROWSER_STACK_ACCESS_KEY= OR BROWSER_STACK_USERNAME= OR browserConnectionEnabled= OR BROWSERSTACK_ACCESS_KEY=&s=indexed&type=Code
https://github.com/search?q=CHROME_CLIENT_SECRET= OR CHROME_EXTENSION_ID= OR CHROME_REFRESH_TOKEN= OR CI_DEPLOY_PASSWORD= OR CI_DEPLOY_USER=&s=indexed&type=Code
https://github.com/search?q=CLOUDAMQP_URL= OR CLOUDANT_APPLIANCE_DATABASE= OR CLOUDANT_ARCHIVED_DATABASE= OR CLOUDANT_AUDITED_DATABASE=&s=indexed&type=Code
https://github.com/search?q=CLOUDANT_ORDER_DATABASE= OR CLOUDANT_PARSED_DATABASE= OR CLOUDANT_PASSWORD= OR CLOUDANT_PROCESSED_DATABASE=&s=indexed&type=Code
https://github.com/search?q=CONTENTFUL_PHP_MANAGEMENT_TEST_TOKEN= OR CONTENTFUL_TEST_ORG_CMA_TOKEN= OR CONTENTFUL_V2_ACCESS_TOKEN=&s=indexed&type=Code
https://github.com/search?q=-DSELION_BROWSER_RUN_HEADLESS= OR -DSELION_DOWNLOAD_DEPENDENCIES= OR -DSELION_SELENIUM_RUN_LOCALLY=&s=indexed&type=Code
https://github.com/search?q=ELASTICSEARCH_PASSWORD= OR ELASTICSEARCH_USERNAME= OR EMAIL_NOTIFI