30

谭导说,你生在这个国家,就要遵守这个国家的规则。

我经常骂他,这是我的国,不是他们的国,他们定下多如牛毛的规则,不许我们这个,不许我们那个,现在你说我生在这里,要遵守他们的规则,这是对的,我无法不从,我只好骂人了。

我是个气急败坏,却无可奈何的人。

http://news.163.com/special/00013D42/woaizhongguo.html

网易特别策划:我爱我的中国

看完有点感动,比起庄严肃穆的广场,整齐挺拔的方队,到处红色一片的全国各地,还是小人物们的一段告白,淡淡如白开水一般,这么一段卑微的命运让人更加感动。

60年,所有中国人的想象和汗水都没有白费,这块土地必将成为一个值得栖居之地,一个我的国。

我喜欢这段文字。虽然有着诸多不幸,很多人选择自由,选择离开,而大部分的中国人,只能扎根于此,生于此,死于此。

无论有再多的不如意,这都是我的国。不是因为这个地方有多好,只因为我生在这个地方,这个地方必将成为一个值得栖居的地方,一个我的国。当然,我注意到这是个将来时。

19
胡同
13

刚上线,机房客服给我发了这么一段:

承天客服 9:43:47
请各客户尽快安装华盾服务器过滤软件,今天下午五点半前未安装的将强行断网

倒是蛮吓人的,于是我就上华盾网站看看,结果居然找不到我的系统使用版本,难道要我重装系统配合那帮太监?哦,是网监。。。嗯,没错,我用的是64位linux和nginx。

未命名其实最反感的是这些人拿了钱却办不好事,实在要装吧,我就上去看看我该用什么版本,结果这个号称中国最领先的网络安全软件企业网页就死翘翘了。

懒虫  10:17:11
hi,华盾能否支持64位linux,nginx的web server

华盾@何畅  10:18:11
不支持哦。可以不用安装的

到底还是因为装了64位linux逃过一劫呀。

11

今天机房客服突然给我发一条信息:
客户在华盾软件网站www.huadunsoft.com下载中心下载安装广东的对应版本安装即可,验证的用户名是:茂名承天珠海公司
珠海的所有做网站的都要安装,安装有问题请联系
华盾软件@李(790643772);13670199238李伟杰,
茂名,湛江找763505490QQ

联系一早同事朋友收到的一些邮件,这事就比较明朗了:

根据2009年09月01日广东省公安厅网检总队及各地网监召开的会议精神,要求各单位于2009年09月13日前,严格落实网站发现、有害信息监测过滤及用户访问日志和系统维护日志存留60日等技术措施,或安装具有相应功能的安全管理系统。附件为《网监会议通知》,请详阅。
现由网监推荐以下两家公司推出的服务器管理系统,详细如下:

1、演示URL:http://demo.huadunsoft.com/ibadmin/index.html  账号:test  密码:888888,此网站为深圳市华盾技术有限公司推出的服务器管理专家测试版本,可试用。其主页为:www.huadunsoft.com;免费试用版下载URL:http://www.huadunsoft.com/product_download.html

2、演示URL:http://61.144.60.198:8000/bdadmin/index.html  账号:admin  密码:123456,此网站为广东天海威数码技术有限公司推出的服务器管理系统试用版本,该版本现免费使用,其主页为:www.bluedon.com;免费试用版下载URL:http://download.bluedon.com

请各公司服务器如是做虚拟主机,请务必于2009年09月10日前选择适合贵司使用之软件并安装;如做网站、论坛等,可相应于2009年09月15日前选择适合贵司使用之软件并安装;如做数据、OA等,可适当考虑是否安装。请严格遵守以上要求安装软件,网监处可检测出相关客户有否安装该软件。安装情况请及时回复,以便我司向网监提交数据。

还有:

