16 2011

NoSql Links 2011/08/16

分类目录: WEBheclei @ 11:35 下午

1.Rainbird 分布式实时统计系统

2.Cassandra简介

3.Cassandra

标签:


12 2011

C# Tip: Monitoring Clipboard Activity in C#

分类目录: winheclei @ 8:02 上午

C#监视剪贴板活动

转:http://www.developer.com/feedback.php/http:/www.developer.com/net/csharp/article.php/3359891

标签:


07 2011

Windows7 自定义右键菜单

分类目录: winheclei @ 11:13 下午

打开注册表文件

Win + R键,在运行中输入“regedit”打开注册表文件

定位到“HKEY_CLASSES_ROOT”节点

在目录上添加右键菜单

HKEY_CLASSES_ROOT\Directory\shell
添加项并双击修改default为右键菜单中显示的名称

image

在新建的项下建立“command”并修改default值为具体的执行语句
“cmd.exe /k cd %1”

image

在所有文件上添加右键菜单

HKEY_CLASSES_ROOT\AllFilesystemObjects\shell

步骤同目录方式

在指定后缀文件上添加右键菜单

HKEY_CLASSES_ROOT\*file\shell
* 号为文件的后缀,如css文件:cssfile,js文件:jsfile

步骤同目录方式

实际上HKEY_CLASSES_ROOT最上面有后缀名的default值对应,

例如:

1.css文件,HKEY_CLASSES_ROOT/.css的default值为CSSfile

2.js文件,HKEY_CLASSES_ROOT/.js的default值为JSfile

参考:

http://maketecheasier.com/customize-the-right-click-menu-in-windows-7-injecting-extra-features/2009/12/22

http://www.sevenforums.com/726207-post3.html

标签: , ,


17 2011

修改华为HG255D超级密码,改用原路由

分类目录: tutorialheclei @ 4:38 下午

一、描述

上海电信光纤改造一律统一给换了光猫和华为HG255D低端无线路由器,导致部分功能不能实现。

如果不需要IP TV功能可以直接使用原来自己的路由器。需要IP TV的获取telecomadmin密码后请阅读参考4

方法有二:

1.直接电话10000要账户密码,然后在以前的路由器中输入就可以了。

2.修改telecomadmin密码,查找账户密码。然后再输入到以前的路由器中。

下面介绍方法2

二、步骤

安装FireFox3的请直接阅读请阅读参考2

下面介绍使用Fiddler实现修改密码功能

1.下载地址http://www.getfiddler.com/dl/Fiddler2Setup.exe

2.安装

4.浏览器输入:http://192.168.1.1,用useradmin登录,密码在电信送到无线路由器底部。

5.点击“安全”-“广域网访问设置”

安全-广域网访问设置

6.双击启动Fiddler

启动Fiddler

7.选中“安全”-“广域网访问设置”(5图)中的“使能”,点击确定

8.在“Fiddler”中查找“http://192.168.1.1/html/security/set.cgi?RequestFile=html/security/urlfilter.asp”的链接

security/set.cgi

9.右键链接,鼠标点击“Unlock For Editing”

修改请求

10.删除 “Inspectors”中的“TextView”内容

编辑

修改为“InternetGatewayDevice.UserInterface.X_ATP_UserInfo.1.Userpassword=密码”

11.右键刚才选中的链接,鼠标点击“Unlock For Editing”,打把钩去掉

取消编辑状态

12.点击“Reissue”

重新发送请求

到此修改telecomadmin超级管理员密码成功

13.退出使用telecomadmin用户登录

14.选择“网络”-“宽带设置”

telecomadmin登录

15.鼠标选择中间部位,右键查看源文件,这是显示html源码

在源代码中搜索“var WanPPP”,在“var WanPPP”后面继续搜索“ad”,”ad”+数字开头的就是新登录帐户,后面一个自然就是密码了。

用户名密码

有了用户名密码一切都好办了吧!

三、结论

1.修改telecomadmin密码:InternetGatewayDevice.UserInterface.X_ATP_UserInfo.1.Userpassword=密码

2.华为是脆弱的

3.电信是万恶的

4.世界是自由的

四、参考

1.google

