Skip to content

Instantly share code, notes, and snippets.

View AABoyles's full-sized avatar

Tony Boyles AABoyles

View GitHub Profile
@AABoyles
AABoyles / creds.R
Created April 13, 2015 18:23
Credentials to connect to postgresql
library("RPostgreSQL")
con <- dbConnect(dbDriver("PostgreSQL"),
host="your database's host",
port="5432",
user="your database's username",
password="your database's password",
dbname="your database's name")
@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 / Resume.md
Created October 15, 2015 17:04
My Resume. In Markdown.

Anthony A. Boyles

Contact

Anthony@Boyles.cc (617) 935-5515 AABoyles.com

Work Experience

@AABoyles
AABoyles / ocr.sh
Created October 23, 2015 19:49
Run this, select a screen region with some un-copyable text, and paste it like normal text.
#!/bin/bash
# Dependencies: tesseract-ocr imagemagick scrot xsel
SCR_IMG=`mktemp`
trap "rm $SCR_IMG*" EXIT
scrot -s $SCR_IMG.png
mogrify -modulate 100,0 -resize 400% $SCR_IMG.png #should increase detection rate
tesseract $SCR_IMG.png $SCR_IMG &> /dev/null
cat $SCR_IMG.txt | xsel -bi
@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) {