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
const canvases = document.querySelectorAll('canvas'); | |
for (let i = 0; i < canvases.length; i++) { | |
const canvas = canvases[i]; | |
const link = document.createElement('a'); | |
link.download = `canvas-${i}.png`; | |
link.href = canvas.toDataURL(); | |
link.click(); | |
} |
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 ast | |
import sys | |
import inflection | |
class TransformDeclaredAttr(ast.NodeTransformer): | |
def visit_FunctionDef(self, node: ast.FunctionDef): | |
if 'declared_attr' in [dec.id for dec in node.decorator_list]: | |
assert len(node.body) == 1 |
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 hashlib import sha256 | |
from typing import BinaryIO | |
CHUNK_LEN = 512 << 20 # 512 MB | |
def chunked_hash(data: BinaryIO, chunk_len: int = CHUNK_LEN) -> sha256: | |
checksum = sha256() | |
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
0 536870912 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 | |
536870912 1073741824 936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af | |
1073741824 1076887552 6c31a451d91860cee189a6d356defdc42d416b671921877ad8f5041124fc9199 |
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
[testenv:typecheck] | |
skip_install = true | |
deps = mypy | |
commands = mypy --ignore-missing-imports your_package_name |
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
@access.user | |
@autoDescribeRoute( | |
Description("Get the position of a queued job.") | |
.modelParam("id", model=Job, level=AccessType.READ) | |
) | |
def getQueuePosition(self, job): | |
# Note: this only works with rabbitmq. Celery's abstraction does not provide | |
# an interface at this level. | |
taskId = job["celeryTaskId"] | |
broker = Setting().get("worker.broker") |
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
task_id = "change_this" # TODO change this to your celery task ID | |
broker = "amqp://guest:guest@localhost/" # TODO set this | |
MAX_QUEUE_CHECK = 20 | |
try: | |
connection = pika.BlockingConnection(pika.URLParameters(broker)) | |
channel = connection.channel() | |
pos = -1 | |
for i, (_, properties, _) in enumerate(channel.consume("celery", inactivity_timeout=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
#!/bin/bash | |
fname=mongodump_$(date +%Y%m%d_%H%M%S) | |
mongodump -h localhost -d girder -o $fname || exit 1 | |
echo "Archiving girder_db_dump" | |
tar cjvf ${fname}.tar.bz2 $fname && rm -rf $fname | |
echo "Uploading girder_db_dump.tar.bz2 to S3 covalic-backup bucket" | |
python `dirname $0`/upload_to_s3.py ${fname}.tar.bz2 covalic-backup && rm ${fname}.tar.bz2 |
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 struct | |
import typing | |
def humanize(val: bytes, words: typing.List[str]) -> typing.List[str]: | |
return [words[struct.unpack_from("H", val, i)[0]] for i in range(0, len(val), 2)] | |
def dehumanize(val: typing.List[str], words_map: typing.Dict[str, int]) -> bytes: | |
return b"".join((struct.pack("H", words_map[word]) for word in val)) |
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
*** Error in `/opt/virtualenv/bin/python3': free(): invalid pointer: 0x00007f325102bd80 *** | |
======= Backtrace: ========= | |
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f326e6487e5] | |
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f326e65137a] | |
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f326e65553c] | |
/opt/virtualenv/lib/python3.5/site-packages/mapnik/.libs/libstdc++-a31e722f.so.6.0.13(_ZNSt6locale5_Impl16_M_install_facetEPKNS_2idEPKNS_5facetE+0x1ca)[0x7f3250d9e37a] | |
/opt/virtualenv/lib/python3.5/site-packages/mapnik/.libs/libstdc++-a31e722f.so.6.0.13(_ZNSt6locale5_ImplC1Em+0x1cf)[0x7f3250d9ebbf] | |
/opt/virtualenv/lib/python3.5/site-packages/mapnik/.libs/libstdc++-a31e722f.so.6.0.13(+0x65b45)[0x7f3250d9fb45] | |
/lib/x86_64-linux-gnu/libpthread.so.0(+0xea99)[0x7f326e9a9a99] | |
/opt/virtualenv/lib/python3.5/site-packages/mapnik/.libs/libstdc++-a31e722f.so.6.0.13(+0x65b81)[0x7f3250d9fb81] |
NewerOlder