3.电信光纤进户FTTH华为HG255D无线路由器自定义配置(破解)


标签: , , ,


22 2011

FileUpload : Page Cannot be displayed and maximum request length exceeded error

分类目录: WEBheclei @ 10:17 下午

By default, ASP.NET permits only files that are 4,096 kilobytes (KB) or less to be uploaded to the Web server.  To upload larger files, we must change the maxRequestLength parameter of the <httpRuntime> section in the Web.config file. By default, the <httpRuntime> element is set to the following parameters in the Machine.config file:

<httpRuntime

executionTimeout=“90“

maxRequestLength=“4096“

useFullyQualifiedRedirectUrl=“false“

minFreeThreads=“8“

minLocalRequestFreeThreads=“4“

appRequestQueueLimit=“100“

/>

We can change the value of maxRequestLength to a desired value in our web.config of the application. For 10 mb we can set it to 10240 KB. Even in this case if user tries to upload a file with size more than 10 mb we than get the above “Page cannot be displayed error ” or the page simply hang up. In this case we can catch the error in the Application_Error event handler of the Global.asax file.

void Application_Error(object sender, EventArgs e)

{

if (System.IO.Path.GetFileName(Request.Path) == “Default.aspx”)

{

System.Exception appException = Server.GetLastError();

if (appException.InnerException.Message == “Maximum request length exceeded.”)

{

Server.ClearError();

Response.Write(“The form submission cannot be processed because it exceeded the maximum length allowed by the Web administrator. Please resubmit the form with less data.”);

Response.Write(“<BR><a href=’Default.aspx’>Click Here to go back to page</a> </BR>”);

Response.End();  } } }

I tried with the above code, but it isn’t consistent.

The best solution for this could be to set the value of maxRequestLength to a very high value.

and checking in the code for the size.

Say changing the value to say 700mb ( not sure what the maximum length of request could be)

<httpRuntime useFullyQualifiedRedirectUrl=“true“

maxRequestLength=“716800“

/>

And checking for the length in your code

// Putting the constraint of 1 mb

if (FileUpload1.FileContent.Length < 1024){

FileUpload1.SaveAs(@”C:/MyFolder/” + FileUpload1.FileName);}

else{

return;}

At least the above solution would save us from the page not displayed error.

And the last solution which i found was creating an httpmodule to intercept the web request.

using System;

using System.Collections.Generic;

using System.Text;

using System.Web;

namespace HAMModule{

public class MyModule : IHttpModule{

public void Init(HttpApplication app){

app.BeginRequest += new EventHandler(app_BeginRequest);

}

void app_BeginRequest(object sender, EventArgs e){

HttpContext context = ((HttpApplication)sender).Context;

// check for size if more than 4 mb

if (context.Request.ContentLength > 4096000){

IServiceProvider provider = (IServiceProvider)context;

HttpWorkerRequest wr = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));

// Check if body contains data

if (wr.HasEntityBody()){

// get the total body length

int requestLength = wr.GetTotalEntityBodyLength();

// Get the initial bytes loaded

int initialBytes = wr.GetPreloadedEntityBody().Length;

if (!wr.IsEntireEntityBodyIsPreloaded()){

byte[] buffer = new byte[512000];

// Set the received bytes to initial bytes before start reading

int receivedBytes = initialBytes;

while (requestLength – receivedBytes >= initialBytes){

// Read another set of bytes

initialBytes = wr.ReadEntityBody(buffer, buffer.Length);

// Update the received bytes

receivedBytes += initialBytes;

}

initialBytes = wr.ReadEntityBody(buffer, requestLength – receivedBytes);}}

// Redirect the user to an error page.

context.Response.Redirect(“Error.aspx”);}}

public void Dispose(){}

}}

and add the following information to web.config

<httpModules>

<add type=“HAMModule.MyModule“ name=“MyModule“/>

</httpModules>

inside

<system.web>

The last solution worked properly!!!!

BeginRequest event -The BeginRequest event signals the creation of any given new request. This event is always raised and is always the first event to occur during the processing of a request.

Article on creating a custom http module

http://msdn.microsoft.com/en-us/library/ms227673(VS.80).aspx

标签: ,


27 2011

on-screen keyboard类似输入法

分类目录: Z, winheclei @ 10:37 下午

skip to main | skip to sidebar
Yort on .NET
This is where ‘Yort’ praises, rants, raves and other wise talks nonsense about Microsoft .NET and Visual Studio. Or anything else related to software development or Microsoft that he feels like throwing in. It’s his blog after all…

Saturday, November 18, 2006
On-screen Keyboards
Recently, I wanted to create an on screen keyboard for use with our POS. Actually, I wanted a full keyboard for our ‘kiosk’ mode, and either a full keyboard or more likely a numeric keypad for the POS mode when running with a touch screen.

So, how do you create a virtual, on screen keyboard ? Creating a form/usercontrol with buttons or some other control(s) on it to represent the keyboard is relatively simple. What’s difficult is knowing where to send the key data when the control is clicked, because when you click on the virtual keyboard it tends to get focus, taking it away from the input field that needs the data.

Googling the problem I found several samples that simply raised an event from the on screen keyboard form/control, but that still leaves you with the issue of passing on the key data to some unknown edit field. Most of these samples assumed the keyboard control was either on the same form as the field receiving the key data, or that a reference to the control could be provided, which is fine if you only want to deal with forms within your own application, but sucks otherwise.

A few other samples worked by using API’s to obtain the handle of the control that currently has focus before the keyboard form/control is activated. When the buttons on the virtual keyboard are clicked, the key data is sent to the ‘remembered’ window handle and then the original window is refocused using API’s, or the window is refocused first and then SendKeys is used. This doesn’t work very well though. If the virtual keyboard window overlaps the client window then you get ‘flickering’ as the focus changes between the windows. Also it seems some key data just gets ‘lost’ if you hit buttons on the virtual keyboard quickly, although I’m not sure why.

In the end, thanks to two http://www.codeproject.com/ articles and another Google search, as well as some trial and error on my part, I managed to find the 3 magic things you must do to make an on screen keyboard work. These are;

Show your virtual keyboard form without ‘activation’, so it doesn’t get focus when the keyboard is shown.
Intercept the WM_MOUSEACTIVATE message and return MA_NOACTIVATE as the result.
Most important of all – you must NOT use controls that can get focus to represent your buttons.
The third point is the one that I missed for quite a while. Say you place a button control on your form for every ‘key’ on the virtual keyboard. You’ve overridden the WM_MOUSEACTIVATE event so clicking on the form won’t activate it – but you haven’t overridden the individual button control’s so they can still get focus, and when they do they will cause the parent form to be activated as well. If you use a label, picture box or some other control that can’t get focus though, then the form won’t get activated even when the control is clicked – which means you’re free to use SendKeys to pass on the keystrokes. This works exceedingly well, there is no flickering, and none of the keystrokes seem to get lost. Best yet, the code is relatively simple.
So, how exactly do you build the virtual keyboard ?
I recommend you grab a copy of FoxholeWilly’s keyboard control from CodeProject at http://www.codeproject.com/cs/miscctrl/touchscreenkeyboard.asp
This gives you a nice looking, resizable, keyboard. It also supports both alphabetical and QWERTY layouts, as well as a ‘kids’ version. It doesn’t have the Numeric Keypad like I wanted, but with a little image editing and some tweaking of the code it’s easy enough to add.
Unfortunately, this control doesn’t take care of points 1 and 2 from before, or actually pass on the key data for you. To do this, place the control on a host form and connect the control’s
UserKeyPressed event to an event handler. In that event handler place the following line of code;
SendKeys.Send(e.KeyboardKeyPressed);
Because FoxholeWilly’s control already provides a SendKeys formatted string as an event argument, that’s the only line of code needed to pass on the key data.
Now, to prevent the form receiving focus or being activated when it’s shown, simply override the CreateParams property on the host form, like this;
private const int WS_EX_NOACTIVATE = 0×08000000;

protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.ExStyle = createParams.ExStyle & WS_EX_NOACTIVATE;
return createParams;
}
}
Finally, you need to prevent the form getting focus or being activated when it or the keyboard control are clicked on. This is as easy as adding the following code to the host form;
private const int WM_MOUSEACTIVATE = 0×0021;
private const int MA_NOACTIVATE = 0×0003;
protected override void WndProc(ref Message m)
{
//If we’re being activated because the mouse clicked on us…
if (m.Msg == WM_MOUSEACTIVATE)
{
//Then refuse to be activated, but allow the click event to pass through (don’t use MA_NOACTIVATEEAT)
m.Result = (IntPtr)MA_NOACTIVATE;
}
else
base.WndProc(ref m);
}
This code actually came from a comment posted by Dirk Moshage, on Randy More’s CodeProject article (http://www.codeproject.com/samples/onscreenkeyboard.asp) about creating an on screen keyboard. However, because Randy’s keyboard project uses button controls to represent the buttons on screen, most people found the above code didn’t work properly because the child windows (buttons) still got activated, and then activated the parent anyway. In our case, neither FoxholeWilly’s keyboard control or the picturebox it uses to show the keyboard can get focus, which means the WM_MOUSEACTIVATE code actually works the way it’s intended.
That’s all there is to it. Once you have your host form and control configured, you can run the project. Simply put keyboard focus in any control on any window, and use the mouse (or your touch screen) to click on your virtual keyboard. As you click each virtual button, the appropriate key stroke is sent to the control that currently has focus, and the focus remains where it is.
Of course there’s a lot more you can do to improve your keyboard, such as adding a sound when keys are clicked on or implementing ‘type rate’ so keystrokes are sent repeatedly while the mouse button is held down over a particular key. For a basic keyboard though, you should have all you need.
Posted by Yort at 11/18/2006 03:01:00 PM


09 2011

TFS(Team Foundation Server)

分类目录: Zheclei @ 10:45 下午
  • Visual Studio Team System – 常规
  • Team Foundation Server – 常规
  • Team Foundation Server – 安装
  • Team Foundation Server – 管理
  • Team Foundation Server — 构建自动化
  • Team Foundation Server — Power Tools 和加载项
  • Team Foundation Server — 流程模板
  • Team Foundation Server – 报告和数据仓库
  • Team Foundation Server — Team System Web Access
  • Team Foundation Server – 版本控制
  • Team Foundation Server — 工作项目跟踪
  • 标签:


    十二 25 2010

    圣诞快乐

    分类目录: Zheclei @ 1:57 下午

    祝大家圣诞节快乐,帕里怕啦

    – 发送自我的 iPad


    十二 18 2010

    压力测试工具

    分类目录: Zheclei @ 2:23 下午

    Linux:webbench
    下载地址:http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz

    安装
    tar zxvf webbench-1.5.tar.gz
    cd webbench-1.5
    make && make install
    
    使用
    webbench -c 500 -t 30 http://www.baidu.com
    


    十二 16 2010

    varnish服务器的配置使用说明

    分类目录: WEBheclei @ 9:43 下午

    varnish是一款优秀的web前端cache服务器,同时能够当作接入服务器,具有负载均衡的功能。性能卓越,看看作者是谁就知道它的厉害了:)

    一 配置后台服务器:
    backend www {
    .host = “www.example.com”;
    .port = “http”;
    .connect_timeout = 1s;
    .first_byte_timeout = 5s;
    .between_bytes_timeout = 2s; //收到第一个字节后,每个字节之间的间隔时间
    //下面是健康检测的相关设置
    .probe = {
    .url = “/test.jpg”;
    /**
    * 或者使用裸的http请求的形式,不需要指定\r\n
    *.request = “GET / HTTP/1.1″
    “Host: www.foo.bar”
    “Connection: close”;
    */
    .timeout = 0.3 s;
    .window = 8; //检测多少次
    .threshold = 3; //返回多少次成功认为是这个后端是健康的
    }
    }
    二 负载均衡:
    根据后端服务器的健康状况以及负载均衡的策略来选择何时的后端服务器。
    策略有:
    round-robin 轮询
    random 随机
    director b2 random {
    .retries = 5; //尝试多少次去寻找后端,默认是这里定义的后端的个数。轮询策略时没有这个选项
    {
    /* We can refer to named backends */
    .backend = b1;
    .weight = 7;
    }
    {
    /* Or define them inline */
    .backend = {
    .host = “fs2″;
    }
    .weight = 3;
    }
    }
    三 访问控制
    acl local {
    “localhost”; /* myself */
    “192.0.2.0″/24; /* and everyone on the local network */
    ! “192.0.2.23″; /* except for the dialin router */
    }
    使用访问控制,如果和local不一致的话,就pipe
    if (client.ip ~ local) {
    pipe;
    }
    四 缓存更新Grace
    如果后端过于缓慢,会导致线程挂起。使用该配置能够在后端生成新的内容的同时返回给客户端一个过期了的内容。
    下面的配置能够让varnish返回过期的对象。所有的对象在过期后还会保存2分钟或者有一个新的对象来替代。
    sub vcl_recv {
    set req.grace = 2m;
    }
    sub vcl_fetch {
    set obj.grace = 2m;
    }
    五 内建函数
    regsub(str, regex, sub)
    Returns a copy of str with the first occurrence of the regular expression regex replaced with sub. Within sub, (which can also be spelled &) is replaced with the entire matched string, and 0 is replaced with the contents of subgroup n in the matched string.
    regsuball(str, regex, sub)
    As regsuball() but this replaces all occurrences.
    purge_hash(regex)
    清空缓存中hash匹配正则表达式的内容
    purge_url(regex)
    清空缓存中url匹配正则表达式的内容
    六 子程序
    使用子程序将一段逻辑代码组织起来,便于重用。
    子程序没有输入参数,也没有返回值
    sub pipe_if_local {
    if (client.ip ~ local) {
    pipe;
    }
    }
    调用子程序:
    call pipe_if_local;
    七 内置子程序
    提供了一些内置的子程序,这些子程序是varnish的运行逻辑中的回调,
    它们能够操作http请求的头部以及请求的其他内容,并根据这些请求的
    内容决定这个请求怎么被处理;每个子程序通过调用几个关键字来描述输出。
    vcl_recv
    在请求被收到以及解析后,准备处理这个请求时被调用。其作用是决定这个请求
    是否需要进行处理,怎么进行处理,
    以及如果处理的话,使用那个后端
    通过调用如下几个关键字来描述输出:
    error code [reason]::
    返回错误码给客户端,并取消这次请求
    pass::
    转到通过pass模式,控制流程交给vcl_pass子程序来进行处理
    pipe::
    转到pipe透传模式,控制流程交给vcl_pipe子程序来进行处理
    lookup::
    去缓存中查找请求的内容,如果请求被命中的话转到vcl_hit子程序去处理,
    如果没有命中的话,转到vcl_miss子程序去处理
    vcl_pipe
    当进入透传模式时被调用。在这个模式里,请求将被透传到后端,
    后端和客户端直接通话,直到一方关掉了连接。
    通过调用如下几个关键字来描述输出:
    error code [reason]
    返回错误码给客户端,并取消这次请求
    pipe
    继续透传模式
    vcl_pass
    当进入pass模式时被调用。这个模式这样处理请求:
    客户端的请求被转发到后端,后端的回应直接转给客户端,不会进入cache中,
    同一个客户端的请求以同样的方式被处理。
    通过调用如下几个关键字来描述输出:
    error code [reason]
    返回错误码给客户端,并取消这次请求
    pass
    继续pass模式
    vcl_hash
    使用req.hash += req.http.Set-Cookie 或者其它同样的方法将Set-Cookie HTTP header包含在hash中。
    通过调用如下几个关键字来描述输出:
    hash
    继续.
    vcl_hit
    当一个请求的内容在cache中命中的时候被调用
    通过调用如下几个关键字来描述输出:
    error code [reason]
    返回错误码给客户端,并取消这次请求
    pass
    转到通过pass模式,控制流交给vcl_pass子程序。
    deliver
    转交cache中的内容给客户端,控制流交给vcl_deliver子程序
    vcl_miss
    当一个请求的内容在cache中不命中的时候被调用
    通过调用如下几个关键字来描述输出:
    error code [reason]
    返回错误码给客户端,并取消这次请求
    pass
    转到通过pass模式,控制流交给vcl_pass子程序。
    fetch
    到后端去取数据,控制流转到vcl_fetch子程序
    vcl_fetch
    当请求被后端处理完成时被调用
    通过调用如下几个关键字来描述输出:
    error code [reason]
    返回错误码给客户端,并取消这次请求
    pass
    转到通过pass模式,控制流交给vcl_pass子程序。
    deliver
    可能会将返回的内容写入到cache中,然后将内容转给客户端。控制流转到vcl_deliver子程序
    esi
    就收到的内容进行分片ESI处理
    vcl_deliver
    当一个缓存中的对象被转发给客户端之前被调用
    通过调用如下几个关键字来描述输出:
    error code [reason]
    返回错误码给客户端,并取消这次请求
    deliver
    将内容转发给客户端
    vcl_timeout
    当回收线程准备回收过期的缓存对象之前被调用。
    通过调用如下几个关键字来描述输出:
    fetch
    从后端请求一个新的拷贝回来
    discard
    丢弃这个对象
    vcl_discard
    不管是缓存空间不够或者是缓存对象到了过期时间,当回收线程丢弃一个对象是被调用。
    通过调用如下几个关键字来描述输出:
    discard
    丢弃这个对象
    keep
    保存这个对象在cache中
    如果上述子程序没有被定义或者没有一个明确的结果调用,控制流将使用内建的默认流程。
    vcl_error
    XXX – needs documentation.
    八 变量
    尽管子程序不能有输入,一些必须的信息可以通过下面的一个全局变量得到。
    下面的变量一直可用:
    now
    从epoch到现在的时间,以秒为单位
    下面的变量在后端声明时可用:
    .host
    后端的名字或者ip地址
    .port
    后端的端口
    下面这些变量在处理请求时可用:
    client.ip
    客户端的ip地址
    server.ip
    接受客户端请求的服务器端的ip地址
    server.port
    接受客户端请求的服务器端的端口号
    req.request
    请求的类型(e.g. “GET”, “HEAD”).
    req.url
    请求的连接
    req.proto
    客户端使用的http版本号
    req.backend
    用来处理请求的后端
    req.backend.healthy
    后端是否健康
    req.http.header
    相应的http的头部
    下面这些变量在准备一个后端请求时可用(不管是cache不命中、pass模式、pipe模式):
    bereq.request
    请求的类型(e.g. “GET”, “HEAD”).
    bereq.url
    请求的连接
    bereq.proto
    客户端使用的http版本号
    bereq.http.header
    相应的http的头部
    bereq.connect_timeout
    后端连接超时的时间,以秒为单位
    bereq.first_byte_timeout
    等待后端返回第一个字节的时间,以秒为单位,在pipe模式下不可用
    bereq.between_bytes_timeout
    等待后端返回两个个字节的时间间隔,以秒为单位,在pipe模式下不可用
    下面这些变量在从cache中取到对象或者后端返回对象时可用:
    obj.proto
    http版本号
    obj.status
    后端返回的状态码
    obj.response
    后端返回的状态信息
    obj.cacheable
    当对象是可缓存时为真。
    当后端返回是合法的,而且返回的状态码为:200, 203, 300, 301, 302, 404 or 410
    而且当有Expires和Cache-Control头部时,返回的内容有一个非0的存活时间,(这个对象是非过期的)
    obj.ttl::
    对象的存活时间, 以秒为单位
    obj.lastuse
    对象上次请求到现在的时间间隔, 以秒为单位
    下面这些变量在确定一个对象的hash键值时可用:
    req.hash
    hash键值用于索引cache中的对象。 用于从cache中读取或者写入cache时。
    下面这些变量在准备向客户端发送内容时可用:
    resp.proto
    http版本号
    resp.status
    返回给客户端的状态码
    resp.response
    返回给客户端的内容
    resp.http.header
    返回给客户端的头部
    这些变量的值可以通过set关键字来进行设置:
    sub vcl_recv {
    # Normalize the Host: header
    if (req.http.host ~ “^(www.)?example.com$”) {
    set req.http.host = “www.example.com”;
    }
    }
    http头部可以通过remove关键字来进行删除
    sub vcl_fetch {
    # Don’t cache cookies
    remove obj.http.Set-Cookie;
    }

    link:http://www.tu321.com/

    标签:


    下一页 »