使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)就是这样!
| $ sudo dmidecode | |
| # dmidecode 2.12 | |
| # SMBIOS entry point at 0x000f0000 | |
| SMBIOS 2.8 present. | |
| <SNIP> | |
| Handle 0x0000, DMI type 0, 24 bytes | |
| BIOS Information |
使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)就是这样!
| function smoothScroll(el, to, duration) { | |
| if (duration < 0) { | |
| return; | |
| } | |
| var difference = to - $(window).scrollTop(); | |
| var perTick = difference / duration * 10; | |
| this.scrollToTimerCache = setTimeout(function() { | |
| if (!isNaN(parseInt(perTick, 10))) { | |
| window.scrollTo(0, $(window).scrollTop() + perTick); | |
| smoothScroll(el, to, duration - 10); |
| Python Cheatsheet | |
| ================= | |
| ################################ Input & Output ############################### | |
| name = input('please enter your name: ') | |
| print('hello,', name) | |
| ageStr = input('please enter your age: ') | |
| age = int(ageStr) |
| import jinja2 | |
| from flask import Flask, render_template, request, redirect, url_for | |
| from flask.ext.sqlalchemy import SQLAlchemy | |
| from . import formatting | |
| from .config import get_config | |
| db = SQLAlchemy() |
| # add to .bashrc | |
| # source .bashrc | |
| if [ "$TERM" == "xterm" ]; then | |
| export TERM=xterm-256color | |
| fi |
| # add to .bashrc | |
| # source .bashrc | |
| if [ "$TERM" == "xterm" ]; then | |
| export TERM=xterm-256color | |
| fi |
| <template> | |
| <div class="hello"> | |
| <div><p>Hello Components</p></div> | |
| <div> | |
| {{count}} | |
| </div> | |
| <div> | |
| <button @click="increment">Inc</button> | |
| <button @click="decrement">Dec</button> | |
| </div> |
| worker_processes 1; | |
| user mark24 mark24; # <-- | |
| # 'user nobody nobody;' for systems with 'nobody' as a group instead | |
| pid /tmp/nginx.pid; | |
| error_log /tmp/nginx.error.log; | |
| events { | |
| worker_connections 1024; # increase if you have lots of clients | |
| accept_mutex off; # set to 'on' if nginx worker_processes > 1 |