Skip to content

Instantly share code, notes, and snippets.

yszou /
Created Apr 29, 2022
py code can run as micropython
# -*- coding: utf-8 -*-
import random
import json
import js
class RandomData():
def __init__(self, rows=5, dimensions=1, metrics=2): = []
# -*- coding: utf-8 -*-
todo = [
{"a": 1, "b": 1},
{"a": 2, "b": 2},
{"a": 1, "b": 1},
{"a": 0, "b": 1},
{"a": 2, "b": 2},
{"a": 0, "b": 2},
{"a": 2, "b": 2},
yszou / deriv-middle-parentheses.scm
Created Jul 30, 2019
View deriv-middle-parentheses.scm
(define (=number? a v) (and (number? a) (= a v)))
(define (variable? e) (symbol? e))
(define (sum? e)
(and (pair? e) (eq? (cadr e) '+)))
(define (sum-a e) (car e))
(define (sum-b e)
(if (= (length e) 3) (caddr e) (cdr (cdr e))))
(define (make-sum a b)
(cond ((=number? a 0) b)
yszou / deriv.scm
Created Jul 29, 2019
View deriv.scm
(define (variable? x) (symbol? x))
(define (same-variable? a b) (and (variable? a) (variable? b) (eq? a b)))
(define (sum? e) (and (pair? e) (eq? (car e) '+)))
(define (added e) (cadr e))
(define (augend e)
(if (= (length e) 3) (caddr e) (append '(+) (cdr (cdr e)))))
(define (product? e) (and (pair? e) (eq? (car e) '*)))
(define (multiplier e) (cadr e))
yszou / fib.scm
Last active Jul 28, 2019
View fib.scm
(define (vector+vector a b)
(define (vector+vector-iter a b value)
(if (null? a) (reverse value)
(vector+vector-iter (cdr a) (cdr b) (cons (+ (car a) (car b)) value) )))
(vector+vector-iter a b '()))
(display "vector+vector: ")
(display (vector+vector '(1 2 3) '(4 5 6)))
(display "\n")
yszou / queen.scm
Created Jul 28, 2019
View queen.scm
(define (range a b)
(define (iter v current)
(if (< v a) current
(iter (- v 1) (cons v current))))
(iter (- b 1) '()))
(define (accmulate f init seq)
(if (null? seq) init
(accmulate f (f (car seq) init) (cdr seq))))
View angularjs
<!DOCTYPE html>
<meta charset="utf-8" />
<script src="" type="text/javascript"></script>
<script src="" type="text/javascript"></script>
<form name="test_form" ng-controller="TestCtrl" ng-init="o=[0,1,2,3]; a=o[1];">
yszou /
Created Jun 20, 2014
# -*- coding: utf-8 -*-
from hashlib import md5
from urllib import urlencode
class Alipay(object):
yszou /
Created Dec 9, 2013
# -*- coding: utf-8 -*-
import sys, os, re
from lib.eml_parse import parse
from lib.smtpclient import SMTPClient
import tempfile
import email.utils
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
yszou /
Created Dec 9, 2013
# -*- coding: utf-8 -*-
import rsa
import re
import time
import json
import traceback
from urllib import urlencode, unquote, quote
from Cookie import SimpleCookie
import tornado