Skip to content

Instantly share code, notes, and snippets.

@luw2007
luw2007 / lftpdown
Last active December 18, 2015 18:59
利用lftp 多点下载。例子lftpdown https://index.docker.io/v1/repositories/base/images 30 base.img
#!/bin/sh
function _get_down_cmd(){
echo "\"pget -n ${2} '${1}' -o ${3}\""
}
if [[ $# -lt 1 ]]; then
echo "need down_url"
echo "$0 用法: $0 [OPTS] <down_url> [maxconn|number] [base|directory]"
exit 1
fi
@luw2007
luw2007 / simple_list.py
Created June 21, 2013 02:04
acmerfight 通过“googlegroups.com” 发送至 python-cn 有一个文件 下面为文件中的前5行数据,注意每行数据存储的元素数量不固定 [1, 2, 3, 4] [1, 2, 3, 5] [1, 9, 4] [10, 11, 12, 7] [10, 12, 4, 5] 我要明确知道上一级到下一级的完整从属关系。 要求输出结果为 {1:{2:{3:[4, 5]}, 9:[4]}} {10:{11:{12:[7]}, 12:{4:[5]}}}
s = [[1, 2, 3, 4],
[1, 2, 3, 5],
[1, 9, 4],
[10, 11, 12, 7],
[10, 12, 4, 5]]
c = {1:{2:{3:[4, 5]}, 9:[4]}, 10:{11:{12:[7]}, 12:{4:[5]}}}
r = {}
.vagrant
Gemfile.lock
Berksfile.lock
tmp/
@luw2007
luw2007 / gist:5590896
Last active December 17, 2015 09:58
http://www.oschina.net/code/snippet_1026590_20768 给定数字X和Y,返回其中包括多少个数字,数字本身是回文数,同时也是另一个回文数的平方。 可能边界还存在问题,但是没有过多的用例验证.
#!/usr/bin/python
#-*- coding:utf-8 -*-
"""
给定数字X和Y,返回其中包括多少个数字,数字本身是回文数,同时也是另一个回文数的平方。
Given two numbers X and Y, return how many numbers in that range
(inclusive) are palindromes, and also the square of a palindrome.
"""
def get_numbers(deep):
if deep == 1:
Out[27]: [u'Win32_TSClientSetting', u'Win32_Service', u'Win32_NTEventlogFile', u'CIM_LinkHasConnector', u'CIM_Service', u'Win32_LogicalShareAccess', u'CIM_DependencyContext', u'Win32_SystemNetworkConnections', u'Win32_PageFile', u'MSFT_WmiCoreUser', u'Win32_PerfFormattedData_PerfProc_Process', u'CIM_CreateDirectoryAction', u'MSFT_NetTakeOwnership', u'CIM_OSProcess', u'Win32_LogicalFileAuditing', u'Win32_ModuleTrace', u'Win32_SystemTimeZone', u'__ExtrinsicEvent', u'Win32_PerfRawData_PerfOS_Objects', u'Win32_SecuritySettingAuditing', u'__TimerInstruction', u'Win32_LUID', u'CIM_DiskPartition', u'Win32_PerfRawData_PSched_PSchedFlow', u'Win32_SystemLogicalMemoryConfiguration', u'Win32_IniFileSpecification', u'Win32_SoftwareFeature', u'Win32_ReserveCost', u'Win32_ThreadTrace', u'MSFT_NetServiceStartFailedNone', u'Win32_TapeDrive', u'Win32_SubDirectory', u'Win32_PerfRawData_Tcpip_NetworkInterface', u'MSFT_WmiCoreLogoffEvent', u'Win32_SystemConfigurationChangeEvent', u'Msft_WmiProvider_CreateClassEnumAsyncEvent_Pre',

python项目通用组件和基础服务

很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。

每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。

原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。

另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。

@luw2007
luw2007 / cms_dotnet.md
Created March 4, 2013 07:15
.net cms pickup

#.NET

http://stackoverflow.com/questions/954764/good-net-based-cms http://space.itpub.net/82080/viewspace-626939 http://www.hualay.net/blog/Bloger-Wikipedia/106/106.html

##Orchard Orchard is a free, open source, community-focused project aimed at delivering applications and reusable components on the ASP.NET platform. It will create shared components for building ASP.NET applications and extensions, and specific applications that leverage these components to meet the needs of end-users, scripters, and developers. Additionally, we seek to create partnerships with existing application authors to help them achieve their goals. Orchard is delivered as part of the ASP.NET Open Source Gallery under the Outercurve Foundation. It is licensed under a New BSD license, which is approved by the OSI. The intended output of the Orchard project is three-fold:

Individual .NET-based applications that appeal to end-users , scripters, and developers

@luw2007
luw2007 / dig_ikandou.py
Created February 27, 2013 07:25
用来抓取 ikandou.com 网站中的书籍信息的脚本 需要安装 mongodb 数据库. - pymongo 用于存储数据库 - requests 方便的读取页面 - pyquery 使用jquery 的语法来控制网页和xml, 其基于lxml - lxml
#!/usr/bin/env python2
#-*- coding:utf-8 -*-
"""
用来抓取 ikandou.com 网站信息的脚本
需要安装 mongodb 数据库.
- pymongo 用于存储数据库
- requests 方便的读取页面
- pyquery 使用jquery 的语法来控制网页和xml, 其基于lxml
- lxml
@luw2007
luw2007 / ikandou_books_orderby_download.txt
Created February 27, 2013 02:00
ikandou 目前下载次数排名
60261 PHP经典实例
28526 史蒂夫·乔布斯传
27804 拖延心理学
26647 明朝那些事儿(1-9)
22816 Steve Jobs
22395 百年孤独
21999 金庸全集三联版
21238 中国历代政治得失
20224 不二
19241 三体
def checkio(n):
'return roman numeral using the specified integer value from range 1...3999'
if 1 <= n <= 3999:
return ''.join(to_roman(n))
def to_roman(num):
roman = [["","I","II","III","IV","V","VI","VII","VIII","IX"],