242010

最近在做一个推荐系统的项目,原来是设计前台一个表单对应后台一个form和action。无奈前台表单太多,只能把表单合并处理(在vo里都是对应同一个类,只是处理不同的逻辑)。这样就在前台表单里加了2个参数type和method。type用来区分form里的validate,然后利用method使用DispatchAction类。

采用 DispathAction
* 如果覆写DispathAction中的execute方法,必须显示的用super调用execute方法
* parameter参数值不能是execute或perform
* 了解<action>标签中的parameter的含义
* 了解DispathAction中的unspecified方法的含义

DispatchAction 的定义:
public abstract class DispatchAction extends Action
这是一个抽象的Action,它会根据request 中的parameter来执行相应的方法。通个这个Action类可以将不同的Action集中到一个Action文件中来。

Struts-config.xml:

<action path=”/saveSubscription” type=”org.apache.struts.actions.DispatchAction” name=”subscriptionForm” scope=”request” input=”/subscription.jsp” parameter=”method”/>

在Action中要有相应的方法:

Public class demoAction extends DispatchAction{

public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward insert(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

}

你就可以通过这样的方法来访问你的程序:

http://localhost:8080/myapp/saveSubscription.do?method=update

如果parameter中参数为空,则执行Action中unspecified方法
DispatchAction就是在struts-config中用parameter参数 配置一个表单字段名,这个字段的值就是最终替代execute被调用的方法. 例如parameter=”method”而request.getParameter(“method”)=”save”,其中”save”就是 MethodName。struts的请求将根据parameter被分发到”save”或者”edit”或者什么。但是有一点,save()或者 edit()等方法的声明和execute必须一模一样。

DispatchAction的父类是 Action ,它的作用就在于将多个功能相似的业务逻辑放在同一个 Action 中实现,各个业务逻辑通过传入不同的参数来决定执行哪个操作方法

通常在 Action 中我们都是通过 execute 方法来处理业务逻辑及页面转向,一个 Action 只能完成一种业务逻辑处理 , 当然我们也可以在页面插入一个隐藏的变量,然后在 Action execute 方法中通过判断这个隐藏变量的值来决定调用哪个方法,也可以达到同 一个 Action 来处理多种业务逻辑

DispatchAction 是如何实现的?

比如对一个用户对象来说,存在增加,删除,修改的操作,首先创建一 个继承 DispatchAction UserAction 类,

然后将 addUser,delUser,updateUser 这些方法写在这个类里面,代码如下:

package com.why.struts.action;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.actions.DispatchAction;

import com.why.Constant;

import com.why.struts.form.AddUserForm;

import com.why.struts.form.LoginForm;

public class UserAction extends DispatchAction

{

public ActionForward addUser (ActionMapping mapping,ActionForm form,

HttpServletRequest request,HttpServletResponse response) throws Exception

{

// 增加用户业务的逻辑

return mapping.findForward(Constant. FORWARD_ADD );

}

public ActionForward delUser(ActionMapping mapping,ActionForm form,

HttpServletRequest request,HttpServletResponse response) throws Exception

{

// 删除用户业务的逻辑

return mapping.findForward(Constant. FORWARD_SUCCESS );

}

public ActionForward updateUser(ActionMapping mapping,ActionForm form,

HttpServletRequest request,HttpServletResponse response) throws Exception

{

// 更新用户业务的逻辑

return mapping.findForward(Constant. FORWARD_SUCCESS );

}

}

如何实现这些不同方法的调用呢 ? 那就是要在 struts-config.xml 文件中更改 action-mapping 的配置,如下:

< action-mappings >

< action

attribute = “addUserForm”

input = “/addUser.jsp”

name = “addUserForm”

parameter=”method”

path = “/addUser”

scope = “request”

type=”com.why.struts.action.UserAction” >

</ action >

< action

attribute = “delUserForm”

input = “/delUser.jsp”

name = “delUserForm”

parameter=”method”

path = “/delUser”

scope = “request”

type=”com.why.struts.action.UserAction” />

< action

attribute = “updateUserForm”

input = “/updateUser.jsp”

name = “updateUserForm”

parameter=”method”

path = “/updateUser”

scope = “request”

type=”com.why.struts.action.UserAction” />

</ action-mappings >

可以看到每个 <action  /> 中都增加了 parameter=” “ 项,这个值可以随便命名,如上面命名为 metho d ,用来接收页面传来的参数

如下为页面的提交, 注意:对应 <action  /> 中的 parameter , 对应 UserAction 类中的方法名

AddUser.jsp

<html:link href=”addUser.do?method=addUser“>Add User</html:link>

DelUser.jsp

<html:link href=”delUser.do?method=delUser“>Add User</html:link>

UpdateUser.jsp

<html:link href=”updateUser.do?method=updateUser“>Add User</html:link>

jsp图片验证码

Posted by 冰河 at 23:16 No Responses » 5,280 Views
232010

代码如下:

image.jsp

<%@ page contentType="image/jpeg" import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
// 给定范围获得随机颜色
Color getRandColor(int fc,int bc) {
    Random random = new Random();
    if(fc > 255) {
        fc = 255;
    }
    if(bc > 255) {
        bc = 255;
    }
    int r = fc + random.nextInt(bc - fc);
    int g = fc + random.nextInt(bc - fc);
    int b = fc + random.nextInt(bc - fc);
    return new Color(r, g, b);
}
%>
<%
//设置页面不缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);

// 在内存中创建图象
int width = 60, height = 20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

// 获取图形上下文
Graphics g = image.getGraphics();

//生成随机类
Random random = new Random();

// 设定背景色
g.setColor(getRandColor(200,250));
g.fillRect(0, 0, width, height);

//设定字体
g.setFont(new Font("Times New Roman", Font.PLAIN, 18));

//画边框
//g.setColor(new Color());
//g.drawRect(0,0,width-1,height-1);

// 随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
g.setColor(getRandColor(160, 200));
for (int i = 0; i < 155; i++) {
    int x = random.nextInt(width);
    int y = random.nextInt(height);
    int xl = random.nextInt(12);
    int yl = random.nextInt(12);
    g.drawLine(x,y,x+xl,y+yl);
}

// 取随机产生的认证码(4位数字)
String sRand = "";
for (int i = 0;i < 4; i++) {
    String rand = String.valueOf(random.nextInt(10));
    sRand += rand;
    // 将认证码显示到图象中
    // 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
    g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
    g.drawString(rand, 13 * i + 6, 16);
}

// 将认证码存入SESSION
session.setAttribute("captcha", sRand);

// 图象生效
g.dispose();

// 输出图象到页面
ImageIO.write(image, "JPEG", response.getOutputStream());

out.clear();
out = pageContext.pushBody();

%>
一定不要漏掉红色部分,否则会报出错误:
getOutputStream() has already been called for this response

在需要使用验证码的地方加入:
<img src="include/image.jsp">
182010

这是谷奥上的一篇译文,写的很不错,转过来和大家分享。英文原文附在最后。

本文为《True North: Discover Your Authentic Leadership》一书作者 之一Peter Sims所 写。

在4月底,JP摩根邀请我参加一个“思想领导者聚餐”来讨论最近硅谷和数字媒体的事情。在旧金山Kokkari饭馆的私人包间里坐了有20来人,有 来自著名VP公司、成功企业家和JP摩根的一帮人,JP摩根的副总裁Jimmy Lee坐在龙头老大位置。

在干了几杯之后,Jimmy开始了他想说的话题:“我想知道你们都是怎么想的,你们会长期持有哪个公司的股票,而哪家公司是短期的?”于是我们开始 写下自己的答案,很多人在长期票名单上都写了Yahoo!和Amazon,而15位思想领导者里的12位则将短命票都投给了Google。Jimmy惊呼 到:“我的佛祖,上帝,以及老天爷呀!你们这是谷黑大聚会吗?”

我当然也被震惊了。Google毕竟是一家在最近非常成功的公司(不管是成长率还是收入),他们有一个受人尊敬的CEO Eric Schmidt,还有很多人写书(这本这本)说为什么每个人都应该变得更Google。我个人也佩服Google和他们的人,他们已经完成了很多壮 举,但这间屋子里的人们的想法并不是基于一个公司过去成绩的,而是Google的未来前景。下面就是人们看衰Google的一些原因:

1.Google已经经历了过去几年严重的人才流失,丧失最初的创业者和一些创新人才。

尽管Google的人才保留率很高,但人才的挑战不是看数量的,而是离职人们的类型和他们离开的原因。屋子里的VC们都同意Facebook和 Zynga是目前硅谷最炙手可热的,最近不少从Google出去的人基本都去了Facebook,包括Android高级产品经理Erick Tseng

知情人士说,Google公司的早期创新文化已经被慢慢取代了,创业型和思想领导者都在挪窝,人们甚至说Google让其想到了2004-2005 年间的Yahoo,已经不是他们加入时那种任人唯贤的公司了。

2.Google已经失去了简单的发展机遇,现在必须找到新的大块收入源。

对于核心搜索业务,Google有必要豪赌一把,尽管移动搜索的增速很快,但它的份额依然很小。Google现在跟个疯狗似的寻找各种增长点,因为 他们知道移动并不是个出路。最近花7亿美元收购ITA就是个挥动魔法棒寻找大赌注的例子。Google必须找到越来越大的收入源来保证增 长率,创新研究专家Clayton Christensen在《The Innovators Solution》已经指出了这个问题,你还可以参考Jim Collins的《How the Mighty Fall》。

3.Google缺乏连贯性的策略,特别在移动方面。

CEO Schmidt和其他Google高管一直强调移动是未来增长的核心,而当晚到场的很多人对Google在移动方面的努力则有自己的一套观点。他们争辩说 还需要很久才能看到新的一直在增长的移动收入,特别是在AdMob被收购后市场上就没有可观的收购对象的时候,不过最近对ITA的收购表现出Google开始押注一些中型收购。

4.人!人!人!

Google以工程师为主导的文化大家都很熟悉了,但是Peter Drucker在《Innovation and Entrepreneurship》一书里指出,成功的创新者看全貌,而他们只看人。Google一直都只招聘符合他们特定要求的一群 人。

比如说产品经理的候选人被告知他们必须具备顶尖大学的计算机科学学位。但尽管Google的核心算法出自冰雪聪明的工程师创新,但能否拧成一股绳才 是公司持续发展的关键。这种类似饼干模子似的招聘规矩使他们拒绝了多样性,并为非工程师制造了升职限制,导致创新的缺失。文化上的傲慢是Jim Collins最关注的问题。人们还总是说,在Google的工程师主导了工程和产品,甚至是市场上的决定。比如Google RadioGoogle Wave这类失败的东西,批评者通常会质疑Google公司是否真正了解人们的需求。

总结:

对于以上这些问题,也许熟悉硅谷的观察家会问:Google会成为下一个微软吗?没错,微软的先驱者有主导市场的操作系统和Office软件,跟 Google革命性的搜索类似。但除了XBOX,微软很难做出新的创新,其实这就是高度成功下所隐藏的深度文化问题。

有一件事可以肯定:现在是Google的关键时刻。如果他们不想将这些问题摆到桌面上解决,衰歌合唱团人数将增加。但手里堆成山的现金、得到出色人 才并解决以上提到的问题,还是有机会。

Google 是否有成为下一个微软的风险?

Via TechCrunch

英文原文;

Is Google at Risk of Becoming the Next Microsoft?

In late April, JP Morgan invited me to a “thought leaders dinner” to discuss the latest goings on in Silicon Valley and digital media. In a private room at the swanky San Francisco restaurant Kokkari, there were about 20 of us seated around a long rectangular table, including venture capitalists from prominent firms, highly successful entrepreneurs, and a handful of people from J.P. Morgan, including Jimmy Lee, the firm’s well-known Vice Chairman, who sat at the head of the table. (I was, like Kevin Costner’s character in Bull Durham Crash Davis, “the player to be named later.”)

Anyhow, after about an hour and a few glasses wine, Jimmy raised the main question he was curious about: “I want to know from each of you: which company would you go long on and which would you short?” We could pick any timeframe. And, as it turned out, while the long picks varied widely from Amazon to Yahoo!, 12 of the 15 ‘thought leaders’ shorted Google. Jimmy was surprised, virtually astounded: “Wow!” he exclaimed, “You guys are really negative on Google, huh?”

I, too, was surprised. Google has been, after all, the most successful company in recent history (in terms of churning out growth and profits), led by Eric Schmidt, a well-respected CEO. And, we’ve seen book after book about why everyone should be more like Google. I admire Google, its people, and what they have been able to accomplish enormously. It’s astonishing. But the opinions in that room were not based on the company’s past performance. They were based on insights about Google’s future. Below are the reasons people cited for shorting the company (which, interestingly, were fairly diverse):

  • Google has experienced a severe talent drain over the past several years, losing some of its most entrepreneurial and innovative people. Although Google’s has high retention rates, Google’s talent challenge is not in terms of numbers, it’s the type of people who are leaving and why they are leaving. The talent drain from Google has been well documented. Venture capitalists in the room (without a vested interest in the companies) argued that Facebook and Zynga are currently considered hot places to work in Silicon Valley. Google has, for example, seen a stream of people leave for Facebook including, more recently, the likes of Erick Tseng, the senior product manager of Android, Google’s critically important mobile initiative.

    People close go Google say upward management is slowly replacing the company’s early culture of innovation. Entrepreneurial types and thought leaders who feel confined or unmotivated are moving. People will even say that it reminds them of Yahoo back in 2004-2005, not the meritocracy they once joined.

  • The company has run out of easy growth opportunities and must now find big chunks of new revenue. With the core search business maturing, Google increasingly seems to increasingly feel the need to make some “big bets.” That is a problem that maturing companies face that CEOs call “the tyranny of large numbers.” Even mobile search, which is seeing impressive growth numbers of a small base, is still too small to make a material difference for the company. The company is obviously trying like crazy to find growth pockets, knowing that mobile is a ways off. The recent $700 million ITA acquisition is a great case in point of how it is going to spread out some medium-sized to big-bets to see what sticks. That is, companies must find bigger and bigger chunks of revenue to maintain growth rates. This problem is documented well by innovation researchers Professor Clayton Christensen in The Innovators Solution, and Jim Collins in How the Mighty Fall.
  • The company lacks a coherent strategy, especially in mobile. As Schmidt and other Google execs have stated, mobile is core to future growth. A number of people around the table that night had unique insight into Google’s mobile efforts. They argued that growing nascent mobile revenues will take significant time, especially since there aren’t many sizable acquisition targets available in mobile after Google’s purchase of AdMob. Instead, the recent purchase of ITA Software was an indicator of how the company might make some medium to big bets to see what sticks.
  • It’s about people, people, people. Google’s engineering-dominated culture isn’t news to anyone. But As Peter Drucker opined in his landmark book Innovation and Entrepreneurship, “Successful innovators…look at figures, and they look at people.” The company has long recruited people who fit a very specific profile.

Product manager candidates, for example, are told they must have computer science degrees from top universities. But while Google’s core algorithm was a brilliant feat of engineering innovation, a growing chorus of voices question whether it can be sustained. That cookie-cutter approach to people misses important opportunities for diversity and creates glass ceilings for non-engineers, both of which stifle innovation. Cultural hubris, another pattern Jim Collins in particular raises, is of foremost concern. It is often said that at Google the engineers lead engineering, product, and even marketing decisions. But when the company has failed, such as with Google Wave or Google Radio, critics have questioned whether the company really understands people.

For these reasons and more, perhaps the question that “in the know” Silicon Valley observers are now increasingly asking is: Could Google be the next Microsoft? That is, much like Google revolutionized search, Microsoft was a pioneer with its market-dominating operating systems and Microsoft Office. But outside the Xbox, Microsoft has struggled severely to produce new innovations. Deeper cultural problems were hidden by amazing performance and success.

One thing is for certain: it’s a pivotal time in Google’s history. If the company does not put these types of issues on the table, the chorus of short sellers will increase. But with mountains of cash, access to great people and big problems, I see the moment as an opportunity. It’s a chance to reflect, ask some tough questions, openly discuss the challenges, and incorporate some fresh thinking and people, so that this great symbol of global innovation can evolve and grow.

What do you think—are you long or short? Is Google at risk of becoming the next Microsoft or on the verge of a creative explosion?

152010
一. 设置客户端网络实用工具
  • 点击“开始”-“程序”,在“Microsoft SQL Server”菜单中选择“客户端网络实用工具”。
  • 在“别名”选项中点击“添加”。
  • 在“服务器别名”中,填入您网站域名,在“网络库”区域中点击“TCP/IP”,在“连接参数”区域取消“动态决定端口”,指定 “端口号”为2433(如果不确定或者图省事,可以勾选动态决定端口)。填写完毕后,点击“确定”按钮保存配置。
二.企业管理器的使用
  • 点击“开始”-“程序”,在“Microsoft SQL Server”菜单中打开“企业管理器”。在企业管理器中,右键单击“SQL Server组”,选择“新建SQL Server注册”。
  • 此时会出现SQL Server属性窗口,在“服务器”中填入您网站的域名,选择“使用SQL Server身份验证”,“登录名”和“密码”分别填入主机开通邮件中的用户名和密码,然后点击“确定”。
  • 连接成功后,你会看到“SQL Server组”中多了一个名称为您网站域名的服务器。此时,您就可以像操作本地SQL数据库一样管理网站数据库了。
注意事项
  • 如果连接的时候出现超时错误,更改超时时间即可,方法是点击“工具”-“选项”。
  • 在属性窗口中选择“高级”选项卡,将“登录超时”的数值设置为0。
(完毕)

MyEclipse 6.5 汉化

Posted by 冰河 at 19:38 3 Responses » 24,534 Views
142010

myeclipse汉化,其实就是装中文语言包。自己做过好几次,总是记不住。

假设安装路径是:D:Program FilesMyEclipse 6.5

(1)首先运行目录<D:Program FilesMyEclipse 6.5eclipse>下的“eclipse.exe”应用程序,进入到主界面后,在主菜单栏处依次点:“help”–> “software update”–>“Find And Install”,这时弹出一个界面,要你选择要安装的功能部件,选择第2项(搜索要安装的新功能部件),然后点next,进入下一步。然后选择New Remote Site(新建远程站点),弹出一个对话框,有两项,第一项是要你起个名字,随便起,就叫language吧,第2项是个URL,填入http://download.eclipse.org/technology/babel/update-site/ 这个下载地址,(finish)确定就行了。更新了一段时间后,会弹出一个对话框,让你选择一个站点,我选择了china(shanghai)这个下载站点,速度挺快的(15分钟的样子就能下完汉化包),选择好站点后,又更新一段时间,然后会弹出一个语言包列表框(language pack),一共有29个语言包,我们不需要全部下载,只需下载“simple chinese”这个语言包就行了,选择好后,点next,继续下载更新。最后,会弹出一个对话框,让你选择安装路径,默认即可(D:Program FilesMyEclipse 6.5eclipse),点”finish”。下载完后,会提示你安装,然后点“install all”就行了。安装完后,提示要关闭myelicpse,确认即可。

(2)MyEclipse6.5汉化包安装完成后,把D:Program FilesMyEclipse 6.5eclipseeclipse.ini里的-Duser.language=en删除掉,保存后,重新运行MyEclipse6.5,就会看见久违的中文界面了。

选择PPTP与OpenVPN

Posted by 冰河 at 17:43 2 Responses » 38,228 Views
122010

使用VPN服务最主要就是通过隐藏你的IP地址实现匿名,以及在网络中发送加密数据提供 隐私。目前有各种各样的VPN连接,但是一般来说,VPN提供商提供PPTP和OpenVPN连 接方式,原因就在于二者的使用简易和效率高。除匿名外,他们都提供不同级别的加 密技术。

PPTP

点对点隧道协议(PPTP)是一种实现虚拟专用网络的方法。 PPTP使用用于封装PPP数据包的TCP及GRE隧道控制通道。

OpenVPN

OpenVPN是一免费开源软件,以路由器或桥接配置和远程访问设备方式实现虚拟专用网络(VPN)创建安全的点 对点或站对站连接的解决方案。它使用SSL / TLS安全加密,具有穿越网络地址转 换(NATs)和防火墙的功能。

PPTP与OpenVPN之比较和选择 ?

在PPTP和OpenVPN二者之间做出选择的一个重要考虑因素,也是我们无法控制的因素,就是有时互联网服务供应商会阻止 PPTP连接。次情况下我们无计可施,只能选择使用OpenVPN。 PPTP具有一些独 特优势,但此刻用OpenVPN会是不错的选择。

PPTP可以应用到几乎所有的操作系统软件,无需安装任何软件。它也兼容许多移动设备,如 iphone,ipad和Windows移动,安装简易。相比之下,OpenVPN的安装比PPTP要复杂一点,但只 要按照正确的指示安装则无太大困难。请注意OpenVPN不兼容移动设备。

PPTP加密技术使用密码作为密钥,它的数据流载有可获 取的混编密码。如果中间有人拦截到了数据流并且破译了密码(尽 管可能但很难),那么他就可以破译你的信息。然而OpenVPN使用非 常强大的加密(Blowfish)技术。即使有人拦 截你的数据流,他们也无计可施。这使得OpenVPN比PPTP安全得多。

如何抉择

如果你希望得到高安全性以及更加关注数据安全传输问题,那么你应该使用OpenVPN。如果您为了简便或者想在移动设备上使用VPN那么PPTP适合你。还有其他协议,例如L2P或IPSec,但他们在用户友好或成本上没有优势。

分享你的MyEntunnel

Posted by 冰河 at 20:37 5 Responses » 16,486 Views
082010

MyEntunnel 只能给本机提供服务。这个就不太爽快了,难不成每台电脑都弄个 SSH 吗?google 了一下,才知道实际上它只是 plink.exe 的图形界面而已。于是乎又开始琢磨 plink.exe。

只要将转发端口设置为 0.0.0.0:7070,其他电脑就可以搭上云梯了。还是 MyEntunnel 的自动重连比较好用,无奈端口号的设置选项,只支持填写纯数字,并不能包含“.”和“:”。

其中过程不用再提。请编辑 myentunnel.ini ,将 SOCKSPort 设置为 0.0.0.0:7070 即可。重新启动 MyEntunnel,可以看到消息:

plink.exe: Local port 0.0.0.0:7070 SOCKS dynamic forwarding

用的时候把本地地址127.0.0.1换成实际地址,端口换成7070。

存在问题:

1.安全性。好像每个人都能用这个ssh了。

2.我的机器有公网固定ip,如果是内网或者动态ip好像就没法使用。

引用链接:http://dallaslu.com/use-myentunnel-as-public-proxy/

MyEntunnel+SSH+AutoProxy玩穿越

Posted by 冰河 at 19:49 4 Responses » 17,745 Views
082010

首先,我们必须准备3个东西:

  1. 一个SSH帐号(免费的大都不稳定,可以去买一个,也不贵。有的虚拟空间是支持ssh的);
  2. 一个叫MyEnTunnel的小软件;
  3. Firefox浏览器;
  4. 用firefox访问AutoProxy扩展官网安装之.如果无法下载或者安装失败,请尝试点击此处手动下载安装文件,下载完毕后将安装文件直接拖到firefox的窗口内进行安装。

以上步骤准备好后,将下载来的MyEnTunnel解压缩到一个目录中,运行” myentunnel”,切换到”设置”选项卡,按下图设置即可:

其中,你需要修改的只有”SSH服务器”,”用户名”,”密码短语”这3项.当然,如果你的SSH帐号所在的服务器不是使用默认的22端口,就需要 修改SSH端口号,”1080”是你作为代理服务器的端口,如果1080已经被其他服务占用,就改一个空闲的端口号即可.

信息都填写完毕后,点击”保存”, MyEnTunnel就会将配置保存到当前目录的一个配置文件中.

点击左下角的”连接”或者”断开”即可连接你的SSH服务器.

第一次连接服务器时,会弹出对话框问你是否要保存密钥,选”Yes”,则将必要保存到注册表,下次连接就不会再提示;如果选“No”,则下次连接时 还会继续提示。

当连接成功后, MyEnTunne的图标会由黄色变为绿色,这个时候你就可以使用IP为127.0.0.1,端口为1080的socks5类型代理上网了.

点击”隐藏”,就可以将它隐藏到系统托盘,不会占用你的任务栏,完美吧?

下面要谈谈firefox的AutoProxy扩展,安装好这个扩展并重启firefox以后,会自动弹出这个窗口:

autoproxy

选中”gfwList”,再点击”确定”,这样就能得到每天自动更新的需要使用代理服务器才能访问的网站列表. 这时候你再看firefox顶部的工具栏右侧(也有可能在底部状态栏右侧)是不是有个红色”福”字的按钮?点击这个按钮就可以打开”AutoProxy首 选项”,打开后,点击”代理服务器”菜单,选择”编辑代理服务器”,打开设置代理服务器的窗口:

autoproxy1

把最右侧的”删除”复选框全部打上勾,然后点击”删除代理”按钮,我们自己再添加代理(当然,你也可以只留下一个,把剩下的删除).我把代理全部都 删除了,它不爽了:

文章原作者是这么写的。这里没必要删除原有的代理。直接跳过这一步新建一个就可以了。新建完之后在“代理服务器->选择代理服务器”里选择你新建的那个。

autoproxy2

赶紧点击”添加代理”重新设置一下吧,别忘了必须选中socks5:

autoproxy3

按照上面的输入即可,端口号是之前在” MyEnTunnel”中设置的端口.当然,你可以自己取一个好听点的名字。

好了,点击”确定”就设置完了,如果你打开了AutoProxy后发现还是有些网站被墙了怎么办?解决办法:在”AutoProxy首选项”中,打 开”代理规则”,选择”添加规则”,输入网址后点击确定即可.当然,” AutoProx”还有其他一些个性化的设置,如显示位置什么的,就不再多做说明了.

如果使用代理后无法观看youtube视频,在firefox地址栏输入:about:config,打开设置页面,搜索 network.proxy.socks_remote_dns,将其值设为true即可用firefox观看。

如果你想让MyEnTunnel开机就自动启动,请创建一个myentunnel.exe的快捷方式,放到开始菜单-所有程序中的”启动”菜单中即 可.

关于tunnelier和myentunnel速度的争 论,myentunnel作者在其官网上给出了解释:

Notice: the development build of plink.exe is MUCH faster with large data transfers than the currently packaged (release 0.60). Simply replace the executeable if you use MyEnTunnel for streaming videos or large file transfers. You can get the development version from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html under the “The latest development snapshot” section.

大意就是plink的稳定版是限速的,使用开发版速度会有很大提升。

有网友测试得出myentunnel用plink的开发版替换稳定版之 后,可以与tunnelier一样达到满速。我个人比较喜欢myentunnel,小巧灵便。

参考链接:http://www.fishnote.net/?p=93

Microsoft Learning to Rank Datasets

 

We release two large scale datasets for research on learning to rank: MSLR-WEB30k with more than 30,000 queries and a random sampling of it MSLR-WEB10K with 10,000 queries.

 

Dataset Descriptions

The datasets are machine learning data, in which queries and urls are represented by IDs. The datasets consist of feature vectors extracted from query-url pairs along with relevance judgment labels:

(1) The relevance judgments are obtained from a retired labeling set of a commercial web search engine (Microsoft Bing), which take 5 values from 0 (irrelevant) to 4 (perfectly relevant).

(2) The features are basically extracted by us, and are those widely used in the research community.

In the data files, each row corresponds to a query-url pair. The first column is relevance label of the pair, the second column is query id, and the following columns are features. The larger value the relevance label has, the more relevant the query-url pair is. A query-url pair is represented by a 136-dimensional feature vector. The details of features can be found here.

Below are two rows from MSLR-WEB10K dataset:
=============================================================
0 qid:1 1:3 2:0 3:2 4:2 … 135:0 136:0
2 qid:1 1:3 2:3 3:0 4:0 … 135:0 136:0
=============================================================

Dataset Partition

We have partitioned each dataset into five parts with about the same number of queries, denoted as S1, S2, S3, S4, and S5, for five-fold cross validation. In each fold, we propose using three parts for training, one part for validation, and the remaining part for test (see the following table). The training set is used to learn ranking models. The validation set is used to tune the hyper parameters of the learning algorithms, such as the number of iterations in RankBoost and the combination coefficient in the objective function of Ranking SVM. The test set is used to evaluate the performance of the learned ranking models.

Folds Training set Validation set Test set
Fold1 {S1,S2,S3} S4 S5
Fold2 {S2,S3,S4} S5 S1
Fold3 {S3,S4,S5} S1 S2   
Fold4 {S4,S5,S1} S2 S3
Fold5 {S5,S1,S2} S3 S4

 

The datasets can be downloaded at Microsoft Research website.

数据挖掘十大经典算法

Posted by 冰河 at 19:48 No Responses » 5,408 Views
192010

国际权威的学术组织the IEEE International Conference on Data Mining (ICDM) 2006年12月评选出了数据挖掘领域的十大经典算法:C4.5, k-Means, SVM, Apriori, EM, PageRank, AdaBoost, kNN, Naive Bayes, and CART.

不仅仅是选中的十大算法,其实参加评选的18种算法,实际上随便拿出一种来都可以称得上是经典算法,它们在数据挖掘领域都产生了极为深远的影 响。


1. C4.5

C4.5 算法是机器学习算法中的一种分类决策树算法,其核心算法是ID3算法.  C4.5算法继承了ID3算法的优点,并在以下几方面对ID3算法进行了改进:

1) 用信息增益率来选择属性,克服了用信息增益选择属性时偏向选择取值多的属性的不足;

