Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
aoeuidht / gist:5723282
Last active December 18, 2015 04:09
exericse 1.29
(defun sum (term a next b)
(if (> a b)
0
(+ (funcall term a)
(sum term (funcall next a) next b))))
(defun cube (x) (* x x x))
(defun integral (f a b dx)
(defun add-dx (x) (+ x dx))
(* (sum f
(+ a (/ dx 2.0))
(defun cube (x) (* x x x))
(defun sum-iter (term a next b)
(defun iter (a result)
(if (> a b)
result
(iter (funcall next a) (+ result (funcall term a)))))
(iter a 0))
(defun simp-integral (f a b n)
@aoeuidht
aoeuidht / gist:5729827
Created June 7, 2013 14:53
exericse 1.31
(defun product (term a next b)
(if (> a b)
1
(* (funcall term a)
(product term (funcall next a) next b))))
(defun product-iter (term a next b)
(defun iter (a result)
(if (> a b)
result
@aoeuidht
aoeuidht / gist:5730331
Created June 7, 2013 15:58
exericse 1.32
(defun accumulate (combiner null-value term a next b)
(if (> a b)
null-value
(funcall combiner
(funcall term a)
(accumulate combiner null-value term (funcall next a) next b)))
)
(defun accumulate-iter (combiner null-value term a next b)
(defun iter (a result)
(if (> a b)
# -*- coding: utf-8 -*-
import socket
import select
if __name__ == '__main__':
addr = ('127.0.0.1', 8004)
epoll = select.epoll()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(addr)
s.setblocking(0)
# -*- coding: utf-8 -*-
import socket
import select
if __name__ == '__main__':
addr = ('127.0.0.1', 8004)
max_sockets = 3
max_requests = 100
request_cnt = 0
sockets = {}
if isinstance(c_content, (str, unicode)):
uc = c_content.encode('utf8')
cnt['content'] = json.loads(uc)
@aoeuidht
aoeuidht / gist:8115186
Last active January 1, 2016 07:59
human couldn't understood php.
<?php
function test_foreach(&$tgt)
{
foreach ($tgt as &$_t)
{
$_t['v'] = $_t['v'] + 1;
}
foreach ($tgt as $_t)
@aoeuidht
aoeuidht / gist:8932059
Created February 11, 2014 09:55
the new cc protocol
{
"result": {
"err_no": 0
},
"content": [
{
"type": "log",
"content": {
"enable": 1,
"size": 3072
@aoeuidht
aoeuidht / index.jade
Created February 17, 2014 10:12 — forked from zhuangya/index.jade
.big-wrapper
.notice
pre
code vertical-align: middle
br
| for IE 7+
style
:stylus
.big-wrapper