###haskell 基本类型,bool(True/False),list[],tuple(),int,Integer,Double,char'' ,string"",function(\x->x+1)
- wiki
| class SimpleOwnerAuthorization(Authorization): | |
| ''' | |
| Does what it says: filters objects by their owner (user). | |
| ''' | |
| def __init__(self, ownerfilter=None, *args, **kwargs): | |
| self.ownerfilter = ownerfilter # the user field i.e. 'person__user' | |
| def is_authorized(self, request, object=None): | |
| return True # for now |
| # create stub, then run flask app in tornado on port 5000 (perhaps with supervisord config below http://supervisord.org/index.html) | |
| #!/usr/bin/env python | |
| from tornado.wsgi import WSGIContainer | |
| from tornado.httpserver import HTTPServer | |
| from tornado.ioloop import IOLoop | |
| from myflaskapp import app | |
| http_server = HTTPServer(WSGIContainer(app)) |
| # You will need to make this file executable (chmod u+x) and run it with sudo | |
| apt-get -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc default-jdk | |
| mkdir -p /src/erlang | |
| cd /src/erlang | |
| wget http://www.erlang.org/download/otp_src_R15B.tar.gz | |
| tar -xvzf otp_src_R15B.tar.gz | |
| chmod -R 777 otp_src_R15B | |
| cd otp_src_R15B | |
| ./configure | |
| make |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # ---------------------------------------------------- | |
| import redis, random | |
| POOL = redis.ConnectionPool(host='localhost', port=6379, db=0) | |
| NUSERS = 10000 | |
| NTAGS = 500 |
| // Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core? | |
| L.TileLayer.Common = L.TileLayer.extend({ | |
| initialize: function (options) { | |
| L.TileLayer.prototype.initialize.call(this, this.url, options); | |
| } | |
| }); | |
| (function () { | |
| #!/usr/bin/env python | |
| # -*- coding: UTF-8 -*- | |
| import sched, time | |
| from threading import Thread, Timer | |
| import subprocess | |
| s = sched.scheduler(time.time, time.sleep) | |
| class Job(Thread): |
| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| <html> <head> | |
| <title>Cowboy test</title> | |
| </head> | |
| <body> | |
| <h1>Woot!</h1> | |
| <hr> |
| (function() { | |
| var path = require('path'), fs = require('fs'); | |
| function walk(uri,filter,tree) { | |
| var node = { | |
| name : null, | |
| children : [], | |
| pNode : null, | |
| }; | |
使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)就是这样!