2) 在树构造过程中进行剪枝;

3) 能够完成对连续属性的离散化处理;

4) 能够对不完整数据进行处理。

C4.5算法有如下优点:产生的分类规则易于理解,准确率 较高。其缺点是:在构造树的过程中,需要对数据集进行多次的顺序扫描和排序,因而导致算法的低效。


2. The k-means algorithm 即K-Means算法

k-means algorithm算法是一个聚类算法,把n的对象根据他们的属性分为k个分割,k < n。它与处理混合正态分布的最大期望算法很相似,因为他们都试图找到数据中自然聚类的中心。它假设对象属性来自于空间向量,并且目标是使各个群组内部的均 方误差总和最小。


3. Support vector machines

支持向量机,英文为Support Vector Machine,简称SV机(论文中一般简称SVM)。它是一种?督式??的方法,它广泛的应用于统计分类以及回归分析中。支持向量机将向量映射到一个更 高维的空间里,在这个空间里建立有一个最大间隔超平面。在分开数据的超平面的两边建有两个互相平行的超平面。分隔超平面使两个平行超平面的距离最大化。假 定平行超平面间的距离或差距越大,分类器的总误差越小。一个极好的指南是C.J.C Burges的《模式识别支持向量机指南》。van der Walt 和 Barnard 将支持向量机和其他分类器进行了比较。

