Skip to content

Instantly share code, notes, and snippets.

@ll1l11
ll1l11 / simple.py
Created February 25, 2020 02:54
send mail
import smtplib
from datetime import datetime
mail_user = 'from@qq.com'
mail_password = 'qq mail auth code'
sent_from = f'系统通知 <{mail_user}>'
to = ['to@qq.com']
subject = f'测试邮件 {datetime.now()}'
body = '嘿,天气很好呀?\n\n- You'
@ll1l11
ll1l11 / Dockerfile
Created June 3, 2018 18:08 — forked from patmaddox/Dockerfile
Using personal SSH keys on docker container (OS X)
RUN mkdir ~/.ssh
RUN echo 'IdentityFile ~/.ssh-local/id_rsa' > ~/.ssh/config
@ll1l11
ll1l11 / app.js
Created March 22, 2018 07:17 — forked from lsongdev/app.js
微信小程序 wx.request 封装
App({
/**
* [request description]
* @param {[type]} method [description]
* @param {[type]} url [description]
* @param {[type]} data [description]
* @param {[type]} header [description]
* @return {[type]} [description]
*/
@ll1l11
ll1l11 / dp.py
Created January 16, 2018 17:42 — forked from zed/dp.py
Find height, width of the largest rectangle containing all 0's in the matrix
#!/usr/bin/env python
"""Find height, width of the largest rectangle containing all 0's in the matrix.
The algorithm for `max_size()` is suggested by @j_random_hacker [1].
The algorithm for `max_rectangle_size()` is from [2].
The Python implementation [3] is dual licensed under CC BY-SA 3.0
and ISC license.
[1]: http://stackoverflow.com/questions/2478447/find-largest-rectangle-containing-only-zeros-in-an-nn-binary-matrix#comment5169734_4671342
import string
s = string.printable * 10
with open('big.txt', 'a') as f:
for i in range(1024):
if i % 1024 == 1:
print(i // 1024)
f.write(s)
@ll1l11
ll1l11 / example.conf
Created July 12, 2017 09:21
nginx cors config
server {
server_name example.com;
location / {
proxy_pass http://localhost:5000;
proxy_set_header host $host;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Expose-Headers "ETag, Link";
@ll1l11
ll1l11 / check_internet.sh
Created April 18, 2017 03:07
检查是否能够上网
#!/usr/bin/env bash
HTTP_CODE=$(curl -I -s -w %{http_code} www.baidu.com | head -n 1 | cut -d$' ' -f2 | egrep '^[123]')
if [ -n $HTTP_CODE ]; then
echo "HTTP_CODE: $HTTP_CODE, return"
exit 0
else
sudo ifdown wlan0 && sudo ifup wlan0
exit 0
fi
@ll1l11
ll1l11 / get_ips.py
Created December 16, 2016 09:48
python使用ifconfig获取所有ip
import os
import re
with os.popen('$(which ifconfig)') as f:
content = f.read()
ips = re.findall('inet (?:addr:)?(\d+\.\d+.\d+.\d+)', content)
print(ips)
@ll1l11
ll1l11 / check_port.py
Created December 16, 2016 06:18
扫描局域网开了某个端口(例如22)的机器
# -*- coding: utf-8 -*-
import socket;
from contextlib import closing
socket.setdefaulttimeout(0.5)
import socket
from contextlib import closing
def check_socket(host, port):
@ll1l11
ll1l11 / nginx-cors.conf
Created October 19, 2016 10:44 — forked from sbuzonas/nginx-cors.conf
Nginx CORS maps
map $http_origin $allow_origin {
default "";
"~^https?://(?:[^/]*\.)?(stevebuzonas\.(?:com|local))(?::[0-9]+)?$" "$http_origin";
}
map $request_method $cors_method {
default "allowed";
"OPTIONS" "preflight";
}