Skip to content

Instantly share code, notes, and snippets.

@IanHopkinson
IanHopkinson / tests.py
Created November 20, 2020 13:47
A gist illustrating testing in Python using unittest
#!/usr/bin/env python
# encoding: utf-8
"""
Some exercising of Python test functionality based on:
https://docs.python.org/3/library/doctest.html
https://docs.python.org/3/library/unittest.html
Generating tests dynamically with unittest
@IanHopkinson
IanHopkinson / csvconcat.py
Created July 14, 2019 13:06
csv concatenation
import csv
mydir = "C:/Users/Nessa/Documents/Work/Coding/Test"
os.chdir(mydir)
all_filenames = [i for i in glob.glob("*.{}".format("csv"))]
all_data = []
for f in all_filenames:
@IanHopkinson
IanHopkinson / start.sh
Created March 21, 2016 15:29
Modified start.sh for Docker Toolbox.
#!/bin/bash
trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong... Press any key to continue..."' EXIT
VM=default
#DOCKER_MACHINE=./docker-machine.exe
DOCKER_MACHINE=/c/Program\ Files/Docker\ Toolbox/docker-machine.exe
if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then
VBOXMANAGE="${VBOX_MSI_INSTALL_PATH}VBoxManage.exe"
@IanHopkinson
IanHopkinson / lxml_examples.py
Created November 24, 2015 19:42
Examples of xpath queries using lxml in python
#!/usr/bin/env python
# encoding: utf-8
import lxml.etree
import lxml.html
import requests
xml_sample = """<?xml version="1.0" encoding="UTF-8"?>
<foo:Results xmlns:foo="http://www.foo.com" xmlns="http://www.bah.com">
<foo:Recordset setCount="2">
@IanHopkinson
IanHopkinson / README.md
Created September 18, 2015 13:11
fresh block

hello markdown

@IanHopkinson
IanHopkinson / 0_reuse_code.js
Created July 17, 2014 13:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@IanHopkinson
IanHopkinson / get_people
Created June 6, 2014 08:40
Get people appearing with a list of people from NewsReader
#!/usr/bin/env python
# encoding: utf-8
from __future__ import unicode_literals
import json
import requests
import scraperwiki
from collections import OrderedDict
@IanHopkinson
IanHopkinson / get_timeline
Created June 6, 2014 08:39
Get a timeline from the NewsReader API
#!/usr/bin/env python
# encoding: utf-8
from __future__ import unicode_literals
import json
import requests
import scraperwiki
from collections import OrderedDict
@IanHopkinson
IanHopkinson / pandas_finance.py
Created April 8, 2014 08:04
Get Yahoo!Finance data on ScraperWiki
#!/usr/bin/env python
"""
Save stock ticker data from Yahoo! Finance to sqlite.
"""
import datetime as d
import sqlite3
import pandas.io.data as web
import pandas.io.sql as sql
@IanHopkinson
IanHopkinson / view-source.R
Last active December 21, 2015 09:09
R used to generate views of ScraperWiki's Twitter Search tool
#!/usr/bin/Rscript
# Script to create r-view 2013-08-14
# Ian Hopkinson
source('scraperwiki_utils.R')
NumberOfTweets<-function(){
query = 'select count(*) from tweets'
number = ScraperWikiSQL(query)
return(number)