Skip to content

Instantly share code, notes, and snippets.

View ivyleavedtoadflax's full-sized avatar
🥘

Matt Upson ivyleavedtoadflax

🥘
View GitHub Profile
@ivyleavedtoadflax
ivyleavedtoadflax / .zshrc
Last active December 22, 2016 16:03
Zsh config file (includes fix for vim colours)
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/matthewupson/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
@ivyleavedtoadflax
ivyleavedtoadflax / eesectors.yml
Created February 13, 2017 14:24
tmuxinator config for eesectors project
# ~/.tmuxinator/eesectors.yml
name: eesectors
root: ~/Remote_documents/eesectors/
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start
@ivyleavedtoadflax
ivyleavedtoadflax / priority.sql
Created April 19, 2017 12:07
Alternative priority using string_agg instead of array_agg.
/*
---
name: Priority View
filename: priority.sql
logic:
- Join the classfied with the raw table and count total of each code
applied to each survey (respondent_id) to give the codes_join cte.
- Calculate the total number of codes applied to each survey to give
total_codes cte.
- Join these two ctes and calculate the ratio codes applied:
@ivyleavedtoadflax
ivyleavedtoadflax / methods.py
Created July 25, 2017 23:50
Different types of python method
class Date(object):
def __init__(self, day=0, month=0, year=0):
self.day = day
self.month = month
self.year = year
def print(self):
return self.day, self.month, self.year
@ivyleavedtoadflax
ivyleavedtoadflax / xml2-fix.md
Last active September 11, 2017 12:22
What to do when installing R package xml2 fails on OS X El Capitan
  • Download the latest binary of the xml2 package from here: https://cran.r-project.org/web/packages/xml2/index.html, you want: OS X El Capitan binaries: r-release: xml2_1.1.1.tgz (or similar).
  • Extract to a local dir with tar -xvf xml2_1.1.1.tgz.
  • Find where libxml2 is installed (or install with brew install libxml2), mine is /usr/local/Cellar/libxml2/2.9.4_3.
  • Set environment variable export LIBXML_INCDIR=/usr/local/Cellar/libxml2/2.9.5 using the path from above.
  • Install to the appropriate library: R CMD INSTALL -l ~/Documents/OMSQ_RAP/packrat/lib/x86_64-apple-darwin15.6.0/3.4.1/ .. Note that this installs into a packrat library, if you just want a system install do: R CMD INSTALL .

et voila!

UPDATE: This works for installing xml2, but it doesn't seem to work as a dependency for other packages that require it.

Keybase proof

I hereby claim:

  • I am ivyleavedtoadflax on github.
  • I am mattupson (https://keybase.io/mattupson) on keybase.
  • I have a public key ASCaaJ_dwu6Lb-DvQqk-EtxJv4TfHgD1ETYiE0XhpydneQo

To claim this, I am signing this object:

extract_GVA <- function(x) {
df <- data.frame(col1 = x)
if (!identical(1:5, df$col1)) stop("GVA data not 1 to 5")
structure(
df,
class = c("GVA", "data.frame"))
}
GVA <- extract_GVA(1:4) #throws error if data incorrect
GVA <- extract_GVA(1:5) #creates dataframe with GVA class that appears in
@ivyleavedtoadflax
ivyleavedtoadflax / pyenv.md
Last active November 21, 2017 17:05
How to use pyenv with virtualenvwrapper

Using pyenv with virtualenvwrapper

  • pyenv is used to manage which version of python you are using
  • virtualenv is used to manage python dependencies

They can interact nicely together if you do the following:

Install the required packages (this assumes that you have virtualenv and virtualenvwrapper installed).

Install pyenv and pyenv-virtualenvwrapper

---
title: "Xtable examples"
subtitle: "From [this thread](http://stackoverflow.com/questions/32005471/simple-example-of-using-tables-knitr-for-latex)"
author: "Matthew Upson"
date: "15 August 2015"
output: pdf_document
---
```{r}
library("xtable")
@ivyleavedtoadflax
ivyleavedtoadflax / ping-csv.sh
Created February 22, 2018 15:31 — forked from dansimau/ping-csv.sh
Ping a host and output each reply in CSV format
#!/bin/bash
#
# Do a ping and output results as CSV.
#
# dsimmons@squiz.co.uk
# 2011-12-23
#
if [ $# -lt 1 ]; then
echo "Usage: $0 [--add-timestamp] <ping host>"