Skip to content

Instantly share code, notes, and snippets.

@ideadsnow
ideadsnow / registry.py
Created February 29, 2016 03:25
安装python包时提示找不到python解决方法
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/[email protected]/msg10512.html
@ideadsnow
ideadsnow / prn_obj.py
Created March 4, 2016 06:28
python 打印对象全部属性
def prn_obj(obj):
print ', '.join(['%s:%s' % item for item in obj.__dict__.items()])
@ideadsnow
ideadsnow / parseURL.js
Created March 15, 2016 08:09
利用浏览器特性解析URL
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function(){
@ideadsnow
ideadsnow / pagination.js
Created March 15, 2016 08:14
利用 jqPaginator 插件分页
$('.pagination').jqPaginator({
totalCounts: totalCounts,
visiblePages: 8,
currentPage: pageNo,
pageSize: pageSize,
onPageChange: function (arg_num, arg_type) {
//type的值有 init 和 change 两种,表示 控件初始化 和 已初始化后的状态改变
console.log('当前第' + arg_num + '页', arg_type);
},
first: '<li><a class="btn btn-default" role="button" href="javascript:;">首页</a></li>',
@ideadsnow
ideadsnow / 258.py
Last active March 22, 2016 02:07
[LeetCode] 258. Add Digits
class Solution(object):
def addDigits_recursion(self, num):
"""
:type num: int
:rtype: int
"""
num_str = str(num)
if len(num_str) == 1:
return num
new_num = 0