$/
artifacts/
build/
docs/
lib/
packages/
samples/
src/
tests/
This file contains hidden or 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
| export async function downloadObjectAsJSONFile(object, filename) { | |
| if(!filename.endsWith('.json')) { | |
| filename = `${filename}.json` | |
| } | |
| const json = JSON.stringify(object) | |
| const blob = new Blob([json],{ type:'application/json' }) | |
| const href = await URL.createObjectURL(blob) | |
| const link = document.createElement('a') | |
| link.href = href | |
| link.download = filename |
This file contains hidden or 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
| """ | |
| This gist shows how to run asyncio loop in a separate thread. | |
| It could be useful if you want to mix sync and async code together. | |
| Python 3.7+ | |
| """ | |
| import asyncio | |
| from datetime import datetime | |
| from threading import Thread | |
| from typing import Tuple, List, Iterable |
This file contains hidden or 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 calculate_aspect(width: int, height: int) -> str: | |
| def gcd(a, b): | |
| """The GCD (greatest common divisor) is the highest number that evenly divides both width and height.""" | |
| return a if b == 0 else gcd(b, a % b) | |
| r = gcd(width, height) | |
| x = int(width / r) | |
| y = int(height / r) | |
| return f"{x}:{y}" |
This file contains hidden or 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
| You can extract .ico icons from an exe with 7-zip! |
This file contains hidden or 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
| #deb cdrom:[Ubuntu 14.04.3 LTS _Trusty Tahr_ - Beta amd64 (20150805)]/ trusty main restricted | |
| # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to | |
| # newer versions of the distribution. | |
| deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted | |
| deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted | |
| ## Major bug fix updates produced after the final release of the | |
| ## distribution. | |
| deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted |
This file contains hidden or 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
| # based on: http://stackoverflow.com/questions/1015307/python-bind-an-unbound-method#comment8431145_1015405 | |
| def bind(instance, func, as_name): | |
| """ Turn a function to a bound method on an instance | |
| .. doctest:: | |
| >>> class Foo(object): | |
| ... def __init__(self, x, y): | |
| ... self.x = x | |
| ... self.y = y |