Skip to content

Instantly share code, notes, and snippets.

View deeplook's full-sized avatar

deeplook

View GitHub Profile
@deeplook
deeplook / timestamp.py
Last active September 30, 2024 17:48 — forked from ju-popov/timestamp.py
Python DateTime / Timestamp Conversion
######################################################################
# 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)
@deeplook
deeplook / fetch_springer_ebooks.py
Created April 29, 2020 19:49
Fetch free Springer ebooks.
#!/usr/bin/env python3
"""
Download free Springer ebooks.
Examples:
python fetch_springer_ebooks python
python fetch_springer_ebooks --dest my/ebooks math
python fetch_springer_ebooks
@deeplook
deeplook / pi_digits.py
Created February 13, 2013 20:16
Generate digits of Pi using a spigot algorithm.
"""
Run the algorithm below using CPython, Cython, PyPy and Numba and compare
their performance. (This is implementing a spigot algorithm by A. Sale,
D. Saada, S. Rabinowitz, mentioned on
http://mail.python.org/pipermail/edu-sig/2012-December/010721.html).
"""
def pi_digits(n):
"Generate n digits of Pi."
k, a, b, a1, b1 = 2, 4, 1, 12, 4
@deeplook
deeplook / bridge_days.ipynb
Created May 12, 2018 21:07
List bridge days for one year and country
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@deeplook
deeplook / gh_cloc.py
Last active October 5, 2023 15:11
Fetch GitHub repo and run cloc on it.
#!/usr/bin/env python
"""
Find the default branch of a GitHub repository online,
download its zipped archive, unpack it in a temporary
directory, and run cloc over it and show the output table.
$ python gh_cloc.py zslayton cron
22 text files.
classified 19 files
@deeplook
deeplook / app.py
Created October 14, 2022 14:30
Try serving geopandas/matplotlib content with Flask.
"""
Try serving geopandas/matplotlib content with Flask.
Run with:
flask --app app run
"""
from flask import Flask, Response
@deeplook
deeplook / speedread.py
Last active June 5, 2022 20:32
An experiment in speed reading texts in a terminal.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
An experiment in speed reading texts in a terminal.
It implements a "poor man's" version running in a plain terminal. The speed
is given in wpm, words per second. KeyboardInterrupts are captured for pausing
the presentation. At the end a summary is printed. This toy project is much
inspired by an iOS app named ReadQuick:
@deeplook
deeplook / list_repo_issues.py
Created August 30, 2011 18:59
List number of issues for project repositories on BitBucket or GitHub.
#!/usr/bin/env python
"""List number of issues for project repositories on BitBucket or GitHub.
This will list the number of issues for public repositories of a given
member with a URL like https://github.com/okfn or https://github.com/okfn.
It was written with the idea of getting insight quickly into the "issue
activity" of all projects of a repository owner.
This script uses a really simple HTML scraping approach. For anything
@deeplook
deeplook / aws_translate.py
Created March 8, 2022 10:30
Snippet for using AWS Translate online service.
"""
Snippet for using AWS Translate online service.
See https://aws.amazon.com/translate/ for more information.
"""
import os
import boto3 # pip install boto3
@deeplook
deeplook / fit_bounds.ipynb
Created December 9, 2021 18:28
Testing ipyleaflt map.fit_bounds(), setting zoom level too low
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.