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 hashlib | |
def compute_file_checksum( | |
filepath: str, | |
algorithm: str = "md5", | |
chunk_size: int = 1024, | |
) -> str: | |
hasher = hashlib.new(algorithm) | |
with open(filepath, "rb") as fp: |
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 typing import Type, TypeVar, Union | |
import numpy as np | |
Number = TypeVar("TypeVar", int, float) | |
class Rectangle(np.ndarray): | |
def __new__( | |
cls, |
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 | |
set -eu | |
# Install PyEnv | |
if [ ! -e ~/.pyenv ]; then | |
git clone https://github.com/pyenv/pyenv.git ~/.pyenv | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile | |
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile |
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 asyncio | |
async def wait(): | |
print('Waiting') | |
for x in range(10 ** 100): | |
z = 10 + 20 | |
print('Done') | |
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 concurrent.futures | |
def wait(): | |
print('Waiting') | |
for x in range(10 ** 100): | |
z = 10 + 20 | |
print('Done') | |
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 concurrent.futures | |
def wait(): | |
print('Waiting') | |
for x in range(10 ** 100): | |
z = 10 + 20 | |
print('Done') | |
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 subprocess | |
class Command(object): | |
def __init__(self, *args, encode='utf8'): | |
self.encode = encode | |
self.args = args | |
def __repr__(self): | |
return '<Command({})>'.format(' '.join(self.args)) |
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 | |
sudo apt-get update | |
sudo apt-get install apt-transport-https ca-certificates | |
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D | |
sudo sh -c "echo 'deb https://apt.dockerproject.org/repo ubuntu-xenial main' > /etc/apt/sources.list.d/docker.list" | |
sudo apt-get update | |
sudo apt-get purge lxc-docker |
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
class Thumb(object): | |
def __init__(self, path): | |
self.url = 'http://hoge.com' + path | |
self.path = path | |
class ThumbDiscriptor(object): | |
BASE_PATH = '/img/{0}/{0}_{1}.{2}' | |
def __init__(self, name): | |
self.name = 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
#-*-coding=utf8-*- | |
from __future__ import absolute_import, unicode_literals | |
from django.utils import six | |
from django.forms.forms import get_declared_fields | |
from django.forms.models import BaseModelForm | |
from django.forms.widgets import media_property | |
from django.utils.datastructures import SortedDict | |
def fields_for_model(model, fields=None, exclude=None, widgets=None, error_messages=None, formfield_callback=None): |
NewerOlder