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
from __future__ import print_function | |
""" | |
Create a structured, but more compact JSON representation of a native data structure. | |
This is inspired by the way native Python data structures are displayed in Jupyter, | |
e.g.: | |
In [1]: d = {"count": 7, "limit": 7, "results": [{"path": "wifi", "meaning": "rssi", "points": [{"timestamp": 1458211728242, "value": -67}, {"timestamp": 1458211736170, "value": -74}, {"timestamp": 1458211740399, "value": -62}, {"timestamp": 1458211746265, "value": -64}], "deviceId": "1e31f865-93b9-482a-a7be-858b56c396ae"}, {"path": "/", "meaning": "batteryLevel", "points": [{"timestamp": 1458211728413, "value": 90}, {"timestamp": 1458211736216, "value": 90}, {"timestamp": 1458211740443, "value": 90}], "deviceId": "1e31f865-93b9-482a-a7be-858b56c396ae"}], "offset": 0} |
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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
A tool for signaling processes found also by their command-line invocation. | |
Sometimes you want to terminate a process based on some specific substring | |
in the command that was entered in a terminal to start it, e.g. here you | |
might want to terminate only a process like this that is running a Python | |
SimpleHTTPServer started with:: |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 datetime | |
import threading | |
class PeriodicTimer(object): | |
""" | |
A class wrapping a callable to be called periodically inside a thread. | |
The wrapped function is called the first time immediately after creating | |
an instance of this class. |
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
###################################################################### | |
# CURRENT AWARE LOCAL DATETIME | |
###################################################################### | |
from datetime import datetime | |
from tzlocal import get_localzone # pip install tzlocal | |
local_tz = get_localzone() | |
local_dt = datetime.now(local_tz) |
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
#!/usr/bin/env python | |
""" | |
Implement a "slow-motion" Unix 'cat' command. | |
Intended to be used with tools like 'asciinema', see asciinema.org. | |
None of the options of Unix 'cat' are implemented here. | |
Examples: |
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
#!/usr/bin/env python | |
""" | |
A little tool to render GeoJSON files as layers in an HTML output map file. | |
The output map shows the region covered by the combined bounding box of all | |
GeoJSON input files. This was tested only with Python 3.5, but should also | |
work on Python >= 2.7. | |
The pygeoj package does calculate the bounding box correctly only for version |
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
#!/usr/bin/env bash | |
echo "Benchmark for Fibonacci numbers with Python3, Cython and PyPy" | |
echo ' | |
def fib(n): | |
"Return the n-th Fibonacci number." | |
i = 0 | |
a, b = 0, 1 | |
if n < 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
#!/usr/bin/env python | |
""" | |
List keyword tokens in Scala source code. | |
Originally intended for spotting lines containing "var" declarations | |
in Scala source files (hence the name "scala varning") which are | |
somewhat considered "harmful" in Scala. The same can be useful for | |
spotting explicit "return" statements which might be superfluous, | |
and, of course, other keywords. |