4. The Apriori algorithm

Apriori算法是一种最有影响的挖掘布尔关联规 则频繁项集的算法。其核心是基于两阶段频集思想的递推算法。该关联规则在分类上属于单维、单层、布尔关联规则。在这里,所有支持度大于最小支持度的项集称 为频繁项集,简称频集。


5. 最大期望(EM)算法

在统计计算中,最大期望(EM,Expectation–Maximization)算法是在概率(probabilistic) 模型中寻找参数最大似然估计的算法,其中概率模型依赖于无法观测的隐藏变量(Latent Variabl)。最大期望经常用在机器学习和计算机视觉的数据集聚(Data Clustering)领域。

6. PageRank

PageRank是Google算法的重 要内容。2001年9月被授予美国专利,专利人是Google创始人之一拉里•佩奇(Larry Page)。因此,PageRank里的page不是指网页,而是指佩奇,即这个等级方法是以佩奇来命名的。

PageRank根据网站的外部链接和内部链接的数量和质量俩衡量网站的价值。PageRank背后的概念是,每个到页面的链接都是 对该页面的一次投票,被链接的越多,就意味着被其他网站投票越多。这个就是所谓的“链接流行度”——衡量多少人愿意将他们的网站和你的网站挂钩。 PageRank这个概念引自学术中一篇论文的被引述的频度——即被别人引述的次数越多,一般判断这篇论文的权威性就越高。

