Skip to content

Instantly share code, notes, and snippets.

View AABoyles's full-sized avatar

Tony Boyles AABoyles

View GitHub Profile
@AABoyles
AABoyles / rep.js
Created September 5, 2014 20:01
An implementation of R's rep function for Javascript Arrays
Array.prototype.repeat = function(times, each) {
if(!times){return this;}
if(!each){each=1;}
var that = this;
var temp=Array(each*this.length);
this.forEach(function(el, i){
for(j = 0; j < each; j++){
temp[i * each + j] = el;
}
});
@AABoyles
AABoyles / FunkyStats.js
Created August 27, 2014 20:54
FunkyStats
function htmlreplace(element){
var nodes=element.childNodes;
for(var n=0;n<nodes.length;n++){
if(nodes[n].nodeType==3){
var r=new RegExp('[pP][^A-Za-z0-9]+[vV]alue', 'gi');
if(nodes[n].textContent){
nodes[n].nodeValue=nodes[n].textContent.replace(r,'P. Funk');
}else{
nodes[n].nodeValue=nodes[n].nodeValue.replace(r,'P. Funk');
}
@AABoyles
AABoyles / GDELTAccessor.R
Last active August 29, 2015 14:05
Query GDELT using Google BigQuery
library(devtools)
devtools::install_github("dplyr")
library(dplyr)
devtools::install_github("bigrquery")
library(bigrquery)
billingID <- "Insert Your Project's Billing ID Here"
gdelt <- src_bigquery(billingID, "GDELT")
events <- tbl(gdelt, "events")
@AABoyles
AABoyles / booze.csv
Last active August 29, 2015 14:02
buzzPerBuck
desc brand size proof price alcohol_ml shot_equiv cents_per_shot display_vol abv bpd
BEER Lionshead Pilsner 58673.8 9 84.99 2640 155.2941176 57.10376125 1/2 Keg 4.5 1.751264854
BEER Pabst 58673.8 9 89.99 2640 155.2941176 60.46320125 1/2 Keg 4.5 1.653961552
BEER Budweiser 58673.8 9 99.99 2640 155.2941176 67.18208125 1/2 Keg 4.5 1.488548854
BEER Bud Light 58673.8 8.4 99.99 2464 144.9411765 71.98080135 1/2 Keg 4.2 1.389338934
BEER Miller Lite 58673.8 8.4 99.99 2464 144.9411765 71.98080135 1/2 Keg 4.2 1.389338934
BEER Coors Light 58673.8 8.4 99.99 2464 144.9411765 71.98080135 1/2 Keg 4.2 1.389338934
BEER Yuengling Traditional Lager 58673.8 9 124.99 2640 155.2941176 83.9792813 1/2 Keg 4.5 1.190815266
BEER Michelob Ultra 58673.8 8.4 129.99 2464 144.9411765 93.5772014 1/2 Keg 4.2 1.068697592
BEER Yuengling Traditional Lager 29336.9 9 66.99 1320 77.64705882 90.0192476 1/4 Keg 4.5 1.110912076
@AABoyles
AABoyles / pdf2txt.py
Created May 16, 2014 18:40
pdf2txt.py - Requires the Slate Library (https://github.com/timClicks/slate)
import glob, slate
for filename in glob.glob( '*.pdf' ):
with open(filename) as f:
doc = slate.PDF(f)
fileout = open(filename.rstrip('.pdf')+'.txt', 'w+')
fileout.writelines(doc)
@AABoyles
AABoyles / animatedheaRt.R
Last active August 29, 2015 13:56 — forked from jknowles/animatedheaRt
Animated Beating Heart in R
############################################################
## Title: Animated Beating Heart in R
## Author: Jared Knowles
## Forked: Tony Boyles
## Date: February 14, 2014
############################################################
library(animation)
library(ggplot2)
@AABoyles
AABoyles / console.php
Last active January 2, 2016 18:19
An itty-bitty (buggy) Oracle DB Console written in PHP. For the love of god, don't put this on any production environment.
<?php
//console.php
// An itty-bitty Oracle DB Console written in PHP.
// Copyright 2014 By [Tony Boyles]<AABoyles@gmail.com> (http://aaboyles.com)
// Licensed under the GPL v3 or later.
//Edit these Credentials to match your Oracle Database's
$dbuser = '';
$dbpass = '';
$dbhost = '127.0.0.1';
@AABoyles
AABoyles / table2CSV.js
Last active December 27, 2015 12:29
*Don't use this Gist!* If you're looking to work with CSVs in Javascript, give [Tabular.js](http://aaboyles.com/Tabular.js/) a try. It was designed after this gist to provide a more complete solution to CSV handling in Javascript. Given a table element (or jQuery-selected table), returns a string which can be used as download URL for the table i…
function table2CSV(table, delim){
var csv = "data:application/csv;charset=utf-8,";
if(table instanceof HTMLElement){
table = $(table);
}
if(table instanceof jQuery){
var regex = /,/g;
if(delim){
regex = new RegExp(delim, 'g');
delim = encodeURIComponent(delim);
@AABoyles
AABoyles / jquery.spin.js
Last active December 16, 2015 07:29 — forked from tsgautier/jquery.spin.js
A simpler, slightly more efficient, less customizable jQuery Spinner plugin.
/*
You can create a spinner using either of the variants below:
$("#el").spin(true); //Starts the spinner.
$("#el").spin(false); // Kills the spinner.
*/
(function($) {
$.fn.spin = function(opts) {
@AABoyles
AABoyles / getFSI.R
Created March 18, 2013 20:34
Read the Entire History of the Failed States Index into an R Data Frame
require(RCurl)
gDocs <- "https://docs.google.com/spreadsheet/pub?key=0AuRPH1hRlnZhdEhtbGtZWTRybThvNXBLZW15Vk1Lenc&single=true&gid=0&output=csv"
txCon <- textConnection(getURL(gDocs))
FSI <- read.csv(txCon)