Skip to content

Instantly share code, notes, and snippets.

View ivyleavedtoadflax's full-sized avatar
🥘

Matt Upson ivyleavedtoadflax

🥘
View GitHub Profile
@ivyleavedtoadflax
ivyleavedtoadflax / bash_file_iterate.sh
Created August 6, 2019 15:19
Iterate through a bash file and do some things
for i in raw/*.json;
do
# Create new filename
filename=$(basename -- "$i")
extension="${filename##*.}"
filename="${filename%.*}"
new_filename=processed/refs_${filename}.txt
@ivyleavedtoadflax
ivyleavedtoadflax / spacy_doc_vectors.py
Last active July 7, 2019 10:35
Get document vectors from spacy
# Need to run:
# python -m spacy download en
# from console first to get the model
import spacy
import pandas as pd
nlp = spacy.load("en")
@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 / customer_tokenizer.py
Last active November 9, 2018 13:28
Custom date tokenizer
from spacy.util import (compile_prefix_regex, compile_infix_regex, compile_suffix_regex)
def _custom_tokenizer(self, nlp, regex=[r"[-/,.\n\s]"]):
"""Custom tokenizer to split date formats like 05-05-2015
and 05/05/2015
"""
# Use the default prefixes and suffixes
prefix_re = compile_prefix_regex(nlp.Defaults.prefixes)
suffix_re = compile_suffix_regex(nlp.Defaults.suffixes)
@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>"
---
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 / 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: