Skip to content

Instantly share code, notes, and snippets.

View yassu's full-sized avatar
💭
👨‍💼

yassu yassu

💭
👨‍💼
  • JP
View GitHub Profile
@yassu
yassu / block.diag
Created September 15, 2014 09:10
issue2(blockdiag-math ver0.0.2)
blockdiag {
plugin math;
A[label="", background="math://\RR"];
}
@yassu
yassu / result
Created September 14, 2014 01:24
result of not dvipng(blockdiag-math)
yuki@ blockdiag block.diag --debug
WARNING: Failed to load blockdiag.imagedraw.pdf: ImportError("No module named 'reportlab'",)
WARNING: Fail to convert formula: a\sin\theta (reason: dvipng command not found)
from random import randint
from inspect import isfunction
def get_random():
return randint(0, 10**10)
class Cacher:
pass
DEFAULT_CACHER = Cacher()
@yassu
yassu / fizzbuzz.py
Created July 9, 2014 09:17
fizzbuzz
#!/usr/bin/env python3
def fizzbuzz():
""" generator of fizzbuzz """
i = 1
while True:
s = ''
if i % 3 == 0:
s += 'Fizz '
import timeit
def get_average(array):
return sum(array) / len(array)
t = timeit.Timer('cond=True; cond == True')
print(get_average(t.repeat(100)))
# -> 0.04552456719000474
t = timeit.Timer('cond=True; cond is True')
import timeit as _timeit
from math import sqrt as _sqrt
def timer_test(s_processing, s_pretreatment, repeat=100):
"""
print minimam, max, average, and unbiased of spend times.
"""
t = _timeit.Timer(s_processing, s_pretreatment)
times = t.repeat(repeat)
l = len(times)
primes_s xs = (head xs) : primes_s (filter (not_dividable (head xs)) xs)
primes = primes_s [2..]