Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1. 用最简单的方法判断一个LONG整形的数A是2^n(2的n次方)

* 若一个数是2^n,那么此数的二进制形式应为: 100000…,在所有的数位中,只有一个是1,其它都为0
* 当用此数减1时,就会变成: 01111111….,在所有数位为1,对应数位为0,那么二者相与,就会为0
* 故:当此数与比他小一的数相与若为0,则此数是2的n次方,算法为:判断 i&(i-1) 是否为0,若为0,则此数是2的n次方

2. 扩展:判断一个LONG整形的数是否是2^n – 1

* 设:x为一个2^n -1数, 那么x+1= 2^n = (x+1)&x
* 即:用x&(x+1)若为0,则是2^n – 1数

3.? (A|B|C) & A = A
令:X = A|B|C, 因为进行的是或运算, 那么在A中位数为1的数位上,对应的X数位也为1,这些为1的数位与A进行与操作,结果为1.?????? 在X的其它数位上,因A在这些数位上为0,故X的其它数位与A相与为0,总和二者知:结果为A
扩展:权限设计,每个权限给予一个数字,每个人的权限值即为这些权限的或操作结果,那么判断此人是否拥有A权限,即用此人总的权限值与A进行与操作即可,若结果为A,则说明拥有此权限。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,过程化:新增一种需求,相应增加一种方法,对应调用。

* 对过Switch,据传入的参数调用对应的方法,这些方法可能执行相同的流程,但不可固定下来。

2,对象化:新增一种需求,相应增加一种对象,通过多态来完成调用。核心的代码调控模块可以固定下来。

* 对过Switch,据传入的参数产生相应的对象,接着利用多态将流程固定下来。

3,XML配置化:新增一种需求,相应增加一条配置信息及对应的处理对象,核心代码读取需求并调用。(Spring)

* 无须Switch,配置文件中设置需求与类的关系,将需求读入列表中,将一种需求提出时,直接在配置文件中找到对应的类,调用之。
* 并且对象的更新与需要的对应在配置文件中完成,弹性非常好。
* 如:
//读取类信息填充成下拉表,据选择的值建立相应的类对象
* string mediatype = cbbMediaType.SelectedItem.ToString();
//得到类名
* string factoryDllName = ConfigurationSettings.AppSettings[mediaType].ToString();
//构造类对象
* ImediaFactory factory = (ImediaFactory)Activator.CreateInstance(“MediaLibrary”,factoryDllName).Unwrap();
* Imedia media = factory.CreateMedia();
* media.Play();

实现参见Gmail: 面向配置的程序设计


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
using System.Diagnostics;

