Skip to content

Instantly share code, notes, and snippets.

View taojy123's full-sized avatar

taojy123 taojy123

View GitHub Profile
@taojy123
taojy123 / nginx.conf
Last active June 9, 2017 08:50 — forked from nl5887/nginx.conf
[SNI] OpenResty + MySQL
worker_processes 1;
error_log logs/error.log debug;
daemon off;
events {
worker_connections 1024;
}
@taojy123
taojy123 / str_sub.lua
Created June 11, 2017 12:08
截取中英混合的UTF8字符串
--截取中英混合的UTF8字符串,endIndex可缺省
function SubStringUTF8(str, startIndex, endIndex)
if startIndex < 0 then
startIndex = SubStringGetTotalIndex(str) + startIndex + 1;
end
if endIndex ~= nil and endIndex < 0 then
endIndex = SubStringGetTotalIndex(str) + endIndex + 1;
end
@taojy123
taojy123 / clear.bat
Created August 14, 2017 00:44
删除U盘隐形病毒
attrib -s -h /s /d
pause
del "Microsoft Word.WsF"
del "Microsoft Excel.WsF"
del "*.WsF"
pause
del "*.lnk"
pause
@taojy123
taojy123 / django_send_mail.py
Last active April 23, 2019 07:10
Python 发送邮件
# ----------------- django ---------------------------
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', '[email protected]', ['[email protected]'])
# ----------------- settings.py ----------------------
SERVER_EMAIL = '[email protected]'
EMAIL_HOST = 'smtp.163.com'
EMAIL_PORT = 465 # 25
EMAIL_USE_SSL = True # False
@taojy123
taojy123 / mutex.py
Created November 10, 2017 03:04
线程锁装饰器
import thread
import time
lock = thread.allocate_lock()
def mutex(func):
include world
include image
# 这些是我预先上传的数字图片,在开始先下载下来几个
# 也可以不写这几行,这样在运行的过程中用到是会下载
im_2 = image-url('http://taojy123.cn:2048/2.png')
im_4 = image-url('http://taojy123.cn:2048/4.png')
im_8 = image-url('http://taojy123.cn:2048/8.png')
@taojy123
taojy123 / kmodes.py
Last active March 26, 2018 06:58
K-modes
#!python2
#coding=utf8
import random
class Man(object):
def __init__(self, name, values):
self.name = name
import os
import requests
import BeautifulSoup
root_url = 'http://index-of.es/'
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
}
@taojy123
taojy123 / float.py
Last active August 1, 2018 06:45
python 浮点精度示例
assert 0.1 + 0.2 == 0.30000000000000004
assert 0.3 - 0.2 == 0.09999999999999998
assert 5.06 * 100 == 505.99999999999994
@taojy123
taojy123 / cmd.py
Created October 25, 2018 03:14
python 执行命令行 获取结果
# ============ python2 ====================
import commands
commands.getoutput("ls")
commands.getstatus("ls")  
status, output = commands.getstatusoutput("ls")  
# ============ python3 ====================
from subprocess import Popen, PIPE