使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)就是这样!
| #include <iostream> | |
| using namespace std; | |
| template<typename T> | |
| class Complex { | |
| private: | |
| T m_real; | |
| T m_imag; | |
| public: | |
| Complex<T>(T real=0.0, T imag=0.0) |
| location / { | |
| proxy_redirect off; | |
| proxy_set_header Host $host; | |
| proxy_pass http://ghs.google.com; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| } |
| # - * - coding: UTF-8 - * - | |
| import subprocess | |
| def macosx_set_clipboard(text): | |
| p = subprocess.Popen('pbcopy', stdin=subprocess.PIPE) | |
| p.communicate(text) | |
| def macosx_send_keys(text): | |
| text = text.replace('\\', '\\\\').replace('"', '\\"') |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <CoreServices/CoreServices.h> | |
| #include "directory_icon.h" | |
| int setDirectoryIcon(const char *dirName, const char *iconData, size_t iconSize) | |
| { | |
| const int kResidIcon = -16455; | |
| const OSType kRsrcType = 'icns'; |
| #!/usr/bin/python | |
| # - * - coding: UTF-8 - * - | |
| import cgi | |
| import json | |
| import urllib | |
| import httplib2 | |
| h = httplib2.Http() | |
| query = urllib.urlencode({ |
| CFLAGS=-fextended-identifiers -std=c99 | |
| objects=chinese.ucn.o | |
| target=chinese | |
| .PHONY: all clean | |
| all: $(target) | |
| $(target): $(objects) | |
| $(CC) $< -o $@ |
| <?php | |
| /** | |
| * 检验是否为有效的电子邮件地址 | |
| * | |
| * 根据 http://www.linuxjournal.com/article/9585 编写 | |
| * | |
| * @param string $email | |
| * @return bool | |
| */ |
使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)就是这样!
| <!DOCTYPE HTML> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | |
| <title></title> | |
| <style type="text/css"> | |
| canvas { position: absolute; top: 0; left: 0; } | |
| #c { background: #ccc; } | |
| #ps { position: absolute; top: 0; right: 0; } |
| #!/bin/bash | |
| # 将 DNSPOD 上指定子域名指向当前本机 IP 的脚本 | |
| # | |
| # 依赖: | |
| # urlencode: http://www.shelldorado.com/scripts/cmds/urlencode | |
| # jsawk: https://github.com/micha/jsawk | |
| # 配置信息 | |
| EMAIL="" |