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
@bwangelme
bwangelme / metaclass.py
Created January 5, 2017 13:07
Metaclass 黑魔法
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
这个C元类的功能就是在准备类的命名空间的时候,
将其父类的非私有成员(不以_开头的成员)添加到
这个命名空间中,然后在创建这个类的时候,再把父类的非私有成员给删除掉。
"""
import os
@kagamimoe
kagamimoe / gist:42a3f1b8ff1dc60304b43e9bc64409cf
Last active July 30, 2017 05:17
a python crawler to find the job information
# -*- coding: utf-8 -*-
import urllib2
import sys, smtplib, poplib
from email.mime.text import MIMEText
reload(sys)
sys.setdefaultencoding('utf-8')
from bs4 import BeautifulSoup
@bwangelme
bwangelme / [ubuntu 16.04 & deepin 15.2 Desktop]gvim compile script
Last active September 25, 2017 14:03
gvim compile script on ubuntu 16.04, add python2/3, ruby, lua, gui support
#!/bin/bash
# checking for xmkmf... no
# checking for X... (cached) no
# checking if X11 header files can be found... no
# checking --enable-gui argument... no GUI support
# checking for X11/SM/SMlib.h... (cached) no
## if you meet the above situation on ubuntu 16.04, please follow the following cmd
# sudo apt-get install xorg-dev
#!/bin/bash
#
# Author: bwangel<bwangel.me@gmail.com>
# Date:Oct,10,2017 14:16
LOG_FILE="./2017_10_10uwsgi-webapp.log"
echo "" | awk '
END {
FMT = "%-33s\t%-5s\t%-15s%-10s\n"
@bwangelme
bwangelme / order1.conf
Last active October 16, 2017 15:07
agentzh 的 Nginx 教程的学习笔记
server {
listen 9091;
# Nginx 请求执行阶段
# 1. rewrite
# set 指令在 rewrite 阶段执行。
# 2. access
# 3. content
# echo 指令在 content 阶段执行。
location /test {
@bwangelme
bwangelme / colors.sh
Created February 10, 2017 09:05
bash 色表
#!/bin/bash
#
# Author: bwangel<bwangel.me@gmail.com>
# Date: Feb,10,2017 16:55
for C in {0..255}; do
tput setaf $((255-${C}))
tput setab $C
echo -n "$C "
done
import itertools
ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ALPHABET_LEN = len(ALPHABET)
ALPHABET_INDEX = {c: i for i, c in enumerate(ALPHABET)}
def a2n(letter):
return ALPHABET_INDEX[letter]

深入Go并发编程研讨课

Go提供了我们便利的进行并发编程的工具、方法和同步原语,同时也提供给我们诸多的犯错的机会,也就是俗称的“坑”。即使是顶级Go开发的项目,比如Docker、Kubernetes、gRPC、etcd, 都是有经验丰富的Go开发专家锁开发,也踩过不少的并发的坑,而且依然源源不断的继续踩着,即便是标准库也是这样。

分析和总结并发编程中的陷阱,避免重复踩在别人的坑中,正式本次培训课的重要内容。只有深入了解并发原语的实现,全面了解它们的特性和限制场景,注意它们的局限和容易踩的坑,才能提高我们的并发编程的能力。通过了解和学习其他人的经验和贡献的项目和库,我们可以更好的扩展我们的视野,避免重复的造轮子,或者说我们可以制作更好的轮子。

语言的内存模型定义了对变量的读写的可见性,可以清晰而准确读写事件的happen before关系。对于我们,可以很好地分析和编排goroutine的运行,避免数据的竞争和不一致的问题。

通过本次课程,你可以:

@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
[V=browser-hello.mp4] Hi, I'm Matthew from OpenResty Inc. In this video, I'll demonstrate how to implement a "hello world" HTTP interface using OpenResty.
First of all, we make sure we are using OpenResty's nginx.
[delay=0] $ export PATH=/usr/local/openresty/nginx/sbin:$PATH
$ which nginx
[S] It's usually in this path.
And then we go to the home directory.