Skip to content

Instantly share code, notes, and snippets.

const sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
(async () => {
console.log('a');
await sleep(1000);
console.log('b');
await sleep(1000);
console.log('c');
await sleep(1000);
console.log('d');
from random import random as r
count = lambda i : (lambda i, f: f(i, 1, f))(i, lambda i, c, f: f(i, c+1, f) if r() > i else c)
print(count(0.1)) # 10%が成功するまでの回数
@NaokiKojima4994
NaokiKojima4994 / image_aspect.py
Last active December 5, 2017 13:51
pythonで画像のアスペクト比を維持したままサイズ変更して余白を埋める ref: https://qiita.com/NaokiKojima4994/items/9e49021b671a7720bace
# -*- coding: utf-8 -*-
from PIL import Image
class image_aspect():
def __init__(self, image_file, aspect_width, aspect_height):
self.img = Image.open(image_file)
self.aspect_width = aspect_width
self.aspect_height = aspect_height
self.result_image = None