Skip to content

Instantly share code, notes, and snippets.

View sincerefly's full-sized avatar
🎯
Focusing

东东 sincerefly

🎯
Focusing
View GitHub Profile
@sincerefly
sincerefly / global_flag.py
Created July 28, 2017 02:43
用于跨模块共享全局变量的包
import sys
class global_flag(object):
def __init__(self):
self.flag_value = False
def get(self):
return self.flag_value
def change(self):
self.flag_value = not self.flag_value
@sincerefly
sincerefly / record_bsdiff_memory.py
Created July 28, 2017 02:39
用于测试记录bsdiff内存占用的python脚本
#!/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
from threading import Thread
import subprocess
import psutil
import time
import os
@sincerefly
sincerefly / get_weather2.py
Created November 4, 2016 04:49
获取天气数据(2)
#!usr/bin/python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
import json
def get_html(url , data = None):
r = requests.get(url, timeout=10)
@sincerefly
sincerefly / get_weather.py
Created November 4, 2016 04:47
获取天气数据(1)
#!usr/bin/python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
def get_html(url , data = None):
r = requests.get(url, timeout=10)
@sincerefly
sincerefly / whereismouse.py
Created August 25, 2016 07:39
鼠标在哪里小游戏(www.3366.com/flash/1000239.shtml) 辅助
#!/bin/env python
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from PIL import Image
import numpy as np
import time
import cv2
@sincerefly
sincerefly / python-qun-people
Created May 18, 2016 10:01
获取QQ群的QQ昵称和QQ号对应关系 记得替换QQ号,QQ密码,QQ群号
#!/bin/env python
# -*- coding:utf-8 -*-
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
driver = webdriver.Chrome()
WAIT_TIME = 30
@sincerefly
sincerefly / python-qqvote
Created May 18, 2016 09:37
获取QQ群投票信息(需要自己在群中)
#!/bin/env python
# -*- coding:utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup
import time
presets = [
{"key":"1080 x 1920","name":"Nexus 5 Portrait","width":1080,"height":1920},
@sincerefly
sincerefly / nvm root find npm
Created January 23, 2016 08:05
使用nvm管理node,npm后当需要在sudo情况下安装的时候设置~/.profile
#modify ~/.profile
alias sudo='sudo env PATH=$PATH:$NVM_BIN'
a:link,a:visited{
font-weight: bold;
color: darkgray;
text-align: center;
padding: 6px;
text-decoration: none;
}
a:hover,a:active{
color: dimgray;
}
@sincerefly
sincerefly / pythonic
Created June 3, 2015 14:10
获取字符串中重复出现的字符个数
def duplicate_count(s):
return len([c for c in set(s.lower()) if s.lower().count(c)>1])
#test.assert_equals(duplicate_count("abcde"), 0)
#test.assert_equals(duplicate_count(""), 0)
#test.assert_equals(duplicate_count("abcdea"), 1)
#test.assert_equals(duplicate_count("indivisibility"), 1)
#test.assert_equals(duplicate_count("aabbcde"), 2)
#test.assert_equals(duplicate_count("aabbcdeB"), 2)
#test.assert_equals(duplicate_count("Indivisibilities"), 2)