Skip to content

Instantly share code, notes, and snippets.

View marktyers's full-sized avatar

Mark Tyers marktyers

View GitHub Profile
@marktyers
marktyers / trafficincidents.py
Created February 11, 2014 18:54
Simple #python script to extract traffic incidents from Bing Maps in #json format #321COM
import urllib2
import json
# http://msdn.microsoft.com/en-us/library/hh441726.aspx
# get lat/lon data from http://itouchmap.com/latlong.html
latN = str(52.477213)
latS = str(52.356601)
lonW = str(-1.615194)
lonE = str(-1.344656)
@marktyers
marktyers / roadworksDOM.py
Last active August 29, 2015 13:56
#python code showing how to parse an RSS feed using the DOM #321COM
from xml.dom.minidom import parseString, Node
import urllib
# http://www.highways.gov.uk/news/connect/rss-feeds/traffic-information-rss-feeds/
url = 'http://hatrafficinfo.dft.gov.uk/feeds/rss/CurrentAndFutureEvents/West%20Midlands.xml'
f = urllib.urlopen(url)
xml = f.read()
xmldoc = parseString(xml)
@marktyers
marktyers / flickr.py
Created September 6, 2014 16:42
Searching Flickr
import json
key = '<YOUR FLICKR API KEY>'
url = 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key='+key+'&tags=coventry&format=json&nojsoncallback=1'
response = urllib2.urlopen(url).read()
data = json.loads(response.decode('utf8'))
photos = data['photos']['photo']
for photo in photos:
@marktyers
marktyers / gist:d9cf82f8185ff9eff768
Created December 10, 2014 09:37
Form validation
<!DOCTYPE html>
<html>
<head>
<title>Simple Form Validation</title>
<script>
window.onload = function() {
console.log('onLoad');
var form = document.forms.register;
form.onsubmit = function() {
console.log('onSubmit');
@marktyers
marktyers / quotes.json
Created December 10, 2014 17:22
Quotes in JSON Format
{
"docs": [
{
"_id": "turing",
"name": "Alan Turing",
"born": "1912-06-23",
"quotes": [
"We can only see a short distance ahead, but we can see plenty there that needs to be done",
"We are not interested in the fact that the brain has the consistency of cold porridge",
"A computer would deserve to be called intelligent if it could deceive a human into believing that it was human",
@marktyers
marktyers / clarke.json
Created December 10, 2014 18:54
Quotes by Arthur C. Clarke
{
"name": "Arthur C. Clarke",
"born": "1917-12-16",
"quotes": [
"Any sufficiently advanced technology is indistinguisable from magic",
"Reading computer manuals without the hardware is as frustrating as reading sex manuals without the software",
"How innapropriate to call this planet Earth when it is quite clearly Ocean",
"I don't believe in astrology. I'm a Sagittarius and we're skeptical"
]
}
@marktyers
marktyers / gist:615074ff49d31ca3dcce
Created December 11, 2014 16:59
Form validation with array
<!DOCTYPE html>
<html>
<head>
<title>Simple Form Validation</title>
<script>
window.onload = function() {
console.log('onLoad');
var people = [];
var form = document.forms.register;
{
"people" : [ {
"born" : 1955,
"fame" : "co-founder of Apple Computers",
"name" : "Steve Jobs"
}, {
"born" : 1955,
"name" : "Tim Berners-Lee"
}, {
"born" : 1815,
@marktyers
marktyers / gist:7de25ccaed9c5dbecdd9
Created August 4, 2015 08:14
Log from docker-compose --verbose up -d
docker@boot2docker:~/docker$ docker-compose --verbose up -d
Compose version 1.3.3
Docker base_url: http+docker://localunixsocket
Docker version: KernelVersion=4.0.5-boot2docker, Os=linux, ApiVersion=1.19, Version=1.7.0, GitCommit=0baf609, Arch=amd64, GoVersion=go1.4.2
docker containers <- (all=True, filters={u'label': [u'com.docker.compose.project=docker', u'com.docker.compose.service=broker', u'com.docker.compose.oneoff=False']})
docker containers -> (list with 0 items)
docker containers <- (all=True)
docker containers -> (list with 0 items)
docker containers <- (all=True, filters={u'label': [u'com.docker.compose.project=docker', u'com.docker.compose.service=publisher', u'com.docker.compose.oneoff=False']})
docker containers -> (list with 0 items)
@marktyers
marktyers / ubuntu.sh
Last active January 11, 2019 10:04
Setting up a web dev machine on Ubuntu 15.
#!/bin/bash
# BIOS Settings
# If you plan on running virtual machines using virtualbox you need to enable this in the BIOS
# on HP machines: ESC, computer setup, security > system security. enable VTx and VTd.
# on Lenovo: ENTER,
# needs to be run with root privileges
# sudo -s