This file contains 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, os.path, sys, urllib2, requests | |
class PyPiError(Exception): | |
def __init__(self, value): | |
self.value = value | |
def __str__(self): | |
return repr(self.value) | |
def _chunk_report(bytes_so_far, chunk_size, total_size): | |
if (total_size != None): |
This file contains 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 | |
# Barcode scanner demo for Pythonista | |
# Based on http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx | |
from objc_util import * | |
from ctypes import c_void_p | |
import ui | |
import sound | |
found_codes = set() |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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 sys | |
from PyQt4 import QtGui | |
from PyQt4.QtCore import Qt | |
class MainWindow(QtGui.QMainWindow): | |
def __init__(self): | |
super(MainWindow, self).__init__() |
This file contains 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
pip install pillow |
This file contains 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 logging | |
logging.basicConfig(filename='%s.log' % today, level=logging.INFO, format='TIME: %(asctime)s -- LEVEL:%(levelname)s -- MESSAGE: %(message)s', datefmt='[%d/%b/%Y %H:%M:%S]') | |
# 同时在日志文件和控制台记录日志 | |
console = logging.StreamHandler() | |
console.setLevel(logging.INFO) | |
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') | |
console.setFormatter(formatter) | |
logging.getLogger('').addHandler(console) |
This file contains 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
def switch_re(the_list): | |
""" | |
多层list转单层 | |
:param the_list: 需要转换的List | |
:return: 单层List | |
""" | |
if isinstance(the_list, list): | |
now = the_list[:] | |
res = [] | |
while now: |
This file contains 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 datetime | |
datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S') |
This file contains 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
charset = requests.utils.get_encodings_from_content(response.content) | |
response.encoding = charset[0] |
This file contains 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
hexo new "postName" #新建文章 | |
hexo new page "pageName" #新建页面 | |
hexo generate #生成静态页面至public目录 简写:hexo g | |
hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server) 简写:hexo s,可用--debug | |
hexo deploy #将.deploy目录部署到GitHub 简写:hexo d | |
hexo d -g #组合命令,先生成页面,后部署到Github |
OlderNewer