Skip to content

Instantly share code, notes, and snippets.

@youqingkui
youqingkui / python
Created July 5, 2018 14:19 — forked from 582033/python
树莓派获取[cpu温度/cpu使用率/内存空闲率]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
显示树莓派cpu温度、使用率及内存使用率
'''
import os
def show_temp():
file = open("/sys/class/thermal/thermal_zone0/temp")
import cv2
import urllib
import numpy as np
stream=urllib.urlopen('http://192.168.31.249:8080/video')
bytes=''
while True:
bytes+=stream.read(1024)
a = bytes.find('\xff\xd8')
b = bytes.find('\xff\xd9')
@youqingkui
youqingkui / log_test11.py
Created January 16, 2018 03:21 — forked from anonymous/log_test11.py
Test script showing usage of a buffering SMTP handler.
#!/usr/bin/env python
#
# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
@youqingkui
youqingkui / hd_info.py
Last active November 14, 2017 04:15
使用Python查看磁盘大小信息
import os
def disk_stat(folder):
"""
查看文件夹占用磁盘信息
:param folder: 文件夹路径
:return:
"""
hd={}
@youqingkui
youqingkui / centos_python.sh
Created March 24, 2017 21:42 — forked from selfboot/centos_python.sh
CentOS 6.8: Install Python 2.7.10, pip, virtualenv, and virtualenvwrapper on CentOS
#!/bin/bash
# According to:
# How To Set Up Python 2.7.6 and 3.3.3 on CentOS 6.4
# https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4
yum -y update
yum groupinstall -y 'development tools'
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
yum install xz-libs
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
2017年3月16日 by Ron
我是来自AWS 广东社区微信2群的Ron.第一次去参加AWS分享会的时候,第一个上来的就是关于Lambda的.但当时我听完后.
觉得这东西耦合度太高,不好.就一直没在去深入了解.那一次技术分享会,还有卓动--张穗文先生分享的Kinesis + RedShift做
用户日志分析,和有米科技的实时日志分析,那个时候真的感叹跟AWS相见恨晚.他们两分享的东西都非常棒,直接驱使我来后自己
去尝试开发Kinesis,SQS等.总体来说,AWS组件很多.但我毕竟刚接触没多久,所以很多AWS的组件和相关概念都还很陌生,
或者说根本就不知道是什么东西.以下在阐释的时候,如有偏差或者错误,欢迎拍砖(我Email: luodm03@qq.com)
在这过去的半年多时间里.所有广州社区的分享会,我都去了.最近一次正好听到胖虎的Lambda的分享会.
回来的路上我已经满脑子的开始想我最近的在做的一个东西,是否能用Lambda来实现.
@youqingkui
youqingkui / tree.md
Created November 22, 2016 08:09 — forked from upsuper/tree.md
一行 Python 实现树

一行 Python 实现树

使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:

def tree(): return defaultdict(tree)

就是这样!

#encoding=utf-8
'''
演示如何多进程的使用gevent,
1、gevent和multiprocessing组合使用会有很多问题,
所以多进程直接用subprocess.Popen,进程间不通过fork共享
任何数据,完全独立运行,并通过socket通信
2、进程间同步不能用multiprocessing.Event,
因为wait()的时候会阻塞住线程,其它协程的代码无法执行,也
不能使用gevent.event.Event(),因为它通过multiprocessing.Process
共享到子进程后,在父进程set(),子进程wait()是不会收到信号的
@youqingkui
youqingkui / PySched.py
Created August 3, 2016 02:07 — forked from rswofxd/PySched.py
Python:任务调度,定时执行
#coding=utf-8
import time
import sched
import os
import threading
"""
sched模块,准确的说,它是一个调度(延时处理机制),每次想要定时执行某任务都必须写入一个调度。
使用步骤如下:
(1)生成调度器:
s = sched.scheduler(time.time,time.sleep)
@youqingkui
youqingkui / flask-mail-qq.py
Created February 17, 2016 07:35 — forked from binderclip/flask-mail-qq.py
用 Flask-Mail 通过 QQ 邮箱发送邮件
from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
app.config.update(
#EMAIL SETTINGS
MAIL_SERVER='smtp.qq.com',
MAIL_PORT=465,
MAIL_USE_SSL=True,