关于传达《关于加强互联网数据中心安全技术措施落实工作的通知》的函 尊敬的客户: 接广东省网监通知,根据《关于加强互联网数据中心安全技术措施落实工作的通知》,要求贵司托管服务器全部安装相关信息安全监管软件,每台服务器必需安装一套。相关软件价格暂时未定,待通知。请于9月10日前完成安装,下载地址如下:http://www.huadunsoft.com。 禅城电信软件方联系人:刘娟 联系电话:15814018814 中山电信软件方联系人:骆丽奕 联系电话:13699846749 惠州电信软件方联系人:李孟明 联系电话:13302625681 如有特殊情况,实在无法安装,请与本市相关网监人员联系。 禅城网监联系人:廖原 联系电话:13703060800 中山网监联系人:张峰 联系电话:0760-23188883 惠州网监联系人:吴宏亮 联系电话:0752-2868185 请于9月10日下班前邮件回复我司相关安装进度。

这软件还不是免费的:

【问题1】:我注册了许可证,但登录华盾在线验证管理平台后,提示我”可用的许可证数量为0″?
【解答】:您虽然注册了许可证,但您并没有购买许可证授权,所以您无权配置服务器,请联系华盾客服人员,购买许可证授权之后,再次登录进行配置。

那显然有关部门是希望通过权力强迫企业购买华盾软件了。

不过最危险的还是华盾软件本身,这是个服务器端安装的绿坝,漏洞不知道会有多少,如果所有服务器都安装了的话,漏洞被黑客控制,那这个后果相当严重。



10

