2012年12月6日
摘要: 使用tornado 处理静态文件时出现了如下的错误UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 108: ordinal not in range(128) python是使用ascii作为默认编码,可以通过修改python/lib/site.py进行修改,如下所示:def setencoding(): """Set the string encoding used by the Unicode implementation. The default 阅读全文
posted @ 2012-12-06 08:56 lepfinder 阅读(4760) 评论(0) 推荐(0) 编辑
  2012年7月3日
摘要: #********************************************# filename: all_files.py# Author: xiyang# email: sdlgxxy@gmail.com# date: 2012-7-2# description:# 包装os.walk实现目录树的遍历,提供更加完善的功能,# 比如文件过滤、单层遍历等#*********************************************import os,fnmatch def all_files(root,patterns='*'... 阅读全文
posted @ 2012-07-03 12:51 lepfinder 阅读(897) 评论(0) 推荐(0) 编辑
摘要: 什么叫做PASV mode(被动模式传送)?他是如何工作的? FTP的连接一般是有两个连接的,一个是客户程和服务器传输命令的,另一个是数据传送的连接。FTP服务程序一般会支持两种不同的模式,一种是Port模式,一种是Passive模式(PasvMode),我先说说这两种不同模式连接方式的分别。 先假设客户端为C,服务端为S. Port模式: 当客户端C向服务端S连接后,使用的是Port模式,那么客户端C会发送一条命令告诉服务端S(客户端C在本地打开了一个端口N在等着你进行数据连接),当服务端S收到这个Port命令后 就会向客户端打开的那个端口N进行连接,这种数据连接就生成了。 Pasv模式: 阅读全文
posted @ 2012-07-03 12:42 lepfinder 阅读(342) 评论(0) 推荐(0) 编辑
  2012年5月15日
摘要: Apache 和 Tomcat是我们平时使用比较多的两个Web服务器,本文收集一些关于这两个服务器的安全性配置的方法和技巧。另外安全是相对的,需要服务器安全、数据库安全、应用程序安全互相配合。仅从服务器配置上只能在某些方面提高系统的安全性。Apache安全配置1、 隐藏或伪装apache版本号 打乱攻击者的步骤,给攻击者带来麻烦。一般软件的漏洞信息是和版本相关的,在攻击者收集你服务器软件信息时给予迷惑信息是个不错的选择。默认情况下,系统会把apache的版本模块都显示出来(http返回的头),如下图 添加上如下两行,再次看http返回的信息,已经不包含apache的版本好了。 还有另外一种方. 阅读全文
posted @ 2012-05-15 09:28 lepfinder 阅读(1737) 评论(0) 推荐(0) 编辑
  2012年4月29日
摘要: 闹钟管理器可以在指定的时间触发事件,这样就可以做一些周期性的任务,比如定时更新数据,实现闹铃等。The steps we follow for this exercise are 1. Get access to the alarm manager. 2. Come up with a time to set the alarm. 3. Create a receiver to be invoked. 4. Create a pending intent that can be passed to the alarm manager to invoke the receiver... 阅读全文
posted @ 2012-04-29 10:35 lepfinder 阅读(742) 评论(0) 推荐(0) 编辑
  2012年4月28日
摘要: BroadcastReceiver通常需要向用户传达发生的某件事或状态,可以使用通知栏通知提醒用户。创建通知的过程:1、创建一个合适的通知2、获得通知管理器的权限3、向通知管理器发送通知创建通知时,需要包含以下几个部分:1、要显示的图标2、显示的提示文本3、传送它的时间然后使用Context获取一个名为Context.NOTIFICATION_SERVICE的系统服务来获取到通知管理器,如下所示://Get the notification manager String ns = Context.NOTIFICATION_SERVICE; NotificationManager nm = (N 阅读全文
posted @ 2012-04-28 15:17 lepfinder 阅读(659) 评论(0) 推荐(0) 编辑
摘要: 一、intent大全:1.从google搜索内容Intent intent = new Intent();intent.setAction( Intent.ACTION_WEB_SEARCH );intent.putExtra( SearchManager.QUERY, "红超的吾记之谈" )//搜索内容startActivity( intent );2.浏览网页Uri uri = Uri.parse( "http://wzhnsc.blogspot.com/" );Intent it = new Intent( Intent.ACTION_VIEW, 阅读全文
posted @ 2012-04-28 14:56 lepfinder 阅读(508) 评论(0) 推荐(0) 编辑
摘要: 如下图所示,点击menu右面的broadcast会发送一条广播,广播接受者接受信息后,打印一些调试信息。下面看代码:布局文件layout/main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_ 阅读全文
posted @ 2012-04-28 14:54 lepfinder 阅读(658) 评论(0) 推荐(0) 编辑
摘要: 演示本地服务的使用方法。布局文件,包含两个按钮,一个启动服务,一个终止服务。<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height=&quo 阅读全文
posted @ 2012-04-28 10:08 lepfinder 阅读(449) 评论(0) 推荐(0) 编辑
  2012年4月27日
摘要: 我们知道Android的activity如果没有在5秒内处理完某个事件,将会触发一个ANR事件,该事件将会极大地影响用户体验。使用Android 的AsyncTask可以以后台线程的形式更新用户界面,可在程序中用来处理一些耗时的操作。比如实现一个从网络上抓取图片显示在一个ImageView中,效果如下图:布局文件main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res 阅读全文
posted @ 2012-04-27 17:04 lepfinder 阅读(474) 评论(0) 推荐(0) 编辑