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
#!/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 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. |
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 | |
""" | |
An updated example file actually using an auto-upgrading tool. | |
WARNING: | |
If you find this script inside a GitHub gist, be warned that | |
its gist ID might change without notice! In this case please | |
look for similar filenames until this might become part of |
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
{ | |
"version": 1, | |
"width": 109, | |
"height": 25, | |
"duration": 80.986919, | |
"command": null, | |
"title": null, | |
"env": { | |
"TERM": "xterm-256color", | |
"SHELL": "/bin/bash" |
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 -*- | |
""" | |
Prototype of a 'dynamic' prompt showing CPU load over 10 seconds as a sparkline. | |
Requires ``psutil``... | |
Not finished... | |
""" |
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 re | |
from selenium import webdriver # pip install selenium | |
from PIL import Image # pip install Pillow | |
driver = webdriver.PhantomJS() # assuming PhantomJS | |
width, height = 1024, 768 | |
driver.set_window_size(width, height) | |
driver.get("http://docs.python-requests.org") | |
fn = "screenshot.png" | |
driver.save_screenshot(fn) |
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 | |
""" | |
Explore a RESTful Swagger/OpenAPI specification with Swagger-UI in a browser. | |
Features: | |
- download a recent Swagger-UI release | |
- extract its "dist" folder | |
- copy desired JSON file into "dist" folder |