Skip to content

Instantly share code, notes, and snippets.

Avatar

Lene Preuss lene

View GitHub Profile
@lene
lene / subparser.py
Last active Jul 13, 2020
argparse subparser easy use
View subparser.py
def command(args):
pass
parser = argparse.ArgumentParser()
subparser = parser.add_subparsers(title="subcommands")
command_parser = subparser.add_parser("command")
command_parser.set_defaults(func=command)
command_parser.add_argument("--dummy", help="some arg to the subcommand")
args = parser.parse_args()
@lene
lene / here.js
Last active Mar 20, 2018
Add this at the end of here.js to request and display a Park and Ride route
View here.js
var mobility = new H.Mobility({
map: map,
app_id: '{YOUR_APP_ID}', // <-- ENTER YOUR APP ID HERE
app_code: '{YOUR_APP_CODE}', // <-- ENTER YOUR APP CODE HERE
});
var ui = mobility.createDefaultUI();
mobility.route({
dep: {YOUR_START_POINT}, // <-- ENTER YOUR START POINT HERE
@lene
lene / response.json
Last active Mar 20, 2018
HERE Intermodal Routing API response (shortened example)
View response.json
{
"Res": {
"Connections": {
"Connection": [
{
"@duration": "PT2H3M33S",
"@transfers": "2",
"Sections": {
"Sec": [
{
@lene
lene / request.sh
Last active Mar 20, 2018
Anatomy of a request to the HERE Intermodal Routing API
View request.sh
http://mobility.api.here.com/v1/route
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&profile=parkandride
&dep={YOUR_START_POINT}
&arr=41.884238,-87.638862
&time=2018-03-20T07:30:00
@lene
lene / tools.js
Last active Mar 19, 2018
Requesting and rendering a route from the HERE Intermodal Routing API
View tools.js
(function(NS) {
var APP_ID = '{YOUR_APP_ID}', // // <-- ENTER YOUR APP ID HERE
APP_CODE = '{YOUR_APP_CODE}'; // <-- ENTER YOUR APP CODE HERE
function Mobility(options) {
this.map = options.map;
}
Mobility.prototype = {
@lene
lene / here.js
Created Mar 8, 2018
Creating a map using the HERE Maps Javascript API
View here.js
var platform = new H.service.Platform({
useCIT: true,
app_id: '{YOUR_APP_ID}', // // <-- ENTER YOUR APP ID HERE
app_code: '{YOUR_APP_CODE}', // <-- ENTER YOUR APP CODE HERE
});
var maptypes = platform.createDefaultLayers();
var map = new H.Map(document.getElementById('map'), maptypes.terrain.map, {
zoom: 9,
center: { lat: 41.884238, lng: -87.638862 }
@lene
lene / demo.html
Created Mar 8, 2018
HTML page including all JavaScript for HERE Intermodal Routing API blog
View demo.html
<html>
<head>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-core.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-mapevents.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-service.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-ui.js"></script>
<script src="http://taser-dev.rnd.transit.api.here.com:8008/static/js/jquery.min.js"></script>
<script src="tools.js"></script>
</head>
View PnR.json
{
"Res": {
"Connections": {
"Connection": [
{
"@duration": "PT2H3M33S",
"@transfers": "2",
"Dep": {
"@time": "2018-03-20T07:47:27",
"Addr": {
@lene
lene / decorator_method.py
Last active Jan 30, 2018
Python decorator (class method)
View decorator_method.py
from functools import wraps
def method_decorator(method):
@wraps(method)
def method_wrapper(self, *args, **kwargs):
return do_stuff(method(self, *args, **kwargs))
return method_wrapper
@lene
lene / decorator_args.py
Last active Dec 21, 2018
Python decorator with argument(s)
View decorator_args.py
from functools import wraps
def decorator_with_argument(argument=None):
def actual_decorator(func):
@wraps(func)
def func_wrapper(*args, **kwargs):
return do_stuff(func(*args, **kwargs), argument)
You can’t perform that action at this time.