android 进入通讯录
Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType("vnd.android.cursor.item/phone"); startActivityForResult(intent, 2);
//在onActivityResult里面: protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub if (resultCode==RESULT_OK) { switch (requestCode) { case 2: Uri contactData = data.getData(); Cursor c = managedQuery(contactData, null, null, null, null); c.moveToFirst(); //String id= c.getString(c.getColumnIndex(Contacts._ID)); //在这取到的id 和原先的id不一样,不知道是怎么回事所也下面就用name 来获得电话号码 String name = c.getString(c.getColumnIndex(Contacts.DISPLAY_NAME)); //取得通讯录中选中的名称 String phoneNum=getPhoneNum(name); // 取得所选的电话号码 System.out.println("name "+name +" number "+phoneNum); break; } } super.onActivityResult(requestCode, resultCode, data); } private String getPhoneNum(String name) { Cursor phones= managedQuery(Phone.CONTENT_URI, null, Phone.DISPLAY_NAME+" = '"+name+"'", null, null); phones.moveToFirst(); String phoneNum = phones.getString(phones.getColumnIndex(Phone.NUMBER)); return phoneNum; }
D-PAD按键处理以及拖动--onKeyDown、onTouch 事件与Layout坐标交互
联想 thinkpad壁纸
从远景上找的 分享给大家
thinkpad壁纸1: http://www.kuaipan.cn/file/id_20032934354355768.html
thinkpad壁纸2: http://www.kuaipan.cn/file/id_20032934354355766.html
联想壁纸:http://www.kuaipan.cn/file/id_20032934354355767.html
Wuala 安全在线存储
wuala邀请一枚
可代替dropbox的在线存储
wuala邀请一枚 需要翻墙
http://www.wuala.com/referral/KF4CJ64PM5PFPBF6GBB6
网易微博 api 分页 since_id
/statuses/home_timeline
折腾网易微博api 分页 ,参照api文档since_id 不知道是什么 ,自己试了试 找到了,
since_id 指的是 Status 里面的cursor_id
mailfiter 过滤ip
#--------ip filter------------ if(/^Received: from (.*) by (.*)/) { FROMIP=$MATCH1 if($FROMIP ne "") { if (lookup($FROMIP, ".blockip")) { echo "[block ip]::$FROMIP::F:$SENDER,T:$EXT@$HOST,drop letter" to /dev/null exit } } }
log4perl使用-按照日期划分log文件
http://search.cpan.org/~mschilli/Log-Log4perl/
首先 安装log4perl
perl -MCPAN -e "install Log::Log4perl"
windows中的ActivePerl 可以用ppm来安装
下面是例子
use strict; use warnings; use Cwd; my $curdir = getcwd; use Log::Log4perl; #按照日期来分割log文件 use POSIX qw(strftime); my $log_file = "subject".strftime("%Y-%m-%d", localtime(time)).".log"; my $conf = qq{ log4perl.category.Foo.Bar = INFO,Logfile log4perl.appender.Logfile = Log::Log4perl::Appender::File log4perl.appender.Logfile.filename = $curdir/$log_file log4perl.appender.Logfile.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = %d{20y-M-d H:m:s:S} %F %L - %m%n }; #初始化 log4perl 配制文件 Log::Log4perl::init (\$conf); my $log = Log::Log4perl::get_logger("Foo::Bar"); $log->info("信息 ");
-------------
另外 $conf 配置也可以写在文件里面:
Log::Log4perl::init("log3perl.conf");
qmail .mailfilter 过滤中文标题垃圾邮件
if(/^Subject:.*/) { SUBJECT=$MATCH #提取出base64编码的邮件标题 #echo "[subject]::$SUBJECT" } if ($SUBJECT ne "") { #将标题转换为中文 #maildecod 请访问http://hello386.is-programmer.com/posts/25736.html NSUB=`/usr/local/sbin/maildecod $SUBJECT` #echo "[NSUB]::$NSUB" } if (lookup($NSUB, ".badsubject")) { echo "[bad_subject]::$SUBJECT::F:$SENDER,T:$EXT@$HOST,drop letter" to /dev/null exit }
将qmail邮件标题从base64转换为中文
#!/usr/bin/perl $sub=join(" ",@ARGV); if ($sub=~ /=\?\S+\?\l(\S)\?/) { if ($1 =~ /[Qq]/) { $sub=decode_qp($sub); } elsif ($1 =~ /[Bb]/) { $sub=decode_base64($sub); } } elsif ($sub=~ /=[a-fA-F0-9][a-fA-F0-9]/) { $sub=decode_qp($sub); } $subject.=$sub; $subject=~s/\'/\\\'/g; $subject=~s/\"/\\\"/g; print $subject; # for test #最好是将生成的subject.log copy一份,在这个基础上修改成为badsubject 主要是怕编码不对 #open(FILE,">> /tmp/subject.log"); #print FILE "$subject\n"; #close(FILE); sub decode_qp { my($string) = @_; @buffer=split(/\?/,$string); $string = $buffer[3] if ($buffer[3] ne ""); $string =~ s/=([\da-fA-F]{2})/pack("C", hex($1))/ge; $string =~ /\?=(.*)/; $string =~ tr/_/ /; $buffer[4]=~s/^=//; $buffer[0]=~s/=$//; $string="$buffer[0]$string$buffer[4]"; return($string); } sub decode_base64 { my($string) = @_; my($string2); @buffer=split(/\?/,$string); $string = $buffer[3] if ($buffer[3] ne ""); $string =~ s/=+$//; $string =~ tr|A-Za-z0-9+/| -_|; while($string =~ /(.{1,60})/gs) { my($string3) = chr(32+length($1)*3/4); $string2 .= unpack("u",$string3 . $1 ); } $buffer[4]=~s/^=//; $buffer[0]=~s/=$//; $string2="$buffer[0]$string2$buffer[4]"; return($string2); }