718
- Java
- Python
- Go
- Review-1 week
- Review-2 weeks
| https://go.dev/play/p/_KTpGn1q_7j |
| def fib(N): | |
| if N == 0: | |
| return 0 | |
| if N == 1: | |
| return 1 | |
| return fib(N - 1) + fib(N - 2) | |
| if __name__ == '__main__': | |
| print(fib(10)) |
718
| // The classic AJAX call - dispatch before the request, and after it comes back | |
| function myThunkActionCreator(someValue) { | |
| return (dispatch, getState) => { | |
| dispatch({type : "REQUEST_STARTED"}); | |
| myAjaxLib.post("/someEndpoint", {data : someValue}) | |
| .then( | |
| response => dispatch({type : "REQUEST_SUCCEEDED", payload : response}), | |
| error => dispatch({type : "REQUEST_FAILED", error : error}) | |
| ); |
| # 有一个装饰器 @require_user,这是对用户进行的权限管理。试想一下,一名用户可能会有多个角色 | |
| # 如果对这些角色每个都定义一个装饰器,就会造成太多的冗余和重复。在这种情况下我们来看看作者是怎么做的: | |
| # 定义了一个基本类 | |
| def __init__(self, role): | |
| self.role = role | |
| def __call__(self, method): | |
| @functools.wraps(method) | |
| def wrapper(*args, **kwargs): | |
| if not g.user: |
| #!/bin/bash | |
| # This is the script for the Linux assingment2 | |
| # Team Members(Sorted by Alphabet order of First Name) | |
| # Haozhou Wang A00431268 | |
| # Naisi Zhen A00431605 | |
| # Rishi Karki A00432524 | |
| # 1,2,3,6 are exit signals | |
| trap clean_docker 1 2 3 6 |
##分布式系统(Distributed System)资料
介绍:这是一篇介绍在动态网络里面实现分布式系统重构的paper.论文的作者(导师)是MIT读博的时候是做分布式系统的研究的,现在在NUS带学生,不仅仅是分布式系统,还有无线网络.如果感兴趣可以去他的主页了解.
| from random import randint | |
| def cal(): | |
| all_time = [] | |
| cash,count = 1,0 | |
| target = 100000 | |
| for i in xrange(0,10): | |
| while True: | |
| cash = cash* 2 if randint(0,1)==0 else 1 | |
| count += 1 |
| # -*- coding:utf-8 -*- | |
| """ | |
| 对某个目录下的文件求 md5 值 | |
| """ | |
| import os | |
| import hashlib | |
| import time | |
| from functools import reduce |
| /* | |
| sublime-imfix.c | |
| Use LD_PRELOAD to interpose some function to fix sublime input method support for linux. | |
| By Cjacker Huang <jianzhong.huang at i-soft.com.cn> | |
| gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC | |
| LD_PRELOAD=./libsublime-imfix.so sublime_text | |
| */ | |
| #include <gtk/gtk.h> | |
| #include <gdk/gdkx.h> |