Skip to content

Instantly share code, notes, and snippets.

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

yassu yassu

💭
👨‍💼
  • JP
View GitHub Profile
primes_s xs = (head xs) : primes_s (filter (not_dividable (head xs)) xs)
primes = primes_s [2..]
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)
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')
@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 '
from random import randint
from inspect import isfunction
def get_random():
return randint(0, 10**10)
class Cacher:
pass
DEFAULT_CACHER = Cacher()
@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)
@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 / anime.py
Created October 16, 2014 10:42
only one graph by matplotlib
import pylab as p
p.ion()
x = p.arange(0, 2*p.pi, 0.01)
a = 10
curve = lambda t: (t, p.sin(x+t/10.0))
line, = p.plot(x, p.sin(x))
@yassu
yassu / analyse.py
Created October 29, 2014 09:55
analyse_twit
from datetime import datetime
from math import sqrt
from json import load as _json_load
import numpy as np
from scipy import stats # for regression line
import pylab
def get_datetime(s_date):
year, month ,day = s_date.split('/')
@yassu
yassu / vimrc
Created January 11, 2015 01:18
vimrc file for prezen of 2014-1-11
""" Plugins {{{
"" NeoBundle {{{
set nocompatible " Be iMproved
filetype off " Required!
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/.vim/bundle/'))