Instantly share code, notes, and snippets.

# Duncan Parkes deparkes

Created July 23, 2021 19:29
Simple exploration of the Lorentz cipher concept using Python - see also https://wp.me/p4DE9r-1mc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Baudot import random import string # Taken from https://www.cryptomuseum.com/ref/ita2/index.htm baudot = { 'a': '0b00011', 'b': '0b11001', 'c': '0b01110', 'd': '0b01001', 'e': '0b00001',
Last active February 27, 2019 20:46
Example of combining lines and markers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import folium points_a = [[1,50], [1.2,50.3], [1.23, 50.7]] points_z = [[1,51], [1.2,51.3], [1.23, 51.7]] # Load map centred on average coordinates ave_lat = sum(p[0] for p in points_a)/len(points_a) ave_lon = sum(p[1] for p in points_a)/len(points_a) my_map = folium.Map(location=[ave_lat, ave_lon], zoom_start=9)
Created April 22, 2017 09:32
Example of defining a field with polar coordinates in OOMMF mif file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # MIF 2.1 # MIF Example File: ellipsoid.mif # Description: Hysteresis loop of an ellipsoidal particle. # This example uses an Oxs_EllipsoidAtlas to define the # ellipsoid volume. This example is exactly equivalent # to ellipsoid-atlasproc.mif and ellipsoid-fieldproc.mif. set pi [expr {4*atan(1.0)}] set mu0 [expr {4*\$pi*1e-7}] set theta 270
Created May 30, 2016 13:57
A sample file for creating a publications list in a thesis or dissertation, separate fromt the references list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 \documentclass{article} \usepackage{natbib} \usepackage{bibunits} \begin{document} % bibunit to list our publications \begin{bibunit}[plain] \renewcommand{\bibsection}{\large \textbf{\begin{center} Publications \end{center}}}
Created May 15, 2016 10:19
UK University Locations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Name lat lon The University of Aberdeen 57.165019 -2.099122 University of Abertay Dundee 56.46334 -2.973441 Aberystwyth University 52.403473 -4.043584 Anglia Ruskin University 51.741381 0.474495 Aston University 52.486637 -1.890952 Bangor University 53.229193 -4.129437 Bath Spa University 51.373209 -2.440912 The University of Bath 51.380441 -2.330673 University of Bedfordshire 51.87825 -0.411539
Created May 2, 2016 13:18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import gpxpy import gpxpy.gpx import folium gpx_file = open('path_to_gpx_file.gpx', 'r') gpx = gpxpy.parse(gpx_file) points = [] for track in gpx.tracks: for segment in track.segments:
Last active May 2, 2016 07:50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import gpxpy import gpxpy.gpx import folium gpx_file = open('my_gpx_coords.gpx', 'r') gpx = gpxpy.parse(gpx_file) points = [] for track in gpx.tracks: for segment in track.segments:
Created April 18, 2016 17:25
Code to generate an interactive map of Colchester public toilets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import os import folium import pandas as pd from bng_to_latlon import OSGB36toWGS84 os.chdir("C:\Users\Duncan\Documents\Python Scripts\pythonGIS") # Load map centred on Colchester uk = folium.Map(location=[51.8860942,0.8336077], zoom_start=10) # Load locally stored colchester public toilets data toilets = pd.read_csv("public-toilets.csv")
Last active November 14, 2016 20:18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # -*- coding: utf-8 -*- """ Created on Tue Oct 20 11:41:59 2015 Find out from which years you cited most publications in your thesis or dissertation. https://xkcd.com/208/ May need to somehow account for 'missing' years http://pandas.pydata.org/pandas-docs/stable/missing_data.html
Last active August 29, 2015 14:22 — forked from bsweger/useful_pandas_snippets.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #List unique values in a DataFrame column pd.unique(df.column_name.ravel()) #Convert Series datatype to numeric, getting rid of any non-numeric values df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) #Grab DataFrame rows where column has certain values valuelist = ['value1', 'value2', 'value3'] df = df[df.column.isin(value_list)]