Skip to content

Instantly share code, notes, and snippets.

@friskfly
friskfly / test
Created October 23, 2012 05:34
test
<?php
/**
* 生成验证码
* @author chenzhouyu
* 类用法
* $checkcode = new checkcode();
* $checkcode->doimage();
* //取得验证
* $_SESSION['code']=$checkcode->get_code();
*/
@friskfly
friskfly / dabblet.html
Last active December 10, 2015 03:58 — forked from rocketxujia/dabblet.html
竖排
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
h1 {
width: 1em;
font-size: 40px;
@friskfly
friskfly / 星期数组
Created December 26, 2012 14:21
星期数组
['一,''二,''三,''四,''五,''六,''日']
@friskfly
friskfly / Context.sublime-menu
Created December 26, 2012 14:42
gist plugin context.sublime-menu
[
{ "caption": "-" },
{
"caption": "Gist",
"children": [
{ "command": "gist", "caption": "Create Public Gist…" },
{ "command": "gist_private", "caption": "Create Private Gist…" },
{ "command": "gist_list", "caption": "Open Gist…" },
{ "command": "insert_gist_list", "caption": "Insert Gist…" },
{ "command": "gist_add_file", "caption": "Add File to Gist…" },
@friskfly
friskfly / switch.py
Created December 26, 2012 14:43
python switch
try:
{
'a': do_a,
'b': do_b,
'c': do_c
}[key](x)
except KeyError:
do_default
@friskfly
friskfly / getfolders.py
Created December 27, 2012 12:37
python getFloders 根据filePath 获得所有的父级目录 向上查找
nestingLimit=30
def getFolders(file_path):
if file_path is None:
return []
folders = [file_path]
limit = nestingLimit
while True:
split = os.path.split(file_path)
@friskfly
friskfly / findFile.py
Created December 27, 2012 12:41
python findFile(folders,file_name) 在所有目录列表中查找是否存在文件 存在则返回所在目录
# Finds a real file path among given folder paths
# and returns the path or None
#
# @type folders: list<string>
# @param folders: list of paths to folders to look into
# @type file_name: string
# @param file_name: file name to search
#
# @return string file path or None
def findFile(folders, file_name):
@friskfly
friskfly / multiThread.py
Created December 30, 2012 11:29
Python 多线程分块读取
# -*- coding: utf-8 -*-
import os,time
import threading
rlock = threading.RLock()
curPosition = 0
class Reader(threading.Thread):
def __init__(self, res):
self.res = res
@friskfly
friskfly / monitor Cpu.py
Created December 30, 2012 12:22
python 监控CPU wmi
#coding:utf-8
import wmi
import time
c = wmi.WMI()
while True:
for cpu in c.Win32_Processor():
timestamp = time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime())
print '%s | Utilization: %s: %d %%' % (timestamp, cpu.DeviceID, cpu.LoadPercentage)
@friskfly
friskfly / codecs.py
Created January 1, 2013 07:57
python 获取系统默认编码
import locale
import codecs
print locale.getpreferredencoding();
print codecs.lookup(locale.getpreferredencoding()).name