Created
May 26, 2014 16:39
-
-
Save prokizzle/75d1d93a814d859d2219 to your computer and use it in GitHub Desktop.
Pythonista - Quick Driving Duration Calculator
This file contains hidden or 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
/* | |
* Globals | |
*/ | |
/* Links */ | |
a, | |
a:focus, | |
a:hover { | |
color: #fff; | |
} | |
/* Custom default button */ | |
.btn-default, | |
.btn-default:hover, | |
.btn-default:focus { | |
color: #333; | |
text-shadow: none; /* Prevent inheritence from `body` */ | |
background-color: #fff; | |
border: 1px solid #fff; | |
} | |
/* | |
* Base structure | |
*/ | |
html, | |
body { | |
height: 100%; | |
background-color: #333; | |
} | |
body { | |
color: #fff; | |
text-align: center; | |
text-shadow: 0 1px 3px rgba(0,0,0,.5); | |
box-shadow: inset 0 0 100px rgba(0,0,0,.5); | |
} | |
/* Extra markup and styles for table-esque vertical and horizontal centering */ | |
.site-wrapper { | |
display: table; | |
width: 100%; | |
height: 100%; /* For at least Firefox */ | |
min-height: 100%; | |
} | |
.site-wrapper-inner { | |
display: table-cell; | |
vertical-align: top; | |
} | |
.cover-container { | |
margin-right: auto; | |
margin-left: auto; | |
} | |
/* Padding for spacing */ | |
.inner { | |
padding: 30px; | |
} | |
/* | |
* Header | |
*/ | |
.masthead-brand { | |
margin-top: 10px; | |
margin-bottom: 10px; | |
} | |
.masthead-nav > li { | |
display: inline-block; | |
} | |
.masthead-nav > li + li { | |
margin-left: 20px; | |
} | |
.masthead-nav > li > a { | |
padding-right: 0; | |
padding-left: 0; | |
font-size: 16px; | |
font-weight: bold; | |
color: #fff; /* IE8 proofing */ | |
color: rgba(255,255,255,.75); | |
border-bottom: 2px solid transparent; | |
} | |
.masthead-nav > li > a:hover, | |
.masthead-nav > li > a:focus { | |
background-color: transparent; | |
border-bottom-color: rgba(255,255,255,.25); | |
} | |
.masthead-nav > .active > a, | |
.masthead-nav > .active > a:hover, | |
.masthead-nav > .active > a:focus { | |
color: #fff; | |
border-bottom-color: #fff; | |
} | |
@media (min-width: 768px) { | |
.masthead-brand { | |
float: left; | |
} | |
.masthead-nav { | |
float: right; | |
} | |
} | |
/* | |
* Cover | |
*/ | |
.cover { | |
padding: 0 20px; | |
} | |
.cover .btn-lg { | |
padding: 10px 20px; | |
font-weight: bold; | |
} | |
/* | |
* Footer | |
*/ | |
.mastfoot { | |
color: #999; /* IE8 proofing */ | |
color: rgba(255,255,255,.5); | |
} | |
/* | |
* Affix and center | |
*/ | |
@media (min-width: 768px) { | |
/* Pull out the header and footer */ | |
.masthead { | |
position: fixed; | |
top: 0; | |
} | |
.mastfoot { | |
position: fixed; | |
bottom: 0; | |
} | |
/* Start the vertical centering */ | |
.site-wrapper-inner { | |
vertical-align: middle; | |
} | |
/* Handle the widths */ | |
.masthead, | |
.mastfoot, | |
.cover-container { | |
width: 100%; /* Must be percentage or pixels for horizontal alignment */ | |
} | |
} | |
@media (min-width: 992px) { | |
.masthead, | |
.mastfoot, | |
.cover-container { | |
width: 700px; | |
} | |
} |
This file contains hidden or 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 urllib2 | |
import urllib | |
import json | |
import webbrowser | |
import sys | |
origin = "78704" | |
destination = urllib.quote(sys.argv[1],'') | |
response = urllib2.urlopen("http://maps.googleapis.com/maps/api/distancematrix/json?origins={0}&destinations={1}&mode=driving&sensor=false".format(origin, destination)) | |
r= json.loads(response.read()) | |
duration = str(r["rows"][0]["elements"][0]["duration"]["text"]) | |
message = str(duration + " to " + destination) | |
webbrowser.open("http://dropbox_public_path_to_output.html?h1=" + message + "&return=launchpro") |
This file contains hidden or 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
function getParameterByName(name) { | |
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); | |
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | |
results = regex.exec(location.search); | |
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | |
} | |
function returnToApp() { | |
window.location = (callback + "://"); | |
} | |
$(document).ready(function() { | |
var header = getParameterByName('h1'); | |
var subheader = getParameterByName('h2'); | |
var description = getParameterByName('p'); | |
var callback = getParameterByName('return') | |
$("#header").html(decodeURI(header)); | |
$("#subheader").html(subheader); | |
$("#description").html(description); | |
$("#callback").click(function() { | |
window.location = (callback + "://"); | |
}); | |
}); |
This file contains hidden or 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
<html> | |
<head> | |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> | |
<link rel="stylesheet" href="css/cover.css"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="css/style.css"> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script> | |
<script src="js/handler.js"></script> | |
</head> | |
<body> | |
<div class="site-wrapper"> | |
<div class="site-wrapper-inner"> | |
<div class="cover-container"> | |
<div class="masthead clearfix"> | |
<div class="inner"> | |
<h3 class="masthead-brand"></h3> | |
</div> | |
</div> | |
<div class="inner cover"> | |
<h1 class="cover-heading" id="header">Cover your page.</h1> | |
<p class="lead" id="description">Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.</p> | |
<p class="lead"> | |
<a href="#" class="btn btn-lg btn-default" id="callback">Back</a> | |
</p> | |
</div> | |
<div class="mastfoot"> | |
<div class="inner"> | |
<p>By Nick Prokesch.</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment