This file contains 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
def pop_val(datastring, index): | |
b = None | |
res = shift = 0 | |
while b is None or b >= 0x20: | |
b = ord(datastring[index]) - 63 | |
res |= ( (b & 0x1f) << shift ) | |
index += 1 | |
shift += 5 | |
if res & 1: | |
return ~(res >> 1), index |
This file contains 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
segments_df['line'] = segments_df.apply(lambda x: LineString([Point(x["lon_x"], x["lat_x"]), | |
Point(x["lon_y"], x["lat_y"])]), | |
axis=1) | |
geodata = gpd.GeoDataFrame(segments_df, geometry=segments_df['line']) | |
geodata['width'] = 5 * (geodata['count']) / (geodata['count'].max()) |
This file contains 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
geodata.plot(figsize=(15, 15), linewidth=np.minimum(np.maximum(df5['width'], 0.1), 2.75)) |
This file contains 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
plt.figure(figsize=(15, 15)) | |
ax = plt.gca() | |
geodata.plot(ax=ax) | |
import contextily as ctx | |
ctx.add_basemap(ax, crs='EPSG:4326', source=ctx.providers.OpenStreetMap.Mapnik) |
This file contains 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
ax = geodata.plot(figsize=(15,15)) | |
import contextily as ctx | |
ctx.add_basemap(ax, crs='EPSG:4326', source=ctx.providers.OpenStreetMap.Mapnik) |
This file contains 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 sys, logging, utils | |
from importlib import import_module | |
from logging.handlers import RotatingFileHandler | |
CONFIG_FILE = 'systems.cred' | |
if __name__ == '__main__': | |
logger = logging.getLogger('home automation') | |
logger.setLevel(logging.DEBUG) | |
fh = RotatingFileHandler('script.log', mode='a', maxBytes=10485760, backupCount=2) |
This file contains 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 utils, logging | |
STATUS_FILE = "example.dat" | |
def run(): | |
logger = logging.getLogger('home automation') | |
logger.debug("Script: Example script") | |
example_bool = utils.get_current_status(STATUS_FILE, default=False) | |
logger.debug("Example bool: " + str(example_bool)) | |
example_bool = not example_bool | |
utils.save_current_state(STATUS_FILE, example_bool) |
This file contains 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 logging, requests | |
logger = logging.getLogger('home automation') | |
class Screens(object): | |
def __init__(self, ifttt_key): | |
self.ifttt_key = ifttt_key | |
def ifttt_call(self, triggername): | |
logger.debug('Firing screen trigger : ' + triggername) | |
requests.post("https://maker.ifttt.com/trigger/" + triggername + "/with/key/" + |
This file contains 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 tahoma, utils, logging, datetime | |
CONFIG_FILE = 'systems.cred' | |
STATUS_FILE = "status_screens.dat" | |
COUNT_FILE = "status_screens_count.dat" | |
COUNT_FILE_OPENNOW = "status_screens_count_opennow.dat" | |
DELAY_MINUTES = 7 | |
def run(config=None): |
This file contains 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 tahoma, utils, logging, datetime | |
CONFIG_FILE = 'systems.cred' | |
STATUS_FILE = "status_screens.dat" | |
COUNT_FILE = "status_screens_count.dat" | |
COUNT_FILE_OPENNOW = "status_screens_count_opennow.dat" | |
DELAY_MINUTES = 7 | |
def run(): |