Skip to content

Instantly share code, notes, and snippets.

View psychemedia's full-sized avatar

Tony Hirst psychemedia

View GitHub Profile
@psychemedia
psychemedia / natural_language_time_periods.py
Last active October 10, 2022 07:13
Simple python functions to give dates and date ranges in "natural time"; this week, next month, etc.
import datetime
from dateutil.relativedelta import relativedelta
def today(date=None,iso=False):
if date is None: date=datetime.date.today()
if iso: return date.isoformat()
else: return date
def yesterday(date=None,iso=False):
if date is None: date=today()
@psychemedia
psychemedia / Dockerfile
Last active October 1, 2022 22:16
Example of setting up a Docker image containing a suite of applications on a related theme for use over the command line: audiogrep, videogreop and youtube_dl.
#Based on https://github.com/kevinhughes27/audiogrep-docker
# DOCKER-VERSION 1.4.0
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y software-properties-common
# FFMPEG
#The repository needs updating from the original
#Note that ffmpeg not standardly available for Ubuntu 14.04: http://www.faqforge.com/linux/how-to-install-ffmpeg-on-ubuntu-14-04/
@psychemedia
psychemedia / README.md
Created May 16, 2014 11:51
OpenRefine *Templating* export format template to generate a geojson file containing a lists of points and connections between them.

This OpenRefine Templating export format template will generate a geojson file containing a lists of points and connections between them.

Requires:

  • the name of the column containing the from marker description (from in the example);
  • the name of the column containing the to marker description (to in the example);
  • a column containing numerical latitude co-ordinate value for the from location (from_lat in the example);
  • a column containing numerical longitude co-ordinate value for the from location (from_lon in the example);
  • a column containing numerical latitude co-ordinate value for the to location (to_lat in the example);
  • a column containing numerical longitude co-ordinate value for the to location (to_lon in the example).
@psychemedia
psychemedia / print_pack.py
Created September 1, 2022 11:20
Generate PDF and epub version of jupyter notebook collections
# # `print_publication.py`
#
# Script for generating print items (weekly PDF, weekly epub).
# # Install requirements
#
# - Python
# - pandoc
# - python packages:
# - ipython
@psychemedia
psychemedia / archive-bibtex.ipynb
Created August 8, 2022 15:31
Attempt to generate BibTeX file for publications on archive.org
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / nomis_api_demo.ipynb
Last active June 26, 2022 19:30
demo - nomis API python wrapper
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / pandas-test.ipynb
Last active June 22, 2022 08:48
Test read/write for pandas dataframes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / dakar_rules.ipynb
Last active June 20, 2022 08:05
Example of generating text from pandas dataframe using a python rules engine ( durable_rules )
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / spritz_mobile_data.ipynb
Last active June 7, 2022 08:43
Example of parsing Mark Spritz mobile phone data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.