Skip to content

Instantly share code, notes, and snippets.

View bwangelme's full-sized avatar
🚀
把 Star 当做收藏在用,点起来很随性。GitHub 全是各种 Tutorial 和 Demo

bwangel bwangelme

🚀
把 Star 当做收藏在用,点起来很随性。GitHub 全是各种 Tutorial 和 Demo
View GitHub Profile
@geoffalday
geoffalday / secretkey.py
Created March 12, 2012 12:28
How to generate a secret key with Python
# How to generate a secret key with Python
# via http://flask.pocoo.org/docs/quickstart/
import os
os.urandom(24)
@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active April 15, 2024 14:27
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/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:
@hSATAC
hSATAC / gist:5343225
Created April 9, 2013 05:38
Http Redirect in Golang
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)
@paulirish
paulirish / gist:5558557
Last active April 18, 2024 14:32
a brief history of detecting local storage

A timeline of the last four years of detecting good old window.localStorage.


Jan Lenhart, bless his heart contributed the first patch for support:

October 2009: 5059daa

@joegoggins
joegoggins / .vimrc
Last active August 4, 2023 08:21
Mac Vim .vimrc file
" 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
@nhoad
nhoad / gist:8966377
Last active March 2, 2023 09:30
Async stdio with asyncio
import os
import asyncio
import sys
from asyncio.streams import StreamWriter, FlowControlMixin
reader, writer = None, None
@asyncio.coroutine
def stdio(loop=None):
@lilydjwg
lilydjwg / lolcat.py
Last active February 4, 2020 12:24
lolcat.py: make rainbows over text
#!/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
@ungoldman
ungoldman / curl_post_json.md
Last active May 2, 2024 15:41
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

在这篇笔记的最前面,我一定要说,网络协议的设计者都是天才

使用SMTP发送邮件其实十分简单,就如同我们和人交谈别无二致。这里我们使用SMTP协议发送一封邮件,小小体会一下网络协议之美。我在这里使用Windows平台上的VS2013 作为编码环境,使用C++,和WinSock中的socket函数通信。

什么是SMTP,用Python中的SMTP模块发送一封邮件

SMTP--Simple Mail Transfer Protocol,简单邮件传输协议。这是一个应用层协议,我们可以使用此协议,发送简单的邮件。SMTP基于TCP协议,在不使用SSL,TLS加密的SMTP协议中,我们默认使用端口号25,在使用SSL\TLS的SMTP协议中,使用端口号465\587。

一次传输邮件的过程,其实就是一次和服务器对话的过程。为了标识这些对话中的各种动作,我们需要使用语言来和服务器沟通。例如客户端发送给服务器一条信息EHLO(Hello),服务器就知道这个客户端要给我发邮件了,这类似于我们人与人之间打招呼,我和服务器说:我要发邮件了!!!,于是服务器知道我要发邮件了,会给我回答一声:发吧。在SMTP协议中,也是同样,协议会返回一个标识码,来告诉我们服务器现在的状态,在我们打招呼之后,服务器一般会返回250,这告诉我们:“一切OK,放马过来吧”。

@mwhittaker
mwhittaker / client.go
Last active November 16, 2023 06:01
Go Echo Server and Client
package main
import (
"fmt"
"net"
"os"
"time"
)
const (