Skip to content

Instantly share code, notes, and snippets.

View Maecenas's full-sized avatar
👋
Hi

Xiang Li Maecenas

👋
Hi
View GitHub Profile
@Maecenas
Maecenas / Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015.md
Last active March 11, 2024 05:49
Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015. Distillation of knowledge gained from a decade of Python consulting, Python training, code reviews, and serving as a core developer. (https://www.youtube.com/watch?v=wf-BqAjZb8M) <br/> https://www.shawnxli.com/posts/beyond-pep-8/

Raymond Hettinger's professional at doing code review and architecture review

P vs. NP. Pythonic vs. Non-Pythonic.

How to make use of PEP 8

  1. Golden rule of PEP-8: PEP-8 onto yourself. PEP 8 is style guide, not a law book.
  2. Care about intelligibility, not simply visually better
  3. Transforming (Java) API to pythonic ones

Why not PEP 8

class classproperty(property):
def __get__(self, cls, owner):
return classmethod(self.fget).__get__(None, owner)()
class classproperty:
"""
Same as property(), but passes obj.__class__ instead of obj to fget/fset/fdel.
Original code for property emulation:
https://docs.python.org/3.5/howto/descriptor.html#properties
考满分阅读机经200篇高频题题号(截止2018.02.02)
2018-02-07 考满分 张巍老师
高频题题号(至少在考场中出现过两次的题目)
问题:为什么高频题更为重要?
答案:ETS出的题目不是每个题都有很好的区分度,在长期的测试过程中,ETS会选择一些区分度比较好的题目来多次重复考察,而有些题可能在考场出现过一次之后就可能再也不会出现了!
考满分All In One课程和考前冲刺班主要讲解的就是以下的高频题~
题号
@Maecenas
Maecenas / Fix: PKIX Path Building Failed_Way2.md
Last active March 23, 2018 10:31
Java/JVM SSL/TLS/HTTPS Connection: PKIX Path Building Failed

Fix: PKIX Path Building Failed_Way2

Solution

Before calling Java Web Serivce:

trustAllHttpsCertificates();  
HttpsURLConnection.setDefaultHostnameVerifier(hv);  
@Maecenas
Maecenas / Dockerfile-COPY.go
Created April 25, 2018 12:11
Dockerfile best practices
# Dockerfile-1
FROM golang:1.9-alpine
RUN apk --no-cache add git ca-certificates
WORKDIR /go/src/github.com/go/helloworld/
COPY app.go .
RUN go get -d -v github.com/go-sql-driver/mysql \
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . \
&& cp /go/src/github.com/go/helloworld/app /root
WORKDIR /root/
CMD ["./app"]
@Maecenas
Maecenas / python_ds.py
Created May 2, 2018 08:40
Data Structure in Python
# coding: utf-8
u"""
线性数据结构, 栈, 队列, deques, 容器结构, 数据项之间存在相对的位置
"""
class Stack(object):
u"""
栈 先进后出
@Maecenas
Maecenas / data_processing.py
Last active May 3, 2018 02:25
Data Processing Using Python
# 时间索引
>>> import pandas as pd
>>> index = pd.date_range('20160503', periods=5)
>>> index
DatetimeIndex(['2016-05-03', '2016-05-04', '2016-05-05', '2016-05-06',
'2016-05-07'],
dtype='datetime64[ns]', freq='D')
# 数据显示
@Maecenas
Maecenas / README.md
Created May 10, 2018 10:26
Generate SSL Cert
$ openssl s_client -connect gitlab.miotech.com:443 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt
$ echo "yes" | keytool -import -alias MTGitlab -keystore /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts -file /root/public.crt -storepass changeit
@Maecenas
Maecenas / README.md
Created May 10, 2018 10:52
Remove .DS_Store from Git commit history
git filter-branch -f --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch /.DS_Store' --tag-name-filter cat -- --all

find . -name ".DS_Store" -print0 | xargs -0 rm -rf
@Maecenas
Maecenas / app.py
Created June 23, 2018 13:42
TimedRotatingLogger
#!/usr/bin/env python
# coding: utf-8
import logging.config
from logging.handlers import TimedRotatingFileHandler
from flask import Flask, request
app = Flask(__name__)
app.secret_key = "ecret_key"