{
static void Main(string[] args)
{
    // Create the source, if it does not already exist.
    if (!EventLog.SourceExists("MySource"))
    {
        //An event log source should not be created and immediately used.
        //There is a latency time to enable the source, it should be created
        //prior to executing the application that uses the source.
        //Execute this sample a second time to use the new source.
        EventLog.CreateEventSource("MySource", "MyNewLog");
        Console.WriteLine("CreatedEventSource");
        Console.WriteLine("Exiting, execute the application a second time to use the source.");
        // The source is created.  Exit the application to allow it to be registered.
        return;
    }

    // Create an EventLog instance and assign its source.
    EventLog myLog = new EventLog();
    myLog.Source = "MySource";

    // Write an informational entry to the event log.    
    myLog.WriteEntry("Writing to event log.");


}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

WPF: Windows Presentation Foundation ,”我佩服”

  • 由XAML代码和程序代码组成。
  • 一套代码Web与桌面应用程序都可作用。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

出现错误时,会将程序的执行状态转储到dmp文件中,可通过Windbg进行分析

  • 设置符号文件的地址: 在WinDbg 的菜单中: File–> Symbol File Path 中,设置 :SRV*DownstreamStore*http://msdl.microsoft.com/download/symbols
  • 以打开 minidump文件进行分析了 .  File–> Open Crash Dump ,
  • 在WinDbg 下面的命令行运行: !analyze -v 将得到详细的信息


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

perfmon:
1,开始运行:perfmon ,Ctrl+E:新增计数器集,右键增加计数器
2,计数器 性能对象:

  • ASP.NET State Service查看在线人数:State Server Sessions Active
  • ASP.NET:
  • Application Restarts:重启个数,如重新配置web.config引起重启等
  • Requests Queued:等候处理的要求数量。
  • ASP.NET Applications :Requests/Sec 每秒钟的请求数
  • SQL SERVER General Statistics:User Connections: 查看连接数
  • Physical Disk:Avg.Disk Queue Length
    PhysicalDisk: Current Disk Queue Length
    等待 I/O 请求的数量应该保持在不超过组成物理磁盘的轴数的 1.5 到 2倍。大多数磁盘只有一个轴,但独立磁盘冗余阵列 (RAID) 设备通常有多个轴。
    要提高性能,可增加磁盘。
    PhysicalDisk: % Disk Time 计数器的值大于90%为瓶颈,计数器监视磁盘忙于读/写活动所用时间的百分比

    Process:%Processor Time 如果该参数值持续超过95%,表明瓶颈是CPU。可以考虑增加一个处理器或换一个更快的处理器。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
firebug
lastpass :密码库
NoScript 禁止广告
web developer
IE Tab
chromifox Basic 主题
NetVideoHunter
flagfox
showIP
FoxyProxy
interclue
Greasemonkey
Greasefire
Stylish
colorZilla
MeasureIt
Download Statusbar


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,VS2008默认带有AJAX Extensions组件
2,局部刷新:UpdatePanel

  • 页面引入ScriptManager,设置EnablePartialRendering=”true”
  • 将需局部刷新的代码块用UpdatePanel包裹
  • 若想得到点击按纽触发局部刷新,设置UpdatePanel的Triggers

3,进度条:UpdateProgress: 它将显示页面上所有的UpdatePanel控件更新的进度信息。,
可用AssoicateUpdatePanelID指定关联的UpdatePanel

  • 页面放置UpdatePanel
  • 在UpdatePanel放置UpdateProgerss


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,网页传输数据是明文形式,实现https形式可以保证其安全,一种方式就是数字证书加密。
2,SSL位于于HTTP协议层与TCP协议层之间,用于建立用户与服务器之间的加密通信,它是依靠数字证书实现的。
3,数字证书实现:

* 为服务器安装证书服务,在系统安装盘。
* 配置网站:IIS-网站属性-目录安全性-安全通信:服务器证书,让系统自动生成一个。
* 配置网站:IIS-网站属性-目录安全性-安全通信:编辑,指定安全方式
* 利用https://网站域名访问


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

远程桌面:mstsc /v:192.168.16.101?? 新开桌面
远程协助:mstsc /v:192.168.16.101 /console 共用桌面


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

@@ROWCOUNT 返回受上一语句影响的行数,如select取出的行数,(可用此判断查询是否有结果),update更新的行数。
注:@@RowCount 是全局变量,它是基于session的,每个会话有自己的全局变量,在任一时间点下@@RowCount是安全的。 也就是说它永远是返回该session前一条sql所影响的行数.


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

?在正式环境的web.config中assemblies结点下加入:???
<add assembly=”System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A”/> 即可。
即:引用的系统命名空间在web.config的assemblies结点下存储。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

C#语法拾遗

1,using;

* using 命名空间名字;
* using 别名 = 包括详细命名空间信息的具体类型,以区别两个不同命名空间有相同的类名。
* using定义范围:即时释放资源,在范围结束时即时释放资源,
* 如: using (StreamWriter w = File.AppendText(“c:\\temp.txt”))
{
Log(context, w);
w.Close();
}

2,@符号的使用

* 将转义符当成一般字符使用:string s = @”c:\a.txt”;
* 忽略换行:string s =string s = @”sdf
sdf
sfsdf”;

3,预处理命令

* #warning 和#error : 若编译器遇到,则产生警告或错误信息,以提示开发者,而#error会直接退出编译
* 如:#warning : 测试使用,正式发布时请去掉下句代码
* #region description #endregion 将一段代码标记为一个指定名称的代码块,可直接折叠,便于阅读

4,对于引用类型,==类似于比较文件夹的路径是否相同,而equals()比较的是文件夹中的内容是否一样。注:对于string,==比较的是值。
原理:==比较的是栈,值变量存储在栈中,而引用类型地址也是存储在栈中。而equals比较的是堆,而引用类型的值就存在于堆中。
引用类型对应有多个字段,故地址存放于栈中,多个字段存放于堆中。

5,const是编译时常数,须在最开始赋初值,默认是static, 而readonly是运行是常数,默认不是static.

* const是编译时常数,故不能修饰引用类型,因为引用类型的构造要在运行时完成。不过string与null除外。
* 注:数组也是引用类型,同样不可用const修饰。
* const默认是static,故不可在非静态方法中修饰局部变量。

6,sealed:不可继承,断子绝孙。virtual与override进行覆盖。

7,变量与属性的区别:属性是对字段的一种封装,可以控制读写,体现了面向对象的封装性。

8,class与struct的区别:class是引用类型,内存分配于堆上,而struct是引用类型,内存分配于线程的栈上。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

实现的效果如下:
文库
步骤:
1,利用FileUpload控件做文件上传
2,转换:安装FlashPaper2.2,
在程序中调用cmd命令完成转换:
FlashPrinter.exe “test.doc” -o “test4.swf”
注:iis及应用程序池需开权限以执行FlashPrinter
如下:

try
{

Process p = new Process();

p.StartInfo.FileName = "cmd";

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;

p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

p.Start();

string strOutput = null;

string outputPath = Server.MapPath("~//test5.swf");
string s = @"FlashPrinter.exe "   + "\"" + FilePath + "\" -o \"" + outputPath + "\"";

p.StandardInput.WriteLine(s);

p.StandardInput.WriteLine("exit");

strOutput = p.StandardOutput.ReadToEnd();

Console.WriteLine(strOutput);

p.WaitForExit();

p.Close();

lblMessage.Text = "success";

embed1.Attributes.Add("src", outputPath);

}

catch (Exception ex)
{

lblMessage.Text = ex.ToString();

}

注:执行完之后可关掉进程
///?<summary>
 ///?根据进程名称来关闭进程
 ///?</summary>
 ///?<param?name="processName"></param>
 private?static?void?KillPrecess(string?processName)
 {
 foreach?(Process?p?in?Process.GetProcesses())
 {
 if?(p.ProcessName?==?processName)
 {
 p.Kill();
 }
 }?
 }

3,在线播放:若文档较小,一般的flash播放器即可。若文件很大,一次加载所有再显示文件的播放器显然会拖慢速度,这时需要了解的是一个开源的flexpaper播放器,它可以播放一帧一页的flash;要像百度文库、豆丁一样修改flexpaper,让它支持一次仅读取指定页数的flash;如果文档安全级别较高,不允许下载查看,则需要给flexpaper加上加密解密算法;如果需要登录用户才能查看,则要让flexpaper有登录UI。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

实体类与数据库表对应关系通过XML配置起来,那么当数据库表字段改变时,只需将配置文件将稍微的调整即可,而在类文件中因为使用的是实体类,没有直接与数据库表关系,所以数据库的改动将影响很小。
即:间接使用对象,使用对象与原来对象通过配置文件进行配置,一如DAO与BLL,也是注入配置而成。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
 1,页面放置控件FileUpload
 2,代码:
string FileName = fileUpload1.PostedFile.FileName;
FileName = FileName.Substring(FileName.LastIndexOf("\\") + 1);// 取出文件名的路径(不包括文件的名称)
string upload_file = Server.MapPath("./upload/") + FileName;//取出服务器虚拟路径,存储上传文件
fileUpload1.PostedFile.SaveAs(upload_file);//上传文件


常用属性:

(1)FileUpload1.HasFile用来检查 FileUpload是否有指定文件。

(2)HttpContext.Current.Request.MapPath("~/") 则是获取网站所在的磁盘绝对路径的,如D:\Inetpub\ServerControls\路径,之所以要这么做,是因为FileUpload控件必须指定“绝对路径”,而非相对路径,同时绝对路径也必须有写入权限。

(3)FileUpload1.SaveAs()则是将上传文件存储在磁盘的方法。

(4)FileUpload1.FileName用于获取上传文件名称。

(5)FileUpload1.PostedFile.ContentLength 用于设置或获取上传文件大小,以Byte为单位。

(6)FileUpload1.PostedFile.ContentType 用于设置或获取上传文件的类型 


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1.在google的搜索框里输入你的网站收录查询命令 site:www.enjoyasp.net然后点击搜索结果的页面最上端点击“打开百宝箱”,页面左边就会显示一个列表,在这里,你可以选择一天内,一周内和规定日期等等。

2,在结果页面的地址栏最后加上 &as_qdr=y9,搜索结果前面将会显示网站首次收录的时间。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
注意:对于命令行,若路径中带有空格时,如D:\My Documents\a.txt时,将找不到此路径,可采用以下两种方法:  
1,加引号如:"D:\My Documents\a.txt"
2,  变缩写:采用8个字符缩写,即写头六个字母(略去空白),另加波浪号和1 改成:D:\MyDocu~1
  
try
{

    Process p = new Process();

    p.StartInfo.FileName = "cmd";

    p.StartInfo.UseShellExecute = false;

    p.StartInfo.RedirectStandardInput = true;

    p.StartInfo.RedirectStandardOutput = true;

    p.StartInfo.RedirectStandardError = true;

    p.StartInfo.CreateNoWindow = true;

    p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

    p.Start();

    string strOutput = null;

    string s = @"F:\DownLoad\wenku\FlashPaper2.2\FlashPaper2.2\FlashPrinter.exe " + "\"" + Server.MapPath("~//test.doc") + "\" -o \"" + Server.MapPath("~//test2.swf") + "\"";
   
    p.StandardInput.WriteLine(s);

    p.StandardInput.WriteLine("exit");

    strOutput = p.StandardOutput.ReadToEnd();

    Console.WriteLine(strOutput);

    p.WaitForExit();

    p.Close();

   lblMessage.Text = "success";

}

catch (Exception ex)
{

   lblMessage.Text = ex.ToString();

}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

搜索多个关键字 以空格分开
不包含某个关键字 加减号: -排除

filetype:pdf 马克思 或者:file.baidu.com
1,搜索内容: 内容
2,搜索指定网站内容: enjoyasp site:www.nxgao.com
3,搜索链接:inurl:wp-admin
4,搜索指定网站链接 inurl:wp-admin site:wordpress.org
5,搜索网页内容 intext:enjoyasp.net
6,搜索关键字 intitle:enjoyasp.net
如:搜索外面引用本站的页面数: intext:enjoyasp.net -inurl:enjoyasp.net
查询后台登录界面:intitle:后台登陆