Skip to content

Instantly share code, notes, and snippets.

View iximiuz's full-sized avatar
🪲

Ivan Velichko iximiuz

🪲
View GitHub Profile
@iximiuz
iximiuz / delayserver.py
Created March 25, 2016 11:41
Simple async HTTP server to emulate long request processing
import sys
from asyncio import coroutine, sleep
from aiohttp import web
@coroutine
def handle(request):
seconds = float(request.match_info.get('seconds', 1))
yield from sleep(seconds)
text = "You've been waiting for {} seconds".format(seconds)
return web.Response(body=text.encode('utf-8'))
@iximiuz
iximiuz / scheme::sum_of_squares.scm
Last active August 29, 2015 14:02
Sum of squares of two biggest numbers (SICP excercise)
; pen test on functional programming
(define (min-2 a b) (if (> a b) b a))
(define (min-3 a b c) (min-2 (min-2 a b) (min-2 b c)))
(define (sq x) (* x x))
(define (foo a b c) (cond ((= a (min-3 a b c)) (+ (sq b) (sq c)))
((= b (min-3 a b c)) (+ (sq a) (sq c)))
(else (+ (sq a) (sq b)))))