7. AdaBoost

Adaboost是一种迭代算法,其核心 思想是针对同一个训练集训练不同的分类器(弱分类器),然后把这些弱分类器集合起来,构成一个更强的最终分类器 (强分类器)。其算法本身是通过改变数据分布来实现的,它根据每次训练集之中每个样本的分类是否正确,以及上次的总体分类的准确率,来确定每个样本的权 值。将修改过权值的新数据集送给下层分类器进行训练,最后将每次训练得到的分类器最后融合起来,作为最后的决策分类器。

8. kNN: k-nearest neighbor classification

K最近邻(k-Nearest Neighbor,KNN)分类算法,是一个理论上比较成熟的方法,也是最简单的机器学习算法之一。该方法的思路是:如果一个样本在特征空间中的k个最相 似(即特征空间中最邻近)的样本中的大多数属于某一个类别,则该样本也属于这个类别。

9. Naive Bayes

在众多的分类模型中,应用最为广泛的两种分类模型是决策树模型 (Decision Tree Model)和朴素贝叶斯模型(Naive Bayesian Model,NBC)。 朴素贝叶斯模型发源于古典数学理论,有着坚实的数学基础,以及稳定的分类效率。同时,NBC模型所需估计的参数很少,对缺失数据不太敏感,算法也比较简 单。理论上,NBC模型与其他分类方法相比具有最小的误差率。但是实际上并非总是如此,这是因为NBC模型假设属性之间相互独立,这个假设在实际应用中往 往是不成立的,这给NBC模型的正确分类带来了一定影响。在属性个数比较多或者属性之间相关性较大时,NBC模型的分类效率比不上决策树模型。而在属性相 关性较小时,NBC模型的性能最为良好。


10. CART: 分类与回归树

CART, Classification and Regression Trees。 在分类树下面有两个关键的思想。第一个是关于递归地划分自变量空间的想法;第二个想法是用验证数据进行剪枝。

© 2009 - 2024 冰河的博客