View reshape_world-bank_data.do
/* This file reshapes world bank data that has been downloaded into stata using the wbopendata command. */
/* It will reshape from wide to long format that can be used in panel data models */
/* First read the file into Stata, e.g: */
/* (replace this command if necessary) */
/* wbopendata, topics(2 - Aid Effectiveness) clear */
use
/* and then, issue the following commands */
drop indicatorcode /* replace this with the name of the appropriate variable */
View csv_load_db.pl
#!/usr/bin/perl
use DBI;
#example running
#csv_load_db.pl Changed.csv pat_regan_combined create_table.sql
$host="localhost";
$port=5433;
$db="geopolitical";
View reshape_freedom-house_data.R
# convert wide-form Freedom House Good Governance data to long-form
# Read the data
wide <- read.csv("freedom_house_good_governance.csv")
# Get the columns corresponding to each wide-form variable that will be converted to long form.
PRvars <- names(wide)[(1:40)*3-1]
CLvars <- names(wide)[(1:40)*3]
Statusvars <- names(wide)[(1:40)*3+1]
# Get the times associated with the wide-form variables
View check_csv.awk
#!/usr/bin/awk -f
BEGIN {FS=","}
$1 !~ /^[0-9]+$/ {print "Line "NR": Field 1 invalid"}
$2 !~ /^"?[a-zA-Z][^,]+"?$/ {print "Line "NR": Field 2 invalid"}
$3 !~ /^[0-9.]+$/ {print "Line "NR": Field 3 invalid"}
$4 !~ /[0-9]+/ {print "Line "NR": Field 4 invalid"}
$5 !~ /[0-9](\.[0-9])? - [0-9](\.[0-9])?/ {print "Line "NR": Field 5 invalid"}
/^$/ { print "Line "NR" is empty" }
View geocode_examples.R
# Some examples of how to use geocode data of different formats.
## load libraries
library("magrittr")
library("eurostat")
library("eurostat")
library("ggplot2")
library("countrycode")
library("rgdal")
library("colorbrewer")
## plotting NUTS shape files
View eurovision_voting_analysis.R
## Analysis of voting patterns for 2016 Eurovision song contest
library(clusterfly)
library(igraph)
library(magrittr)
## load the voting data
votedata <- read.csv("eurovision-votes_2016.csv")
## remove total votes column
votedata$total_votes <- NULL
View extract_law-enforcement_data.el
;; This file contains an example of how to extract data from pdf files using `extract-text-from-files'
;; It extracts state-by-state data on total number of law enforcement employees from pdf files
;; downloaded from the FBI website.
;; There is a lot more data available in these files, but I only need total employees for now.
;; PDF files must first be downloaded from these URLs:
;; https://www.fbi.gov/about-us/cjis/ucr/crime-in-the-u.s/1995/95sec6.pdf
;; https://www.fbi.gov/about-us/cjis/ucr/crime-in-the-u.s/1996/96sec6.pdf
;; https://www.fbi.gov/about-us/cjis/ucr/crime-in-the-u.s/1997/97sec6.pdf
View reshape_UK_crime_data.awk
#!/usr/bin/awk -f
# Create variables containing counts of the number of different incident types within each area,
# where an area is defined as a unique longitude/latitude pair to the nearest 2 decimal places
BEGIN {
# Define csv fields
FPAT="\"[^\"]*\"|[^\",]*";
PROCINFO["sorted_in"] = "@ind_str_asc";
}
View stubby.conf
# stubby - a local DNS Privacy stub resolver
#
# stubby acts as a local DNS Privacy stub resolver, using DNS-over-TLS.
# Stubby encrypts DNS queries sent from the local machine to a DNS Privacy resolver, increasing end user privacy.
#
description "stubby server"
start on runlevel [2345]
stop on runlevel [!2345]
View gist:5823399
(defun mapcar@ (fun seq)
(let (result)
(loop for elem in (reverse seq)
for newelem = (funcall fun elem)
if (and (listp newelem)
(eq (car newelem) '@))
do (loop for newelem2 in (cdr newelem)
do (setq result (cons newelem2 result)))
else do (setq result (cons newelem result)))
result))