静态
var data = “Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities”.split(” “);
$(“#example”).autocomplete(data);

动态
1. jQuery(document).ready(function() {
2. jQuery(“#quick_search”).autocomplete(
3. “$!{request.contextPath}/autoComplete.shtml”,
4. {
5. max: 10,
6. scroll: false,
7. width: 162
8. }
9. );
10. })

http://www.javaeye.com/topic/275871

Tagged with:
01

天地不仁,以万物为刍狗。

前几天珠三角酸雨,梅州地区大批作物枯黄,每个人的故乡都在沦陷。

在twitter上面,心里总是憋得慌,每天都像个末日。然而每天都有大量精彩绝伦上演,欲罢不能。

有个年青人有一天unfollow了news163,说他每天大量推送死人,爆炸,污染的新闻,他已经变得越来越愤青,不如unfollow掉算了。

又回到北京街头,生活一如往常,依然每天背着包包骑车上下班,我的精神到底是正常还是不正常?

01

Restlet is a great, lightweight REST framework for Java developers. The only problem, there are not that many examples on how to use this framework available.
Some examples are included after installing the package under the src/org.restlet.example directory. But these examples are simple starting points and do not fully describe how to create a full REST web service with create, update and delete functionality.
I am using the 1.1 M4 version of restlet. The API documentation is available here.
The example code works but does not execute any database lookup. To make this example more useful, it is recommended to replace the :TODO lines with your database lookup.

First, create a simple User class. Which contains a variable id and name.

import java.nio.Buffer;

import org.json.JSONObject;

public class User {

private String id = null;
private String name = null;

/**
 * @return Returns the id.
 */
public String getId() {
 return id;
}

/**
 * @param id
 *            The id to set.
 */
public void setId(String id) {
 this.id = id;
}

/**
 * @return Returns the name.
 */
public String getName() {
 return name;
}

/**
 * @param name
 *            The name to set.
 */
public void setName(String name) {
 this.name = name;
}

/**
 * Convert this object to a JSON object for representation
 */
public JSONObject toJSON() {
try{
 JSONObject jsonobj = new JSONObject();
 jsonobj.put("id", this.id);
 jsonobj.put("name", this.name);
 return jsonobj;
}catch(Exception e){
 return null;
}
}

/**
 * Convert this object to a string for representation
 */
public String toString() {
 StringBuffer sb = new StringBuffer();
 sb.append("id:");
 sb.append(this.id);
 sb.append(",name:");
 sb.append(this.name);
 return sb.toString();
}
}

We also need some kind of error object to represent an error message. This is a very simple example

import org.json.JSONObject;

public class ErrorMessage {

public JSONObject toJSON() {
 JSONObject jsonobj = new JSONObject();
 try {
  jsonobj.put("error", "An error occured");
  return jsonobj;
 } catch (Exception e) {
  return null;
 }
}
public String toString() {
 StringBuffer sb = new StringBuffer();
 sb.append("error:");
 sb.append("An error occured");
 return sb.toString();
}
}

Now, let's create our UserResource.

import org.restlet.Context;
import org.restlet.data.Form;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Status;
import org.restlet.ext.json.JsonRepresentation;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
import org.restlet.resource.ResourceException;
import org.restlet.resource.StringRepresentation;
import org.restlet.resource.Variant;

public class UserResource extends Resource {

private User user = null;

public UserResource(Context context, Request request, Response response) {
 super(context, request, response);
 String userid = null;
 userid = (String) getRequest().getAttributes().get("id");
 this.user = findUser(userid);
 getVariants().add(new Variant(MediaType.TEXT_PLAIN));
 getVariants().add(new Variant(MediaType.APPLICATION_JSON));
}

/**
 * Allow a PUT http request
 *
 * @return
 */
public boolean allowPut() {
 return true;
}

/**
 * Allow a POST http request
 *
 * @return
 */
public boolean allowPost() {
 return true;
}

/**
 * Allow a DELETE http request
 *
 * @return
 */
public boolean allowDelete() {
 return true;
}

/**
 * Allow the resource to be modified
 *
 * @return
 */
public boolean setModifiable() {
 return true;
}

/**
 * Allow the resource to be read
 *
 * @return
 */
public boolean setReadable() {
 return true;
}

/**
 * Find the requested user object
 *
 * @param userid
 * @return
 */
private User findUser(String userid) {
 try {
  if (null == userid)
   return null;
  // :TODO {do some database lookup here }
  // user = result of lookup
  // This part should be replaced by a lookup
  User u = new User();
  u.setId("1");
  u.setName("name");
  // end replace
  return u;
 } catch (Exception e) {
  return null;
 }
}

/**
 * Represent the user object in the requested format.
 *
 * @param variant
 * @return
 * @throws ResourceException
 */
public Representation represent(Variant variant) throws ResourceException {
 Representation result = null;
 if (null == this.user) {
  ErrorMessage em = new ErrorMessage();
  return representError(variant, em);
 } else {
  if (variant.getMediaType().equals(MediaType.APPLICATION_JSON)) {
   result = new JsonRepresentation(this.user.toJSON());
  } else {
   result = new StringRepresentation(this.user.toString());
  }
 }
 return result;
}

/**
 * Handle a POST Http request. Create a new user
 *
 * @param entity
 * @throws ResourceException
 */
public void acceptRepresentation(Representation entity)
  throws ResourceException {
 // We handle only a form request in this example. Other types could be
 // JSON or XML.
 try {
  if (entity.getMediaType().equals(MediaType.APPLICATION_WWW_FORM,
    true)) {
   Form form = new Form(entity);
   User u = new User();
   u.setName(form.getFirstValue("user[name]"));
   // :TODO {save the new user to the database}
   getResponse().setStatus(Status.SUCCESS_OK);
   // We are setting the representation in the example always to
   // JSON.
   // You could support multiple representation by using a
   // parameter
   // in the request like "?response_format=xml"
   Representation rep = new JsonRepresentation(u.toJSON());
   getResponse().setEntity(rep);
  } else {
   getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
  }
 } catch (Exception e) {
  getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
 }
}

/**
 * Handle a PUT Http request. Update an existing user
 *
 * @param entity
 * @throws ResourceException
 */
public void storeRepresentation(Representation entity)
  throws ResourceException {
 try {
  if (null == this.user) {
   ErrorMessage em = new ErrorMessage();
   Representation rep = representError(entity.getMediaType(), em);
   getResponse().setEntity(rep);
   getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
   return;
  }
  if (entity.getMediaType().equals(MediaType.APPLICATION_WWW_FORM,
    true)) {
   Form form = new Form(entity);
   this.user.setName(form.getFirstValue("user[name]"));
   // :TODO {update the new user in the database}
   getResponse().setStatus(Status.SUCCESS_OK);
   // We are setting the representation in this example always to
   // JSON.
   // You could support multiple representation by using a
   // parameter
   // in the request like "?response_format=xml"
   Representation rep = new JsonRepresentation(this.user.toJSON());
   getResponse().setEntity(rep);
  } else {
   getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
  }
 } catch (Exception e) {
  getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
 }
}

/**
 * Handle a DELETE Http Request. Delete an existing user
 *
 * @param entity
 * @throws ResourceException
 */
public void removeRepresentations()
  throws ResourceException {
 try {
  if (null == this.user) {
   ErrorMessage em = new ErrorMessage();
   Representation rep = representError(MediaType.APPLICATION_JSON, em);
   getResponse().setEntity(rep);
   getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
   return;
  }
  // :TODO {delete the user from the database}
  getResponse().setStatus(Status.SUCCESS_OK);
 } catch (Exception e) {
  getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
 }
}

/**
 * Represent an error message in the requested format.
 *
 * @param variant
 * @param em
 * @return
 * @throws ResourceException
 */
private Representation representError(Variant variant, ErrorMessage em)
  throws ResourceException {
 Representation result = null;
 if (variant.getMediaType().equals(MediaType.APPLICATION_JSON)) {
  result = new JsonRepresentation(em.toJSON());
 } else {
  result = new StringRepresentation(em.toString());
 }
 return result;
}

protected Representation representError(MediaType type, ErrorMessage em)
  throws ResourceException {
 Representation result = null;
 if (type.equals(MediaType.APPLICATION_JSON)) {
  result = new JsonRepresentation(em.toJSON());
 } else {
  result = new StringRepresentation(em.toString());
 }
 return result;
}
}

And implement a restlet server, listening on port 8100.

import org.restlet.Application;
import org.restlet.Component;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Router;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.StringRepresentation;

public class WebServiceApplication extends Application {

    public static void main(String[] args) throws Exception {

        // Create a component
        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8100);

        WebServiceApplication application = new WebServiceApplication(
                component.getContext());

        // Attach the application to the component and start it
        component.getDefaultHost().attach(application);
        component.start();
    }

    public WebServiceApplication() {
        super();
    }

    public WebServiceApplication(Context context) {
        super(context);
    }

    @Override
    public Restlet createRoot() {

        Router router = new Router(getContext());
        router.attach("/users", UserResource.class);
        router.attach("/users/{id}", UserResource.class);

        Restlet mainpage = new Restlet() {
            @Override
            public void handle(Request request, Response response) {
                StringBuilder stringBuilder = new StringBuilder();

                stringBuilder.append("<html>");
                stringBuilder
                        .append("<head><title>Sample Application Servlet Page</title></head>");
                stringBuilder.append("<body bgcolor=white>");

                stringBuilder.append("<table border=\"0\">");
                stringBuilder.append("<tr>");
                stringBuilder.append("<td>");
                stringBuilder.append("<h1>example - REST</h1>");
                stringBuilder.append("</td>");
                stringBuilder.append("</tr>");
                stringBuilder.append("</table>");
                stringBuilder.append("</body>");
                stringBuilder.append("</html>");

                response.setEntity(new StringRepresentation(stringBuilder
                        .toString(), MediaType.TEXT_HTML));

            }
        };
        router.attach("", mainpage);
        return router;
    }
}

You can test the restlet web service with any internet browser except for the PUT and DELETE requests. I prefer curl to test a Restful web service.

GET REQUEST – Show the information of a user:

curl http://localhost:8100/users/1

POST REQUEST – Create a new user:

curl -d “user[name]=John” http://localhost:8100/users

PUT REQUEST – Update an existing user:

curl -X PUT -d “user[name]=Jane” http://localhost:8100/users/1

DELETE REQUEST – Delete an existing user:

curl -X DELETE http://localhost:8100/users/1k

Tagged with:
preload preload preload