Skip to content

Instantly share code, notes, and snippets.

View tjukanovt's full-sized avatar

Topi Tjukanov tjukanovt

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import requests
import csv
from datetime import timedelta
import dateutil.parser
import time
i=0
sleep = 15
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 14 16:54:39 2019
@author: topit
MQTT part based on: http://www.steves-internet-guide.com/into-mqtt-python-client/
API docs for HSL high-frequency positioning: https://digitransit.fi/en/developers/apis/4-realtime-api/vehicle-positions/
"""
import paho.mqtt.client as mqtt
<!DOCTYPE qgis_style>
<qgis_style version="2">
<symbols>
<symbol clip_to_extent="1" name="qlimt" force_rhr="0" type="fill" alpha="1">
<layer enabled="1" pass="0" locked="0" class="GeometryGenerator">
<prop v="Fill" k="SymbolType"/>
<prop v="with_variable('my_geom',&#xd;&#xa;CASE WHEN &#xd;&#xa; num_geometries( $geometry)>1&#xd;&#xa; THEN &#xd;&#xa; geometry_n( $geometry, @geometry_part_num)&#xd;&#xa; ELSE&#xd;&#xa; $geometry&#xd;&#xa; END,&#xd;&#xa; with_variable('shape',rand(1,4),&#xd;&#xa; CASE WHEN &#xd;&#xa; @shape =1&#xd;&#xa; THEN &#xd;&#xa; minimal_circle( @my_geom )&#xd;&#xa; WHEN&#xd;&#xa; @shape =2&#xd;&#xa; THEN&#xd;&#xa; oriented_bbox( @my_geom )&#xd;&#xa; WHEN&#xd;&#xa; @shape =3&#xd;&#xa; THEN&#xd;&#xa; oriented_bbox( @my_geom )&#xd;&#xa; WHEN&#xd;&#xa; @shape =4&#xd;&#xa; THEN&#xd;&#xa; simplify(@my_geom, rand(1,20))&#xd;&#xa; END))&#xd;&#xa; " k="geometryModifier"/>
<data_defined_properties>
<Option type="Map">
@tjukanovt
tjukanovt / twitterbot.py
Created July 2, 2018 18:06
A super simple Twitter bot application posting random csv content every 2 hours
import tweepy
import random
import pandas as pd
import time
#get your codes from https://apps.twitter.com/
consumer_key = 'your_code_here'
consumer_secret = 'your_code_here'
access_token = 'your_code_here'
access_token_secret = 'your_code_here'
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis styleCategories="AllStyleCategories" maxScale="0" simplifyDrawingHints="1" simplifyDrawingTol="1" simplifyMaxScale="1" version="3.18.1-Zürich" simplifyLocal="1" simplifyAlgorithm="0" readOnly="0" minScale="100000000" hasScaleBasedVisibilityFlag="0" labelsEnabled="0">
<flags>
<Identifiable>1</Identifiable>
<Removable>1</Removable>
<Searchable>1</Searchable>
<Private>0</Private>
</flags>
<temporal startExpression="" durationUnit="min" enabled="0" accumulate="0" startField="" endExpression="" fixedDuration="0" durationField="" mode="0" endField="">
<fixedRange>
@tjukanovt
tjukanovt / api_calls.py
Last active July 7, 2021 17:17
Two Python scripts that can be used to create animated route maps to multiple locations
import pandas as pd
import urllib.request
# path to your csv file with the endpoint coordinates
coordinates = pd.read_csv('swe_points.csv')
# graphhopper API call building blocks. Check Graphhopper documentation how to modify these.
urlStart = 'http://localhost:8989/route?'
point = 'point='
urlEnd = '&type=gpx&instructions=false&vehicle=car'
<!DOCTYPE qgis_style>
<qgis_style version="2">
<symbols>
<symbol tags="imported" force_rhr="0" alpha="1" type="fill" clip_to_extent="1" name="kenya_kit">
<data_defined_properties>
<Option type="Map">
<Option type="QString" value="" name="name"/>
<Option name="properties"/>
<Option type="QString" value="collection" name="type"/>
</Option>
import requests
import csv
import datetime
import calendar
import time
i=0
# Change the range depending on how long you like to record the data
for i in range (0,50):
<!DOCTYPE qgis_style>
<qgis_style version="2">
<symbols>
<symbol name="qartoon" force_rhr="0" clip_to_extent="1" alpha="1" type="fill">
<layer class="SimpleFill" enabled="1" locked="0" pass="0">
<prop v="3x:0,0,0,0,0,0" k="border_width_map_unit_scale"/>
<prop v="0,0,0,255" k="color"/>
<prop v="round" k="joinstyle"/>
<prop v="1,1" k="offset"/>
<prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/>