A timeline of the last four years of detecting good old window.localStorage.
October 2009: 5059daa
| # How to generate a secret key with Python | |
| # via http://flask.pocoo.org/docs/quickstart/ | |
| import os | |
| os.urandom(24) |
| #!/usr/bin/env python | |
| """ | |
| Very simple HTTP server in python (Updated for Python 3.7) | |
| Usage: | |
| ./dummy-web-server.py -h | |
| ./dummy-web-server.py -l localhost -p 8000 | |
| Send a GET request: |
| package main | |
| import ( | |
| "log" | |
| "net/http" | |
| ) | |
| func redirect(w http.ResponseWriter, r *http.Request) { | |
| http.Redirect(w, r, "http://www.google.com", 301) |
A timeline of the last four years of detecting good old window.localStorage.
October 2009: 5059daa
| " Use Vim settings, rather then Vi settings (much better!). | |
| " This must be first, because it changes other options as a side effect. | |
| set nocompatible | |
| " ================ General Config ==================== | |
| set number "Line numbers are good | |
| set backspace=indent,eol,start "Allow backspace in insert mode | |
| set history=1000 "Store lots of :cmdline history | |
| set showcmd "Show incomplete cmds down the bottom |
| import os | |
| import asyncio | |
| import sys | |
| from asyncio.streams import StreamWriter, FlowControlMixin | |
| reader, writer = None, None | |
| @asyncio.coroutine | |
| def stdio(loop=None): |
| #!/usr/bin/env python3 | |
| # inspired by https://github.com/busyloop/lolcat | |
| import sys | |
| import re | |
| import os | |
| from math import ceil | |
| from colorsys import hsv_to_rgb | |
| from unicodedata import east_asian_width |
在这篇笔记的最前面,我一定要说,网络协议的设计者都是天才。
使用SMTP发送邮件其实十分简单,就如同我们和人交谈别无二致。这里我们使用SMTP协议发送一封邮件,小小体会一下网络协议之美。我在这里使用Windows平台上的VS2013 作为编码环境,使用C++,和WinSock中的socket函数通信。
SMTP--Simple Mail Transfer Protocol,简单邮件传输协议。这是一个应用层协议,我们可以使用此协议,发送简单的邮件。SMTP基于TCP协议,在不使用SSL,TLS加密的SMTP协议中,我们默认使用端口号25,在使用SSL\TLS的SMTP协议中,使用端口号465\587。
一次传输邮件的过程,其实就是一次和服务器对话的过程。为了标识这些对话中的各种动作,我们需要使用语言来和服务器沟通。例如客户端发送给服务器一条信息EHLO(Hello),服务器就知道这个客户端要给我发邮件了,这类似于我们人与人之间打招呼,我和服务器说:我要发邮件了!!!,于是服务器知道我要发邮件了,会给我回答一声:发吧。在SMTP协议中,也是同样,协议会返回一个标识码,来告诉我们服务器现在的状态,在我们打招呼之后,服务器一般会返回250,这告诉我们:“一切OK,放马过来吧”。
| package main | |
| import ( | |
| "fmt" | |
| "net" | |
| "os" | |
| "time" | |
| ) | |
| const ( |