Skip to content

Instantly share code, notes, and snippets.

View AABoyles's full-sized avatar

Tony Boyles AABoyles

View GitHub Profile
@AABoyles
AABoyles / laggr.R
Last active September 25, 2015 04:08
Returns a Vector x lagged by y steps
laggr <- function(x,y){return(c(rep(NA, y),x[-((length(x)-y+1):length(x))]))}
@AABoyles
AABoyles / Stata2CSV.R
Created June 3, 2011 21:20
Converts a Stata .DTA file to a Comma-separated variable file
library(foreign)
write.table(read.dta(file.choose()), file="output.csv", quote = FALSE, sep = ",")
@AABoyles
AABoyles / RPolityHeatmap.R
Created October 3, 2012 05:08
R Script to create an Animated Gif of Polity Heatmap
## 213 YEARS OF POLITICAL EVOLUTION IN 60 SECONDS v4
# Created:
## Jay Ulfelder
## October 1, 2012
# Modified:
## Tony Boyles[AABoyles@gmail.com]
## March 20, 2014
@AABoyles
AABoyles / makeExt.php
Created October 4, 2012 16:02
Quick-creator for MediaWiki Extensions. Creates a project directory, main file, body file, and internationalization file, all adhering to the standards of extension design described in http://www.mediawiki.org/wiki/Manual:Developing_extensions
<?php
class makeExt{
protected $project = "<project>";
protected $name = "<you>";
protected $desc = "<insert a short description here>";
public function __construct(){
global $argv, $argc;
@AABoyles
AABoyles / html2txt.py
Created October 5, 2012 20:54
Turn HTML files into text files
import nltk, glob
for filename in glob.glob( '*.htm*' ):
filein = open(filename)
html = filein.read()
raw = nltk.clean_html(html)
fileout = open(filename.rstrip('.html')+'.txt', 'w+')
fileout.write(raw)
@AABoyles
AABoyles / getPackage.R
Last active December 11, 2015 07:29
A simple, reliable, string-based package loader for packages on CRAN.
getPackage <- function(pkg){
if(!require(pkg, character.only=TRUE)){
install.packages(pkg, dependencies=TRUE)
library(pkg, character.only=TRUE)
}
return(TRUE)
}
getPackages <- function(pkgs){
for (pkg in pkgs){
@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)
@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 / 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 / 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';