Skip to content

Instantly share code, notes, and snippets.

View ivyleavedtoadflax's full-sized avatar
🥘

Matt Upson ivyleavedtoadflax

🥘
View GitHub Profile
@ivyleavedtoadflax
ivyleavedtoadflax / init.vim
Last active April 4, 2020 23:25
NeoVim config
call plug#begin('~/.vim/plugged')
Plug 'Valloric/YouCompleteMe'
Plug 'jreybert/vimagit'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-unimpaired'
Plug 'w0rp/ale'
Plug 'tpope/vim-sensible'
Plug 'dracula/vim'
@ivyleavedtoadflax
ivyleavedtoadflax / aws_comprehend.py
Created May 2, 2018 16:01
AWS Comprehend example
# coding: utf-8
# In[5]:
import boto3
import os
@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>"
@ivyleavedtoadflax
ivyleavedtoadflax / .zshrc
Last active March 3, 2019 18:15
Ubuntu .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Add $HOME/bin to PATH for use with YouCompleteMe
# https://github.com/zchee/deoplete-jedi/wiki/Setting-up-Python-for-Neovim
export PATH=$PATH:$HOME/bin
export PATH=$PATH:$HOME/.local/bin
# Path to your oh-my-zsh installation.
@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

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

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:

@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.

@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 / 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: