Skip to content

Instantly share code, notes, and snippets.

View tonysimpson's full-sized avatar

Tony Simpson tonysimpson

  • Glean
  • Leeds, UK
View GitHub Profile
@tonysimpson
tonysimpson / default_controller.py
Created December 7, 2015 14:03
Swagger CodeGen LOL
def (latitude, longitude) -> str:
return 'do some magic!'
def (offset, limit) -> str:
return 'do some magic!'
def () -> str:
return 'do some magic!'
@tonysimpson
tonysimpson / jump_manchine.c
Created July 20, 2015 09:59
Example of a computed jump based interpreter.
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <windows.h>
typedef struct {
union {
bool bool_value;
int64_t int64_value;
double double_value;
@tonysimpson
tonysimpson / visible_text_example.py
Last active January 21, 2021 18:19
Using Selenium to location and automate elements via thier visible text.
# Note I haven't executed this code it's
# written from memory - its purpose is
# as an example.
from selenium import webdriver
wd = webdriver.Firefox()
# ... open a website etc.
@tonysimpson
tonysimpson / gist:5923632
Created July 3, 2013 23:06
Experimenting to find a simpler approach to delegation as implemented by https://github.com/5long/forwardable
class AliasDelegateMethodOntoSelfApproach(object):
def __init__(self):
self.bar = set()
self.__len__, self.add = self.bar.__len__, self.bar.add
foo = AliasDelegateMethodOntoSelfApproach()
foo.add(1) # Delegates to foo..add(), works fine
assert foo.bar != set([0]) # negative test
assert foo.bar == set([1]) # positive test
@tonysimpson
tonysimpson / hexbinmapplot.py
Created April 27, 2013 13:07
Plotting hexbin on a map projection using Basemap and Mapplotlib
from matplotlib import pylab # .exe install is on sourceforge
import numpy# easy_install numpy
from mpl_toolkits.basemap import Basemap # easy_install basemap
# functions to create some random data points and convert them to meters via the map projection
def create_points_in_lon_lat(N=10000):
return zip(numpy.random.standard_normal(N)*360, numpy.random.standard_normal(N) * 45)
def convert_lon_lat_points_to_meters_using_transform(points, tran):
# maybe there is a better way to get long/lat into meters but this works ok