This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RUN mkdir ~/.ssh | |
| RUN echo 'IdentityFile ~/.ssh-local/id_rsa' > ~/.ssh/config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App({ | |
| /** | |
| * [request description] | |
| * @param {[type]} method [description] | |
| * @param {[type]} url [description] | |
| * @param {[type]} data [description] | |
| * @param {[type]} header [description] | |
| * @return {[type]} [description] | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import socket; | |
| from contextlib import closing | |
| socket.setdefaulttimeout(0.5) | |
| import socket | |
| from contextlib import closing | |
| def check_socket(host, port): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| map $http_origin $allow_origin { | |
| default ""; | |
| "~^https?://(?:[^/]*\.)?(stevebuzonas\.(?:com|local))(?::[0-9]+)?$" "$http_origin"; | |
| } | |
| map $request_method $cors_method { | |
| default "allowed"; | |
| "OPTIONS" "preflight"; | |
| } |