I hereby claim:
- I am sunliwen on github.
- I am sunliwen (https://keybase.io/sunliwen) on keybase.
- I have a public key ASABIfKL8I_F9v4CepwlSJS9Fo8No_qdVEuOx9tQxEIt6wo
To claim this, I am signing this object:
# Install pip install cryptography, path issue with openssl/aes.h will occur. The reason is Apple deprecated openssl and the compiler can't find the one installed by homebrew. | |
# So the following line will help. | |
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography |
#!/usr/bin/env python3 | |
# Ported to Python 3 by Telmo "Trooper" (telmo.trooper@gmail.com) | |
# | |
# Original code from: | |
# http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# https://gist.github.com/dergachev/7028596 | |
# | |
# To generate a certificate use: | |
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes |
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --unsafely-treat-insecure-origin-as-secure=http://0.0.0.0:8000 |
# refs: https://stackoverflow.com/questions/51125013/how-can-i-install-a-previous-version-of-python-3-in-macos-using-homebrew/51125014#51125014 | |
brew uninstall --ignore-dependencies python3 | |
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb | |
brew switch python 3.6.5_1 | |
I hereby claim:
To claim this, I am signing this object:
import os, sys | |
import smtplib | |
from smtplib import SMTP_SSL | |
from email.header import Header | |
from email.mime.text import MIMEText | |
mailInfo = { | |
"from":"user@domain.com", | |
"to":"someone@anotherdomain.com", | |
"hostname":"smtp.exmail.qq.com", |
function getQueryParam(key) { | |
key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars | |
var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)")); | |
return match && decodeURIComponent(match[1].replace(/\+/g, " ")); | |
} | |
// ?id=123 | |
// getQueryParam('id') --> 123 |
""" | |
Following error will occur if there's custom field. | |
``` | |
! Cannot freeze field 'myapp.mymodel.entity_type' | |
! (this field has class myapp.fields.EntityTypeField) | |
! South cannot introspect some fields; this is probably because they are custom | |
! fields. If they worked in 0.6 or below, this is because we have removed the | |
! models parser (it often broke things). |
# `pip install shortuuid` | |
import uuid | |
long = uuid.uuid5(namespace=uuid.NAMESPACE_URL, name="http://example.com") | |
print long # UUID('8c9ddcb0-8084-5a7f-a988-1095ab18b5df') | |
import shortuuid | |
short = shortuuid.uuid(name="http://example.com") | |
print short # 'c8sh5y9hdSMS6zVnrvf53T' |
# Ubuntu upstart file at /etc/init/mongodb.conf | |
limit nofile 32768 32768 | |
kill timeout 300 # wait 300s between SIGTERM and SIGKILL. | |
pre-start script | |
mkdir -p /data/mongodb &> /dev/null | |
mkdir -p /data/logs/mongo &> /dev/null | |
chown mongodb:nogroup /data/mongodb &> /dev/null |