All posts by 龙生
不小心把所有的快捷方式lnk文件都设置成了用Word打开,该怎么改回来
1 2 3 4 5 |
1、点开始,点运行,输入REGEDIT,回车; 2、找到HKEY_CURRENT_USER\Software\Microsoft\Windows\currentVersion\Explorer\fileExts\.lnk,然后删除掉; 3、点开始,点运行,输入“assoc .lnk=lnkfile”,回车,重启,就可以啦; FROM:http://zhidao.baidu.com/link?url=iLUvY1xoo_49Z69p9M3Flf3n7KK9VvEJyP8ZlUAC83MHbd87Qn8zf-TxB7VrcprJXbHb2680Iuv1D3bN1Eo1Oa |
Mac下Photoshop CS6 简体中文版的安装和离线激活
大师版有注册机,但没中文版;单photoshop中文版,没注册机。我整合了一下,找了个可用的序列号,用大师版注册机离线激活。经过测试,已完美激活,可升级!1、下载photoshop单文件简体中文版官方:http://trials2.stage.adobe.com/A … hotoshop_13_LS3.dmg用迅雷下载就可以了2、断网。 确认/etc/hosts没有下面两行: 127.0.0.1 lmlicenses.wip4.adobe.com 127.0.0.1 lm.licenses.adobe.com 如果以前安装过,请删除下面两个目录: /Library/Application Support/Adobe/SLStore /Library/Application Support/Adobe/SLCache3、打开安装文件,选择安装(不是试用!),填入下面的序列号: 1330-1730-0041-7458-1356-16534、装好后打开photoshop,确认链接问题,选择离线激活,生成请求码。5、打开注册机,填入上面的序列号(不能用注册机生成的序列号,那是大师版的)和请求码,生成激活码。6、激活成功。7、在/etc/hosts加入:(或者用管理员运行注册机附带的disable_activation_osx也是一样的) # Adobe Blocker 127.0.0.1 lmlicenses.wip4.adobe.com 127.0.0.1 lm.licenses.adobe.com8、好吧,现在可以联网、升级。9、Enjoy!附:注册机(就是大师版的注册机,我把windows版的文件去除了,已经下载的略过) Crack-OSX FROM:http://bbs.feng.com/read-htm-tid-5011699.html
View DetailsIIS6中配置FastCGI运行PHP
环境说明: 操作系统:使用windows 2003 server 32位系统,IIS6。 PHP版本:官方下载PHP 5.3.26 VC9 x86 Non Thread SafeZIP版本。 IIS6 FastCGI安装包:FastCGI for IIS x86版本。 PHP路径:C:\php-5.3.26\ FastCGI相关文件和路径 : C:\WINDOWS\system32\inetsrv\fcgiext.dll C:\WINDOWS\system32\inetsrv\fcgiext.ini 配置步骤: 解压PHP文件,修改目录名放到C盘。目录地址为C:\php-5.3.26\ 复制php.ini-production改名为php.ini,先参考PHP.ini参数说明修改。 并修改PHP对FastCGI支持: 安装下载的FastCGI for IIS工具,本文下载的文件名为fcgisetup_1.5_rtw_x86.msi。安装完成后无提示,直接打开文件C:\WINDOWS\system32\inetsrv\fcgiext.ini在最后[Types]后添加以下
1 2 3 4 5 6 7 8 9 |
[Types] php=PHP [PHP] ExePath=C:\php-5.3.26\php-cgi.exe InstanceMaxRequests=10000 ActivityTimeout=600 RequestTimeout=600 EnvironmentVars=PHP_FCGI_MAX_REQUESTS:10000,PHPRC:C:\php-5.3.26\ |
检查IIS是否配置正确了FastCGI的调用。如下图: from:http://www.magicwinmail.com/setupiis/iis6fastcgi.html
View Details值得收藏的十二条Jquery随身笔记
1、关于页面元素的引用 通过jquery的$()引用元素包括通过id、class、元素名以及元素的层级关系及dom或者xpath条件等方法,且返回的对象为jquery对象(集合对象),不能直接调用dom定义的方法。 2、jQuery对象与dom对象的转换 只有jquery对象才能使用jquery定义的方法。注意dom对象和jquery对象是有区别的,调用方法时要注意操作的是dom对象还是jquery对象。 普通的dom对象一般可以通过$()转换成jquery对象。 如:$(document.getElementById("msg"))则为jquery对象,可以使用jquery的方法。 由于jquery对象本身是一个集合。所以如果jquery对象要转换为dom对象则必须取出其中的某一项,一般可通过索引取出。 如:$("#msg")[0],$("div").eq(1)[0],$("div").get()[1],$("td")[5]这些都是dom对象,可以使用dom中的方法,但不能再使用Jquery的方法。 以下几种写法都是正确的: $("#msg").html(); $("#msg")[0].innerHTML; $("#msg").eq(0)[0].innerHTML; $("#msg").get(0).innerHTML; 3、如何获取jQuery集合的某一项 对于获取的元素集合,获取其中的某一项(通过索引指定)可以使用eq或get(n)方法或者索引号获取,要注意,eq返回的是jquery对象,而get(n)和索引返回的是dom元素对象。对于jquery对象只能使用jquery的方法,而dom对象只能使用dom的方法,如要获取第三个<div>元素的内容。 有如下两种方法: $("div").eq(2).html(); //调用jquery对象的方法 $("div").get(2).innerHTML; //调用dom的方法属性 4、同一函数实现set和get Jquery中的很多方法都是如此,主要包括如下几个: $("#msg").html(); //返回id为msg的元素节点的html内容。 $("#msg").html("<b>new content</b>"); //将“<b>new content</b>” 作为html串写入id为msg的元素节点内容中,页面显示b加粗的new content $("#msg").text(); //返回id为msg的元素节点的文本内容。 $("#msg").text("<b>new content</b>"); //将“<b>new content</b>” 作为普通文本串写入id为msg的元素节点内容中,页面显示<b>new content</b> $("#msg").height(); //返回id为msg的元素的高度 $("#msg").height("300"); //将id为msg的元素的css高度设为300 $("#msg").width(); //返回id为msg的元素的css宽度 $("#msg").width("300"); //将id为msg的元素的宽度设为300 $("input").val("); //返回表单输入框的value值 $("input").val("test"); //将表单输入框的value值设为test $("#msg").click(); //触发id为msg的元素的单击事件 $("#msg").click(fn); //为id为msg的元素单击事件添加函数 同样blur,focus,select,submit事件都可以有着两种调用方法 5、集合处理功能 对于jquery返回的集合内容无需我们自己循环遍历并对每个对象分别做处理,jquery已经为我们提供的很方便的方法进行集合的处理。 包括两种形式: $("p").each(function(i){this.style.color=['#f00′,’#0f0′,’#00f'][ i ]}) //为索引分别为0,1,2的p元素分别设定不同的字体颜色。 $("tr").each(function(i){this.style.backgroundColor=['#ccc',’#fff'][i%2]}) //实现表格的隔行换色效果 $("p").click(function(){alert($(this).html())}) //为每个p元素增加了click事件,单击某个p元素则弹出其内容 6、扩展我们需要的功能 $.extend({min: function(a, b){return a < b?a:b; }, max: function(a, b){return a > b?a:b; } }); //为jquery扩展了min,max两个方法使用扩展的方法(通过“$.方法名”调用): alert("a=10,b=20,max="+$.max(10,20)+",min="+$.min(10,20)); 7、支持方法的连写 所谓连写,即可以对一个jquery对象连续调用各种不同的方法。 例如: $("p").click(function(){alert($(this).html())}) […]
View Detailsarray_slice() 函数
定义和用法 array_slice() 函数在数组中根据条件取出一段值,并返回。 注释:如果数组有字符串键,所返回的数组将保留键名。(参见例子 4) 语法
1 |
array_slice(<i>array</i>,<i>offset</i>,<i>length</i>,<i>preserve</i>) |
参数 描述 array 必需。规定输入的数组。 offset 必需。数值。规定取出元素的开始位置。 如果是正数,则从前往后开始取,如果是负值,从后向前取 offset 绝对值。 length 可选。数值。规定被返回数组的长度。 如果 length 为正,则返回该数量的元素。 如果 length 为负,则序列将终止在距离数组末端这么远的地方。 如果省略,则序列将从 offset 开始直到 array 的末端。 preserve 可选。可能的值: true – 保留键 false – 默认 – 重置键 例子 1
1 2 3 4 |
<?php $a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird"); print_r(array_slice($a,1,2)); ?> |
输出:
1 |
Array ( [0] => Cat [1] => Horse ) |
例子 2 带有负的 offset 参数:
1 2 3 4 |
<?php $a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird"); print_r(array_slice($a,-2,1)); ?> |
输出:
1 |
Array ( [0] => Horse ) |
例子 3 preserve 参数设置为 true:
1 2 3 4 |
<?php $a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird"); print_r(array_slice($a,1,2,true)); ?> |
输出:
1 |
Array ( [1] => Cat [2] => Horse ) |
例子 4 带有字符串键:
1 2 3 4 |
<?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse","d"=>"Bird"); print_r(array_slice($a,1,2)); ?> |
输出:
1 |
Array ( [b] => Cat [c] => Horse ) |
C#集合类Queue
队列(Queue)在程序设计中扮演着重要的角色,因为它可以模拟队列的数据操作。例 如,排队买票就是一个队列操作,新来的人排在后面,先来的人排在前面,并且买票请求 先被处理。为了模拟队列的操作,Queue在ArrayList的基础上加入了以下限制: · 元素采用先入先出机制(FIFO,First In First Out),即先进入队列的元素必须先离 开队列。最先进入的元素称为队头元素。 · 元素只能被添加到队尾(称为入队),不允许在中间的某个位置插入。也就是说, 不支持ArrayList中的Insert方法。 · 只有队头的元素才能被删除(称为出队),不允许直接对队列中的非队头元素进行 删除,从而保证FIFO机制。也就是说,不支持ArrayList中的Remove方法。 · 不允许直接对队列中非队头元素进行访问。也就是说,不支持ArrayList中的索引访 问,只允许遍历访问。 下面的实例展示了如何创建Queue对象,并向Queue对象中入队数据、出队数据、遍历 数据。 创建TestQueue类,在TestQueue.cs中输入如下代码: using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace Chapter12 { class TestQueue { static void Print(Queue list) { Console.Write("队列内容:"); foreach (string str in list) System.Console.Write(str + " "); } static void Main(string[] args) { Queue list = new Queue(); //Add elements Console.WriteLine("输入字符串添加到队列(#号结束):"); string str; do { str = Console.ReadLine(); if (str == "#") break; else { list.Enqueue(str); } } while (true); TestQueue.Print(list); Console.WriteLine(); //Remove elements Console.WriteLine("出队字符串:"); while (list.Count != 0) […]
View Detailsvolatile(C# 参考)
volatile 关键字指示一个字段可以由多个同时执行的线程修改。 声明为 volatile 的字段不受编译器优化(假定由单个线程访问)的限制。 这样可以确保该字段在任何时间呈现的都是最新的值。 volatile 修饰符通常用于由多个线程访问但不使用 lock 语句对访问进行序列化的字段。 volatile 关键字可应用于以下类型的字段: 引用类型。 指针类型(在不安全的上下文中)。 请注意,虽然指针本身可以是可变的,但是它指向的对象不能是可变的。 换句话说,您无法声明“指向可变对象的指针”。 类型,如 sbyte、byte、short、ushort、int、uint、char、float 和 bool。 具有以下基类型之一的枚举类型:byte、sbyte、short、ushort、int 或 uint。 已知为引用类型的泛型类型参数。 IntPtr 和 UIntPtr。 可变关键字仅可应用于类或结构字段。 不能将局部变量声明为 volatile。 示例 下面的示例说明如何将公共字段变量声明为 volatile。 C#
1 2 3 4 5 6 7 8 9 |
<span style="color: blue;">class</span> VolatileTest { <span style="color: blue;">public</span> <span style="color: blue;">volatile</span> <span style="color: blue;">int</span> i; <span style="color: blue;">public</span> <span style="color: blue;">void</span> Test(<span style="color: blue;">int</span> _i) { i = _i; } } |
下面的示例演示如何创建辅助线程,并用它与主线程并行执行处理。 有关多线程处理的背景信息,请参见托管线程处理和线程处理(C# 和 Visual Basic)。 C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
<span style="color: blue;">using</span> System; <span style="color: blue;">using</span> System.Threading; <span style="color: blue;">public</span> <span style="color: blue;">class</span> Worker { <span style="color: green;">// This method is called when the thread is started.</span> <span style="color: blue;">public</span> <span style="color: blue;">void</span> DoWork() { <span style="color: blue;">while</span> (!_shouldStop) { Console.WriteLine(<span style="color: #a31515;">"Worker thread: working..."</span>); } Console.WriteLine(<span style="color: #a31515;">"Worker thread: terminating gracefully."</span>); } <span style="color: blue;">public</span> <span style="color: blue;">void</span> RequestStop() { _shouldStop = <span style="color: blue;">true</span>; } <span style="color: green;">// Keyword volatile is used as a hint to the compiler that this data</span> <span style="color: green;">// member is accessed by multiple threads.</span> <span style="color: blue;">private</span> <span style="color: blue;">volatile</span> <span style="color: blue;">bool</span> _shouldStop; } <span style="color: blue;">public</span> <span style="color: blue;">class</span> WorkerThreadExample { <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main() { <span style="color: green;">// Create the worker thread object. This does not start the thread.</span> Worker workerObject = <span style="color: blue;">new</span> Worker(); Thread workerThread = <span style="color: blue;">new</span> Thread(workerObject.DoWork); <span style="color: green;">// Start the worker thread.</span> workerThread.Start(); Console.WriteLine(<span style="color: #a31515;">"Main thread: starting worker thread..."</span>); <span style="color: green;">// Loop until the worker thread activates.</span> <span style="color: blue;">while</span> (!workerThread.IsAlive) ; <span style="color: green;">// Put the main thread to sleep for 1 millisecond to</span> <span style="color: green;">// allow the worker thread to do some work.</span> Thread.Sleep(1); <span style="color: green;">// Request that the worker thread stop itself.</span> workerObject.RequestStop(); <span style="color: green;">// Use the Thread.Join method to block the current thread </span> <span style="color: green;">// until the object's thread terminates.</span> workerThread.Join(); Console.WriteLine(<span style="color: #a31515;">"Main thread: worker thread has terminated."</span>); } <span style="color: green;">// Sample output:</span> <span style="color: green;">// Main thread: starting worker thread...</span> <span style="color: green;">// Worker thread: working...</span> <span style="color: green;">// Worker thread: working...</span> <span style="color: green;">// Worker thread: working...</span> <span style="color: green;">// Worker thread: working...</span> <span style="color: green;">// Worker thread: working...</span> <span style="color: green;">// Worker thread: working...</span> <span style="color: green;">// Worker thread: terminating gracefully.</span> <span style="color: green;">// Main thread: worker thread has terminated.</span> } from:http://msdn.microsoft.com/zh-cn/library/x13ttww7.aspx |
ManualResetEvent详解
1. 源码下载: 下载地址:http://files.cnblogs.com/tianzhiliang/ManualResetEventDemo.rar Demo: 2. ManualResetEvent详解 ManualResetEvent 允许线程通过发信号互相通信。通常,此通信涉及一个线程在其他线程进行之前必须完成的任务。当一个线程开始一个活动(此活动必须完成后,其他线程才能开始)时,它调用 Reset 以将 ManualResetEvent 置于非终止状态,此线程可被视为控制 ManualResetEvent。调用 ManualResetEvent 上的 WaitOne 的线程将阻止,并等待信号。当控制线程完成活动时,它调用 Set 以发出等待线程可以继续进行的信号。并释放所有等待线程。一旦它被终止,ManualResetEvent 将保持终止状态(即对 WaitOne 的调用的线程将立即返回,并不阻塞),直到它被手动重置。可以通过将布尔值传递给构造函数来控制 ManualResetEvent 的初始状态,如果初始状态处于终止状态,为 true;否则为 false。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ManualResetEventDemo { class MREDemo { private ManualResetEvent _mre; public MREDemo() { this._mre = new ManualResetEvent(true); } public void CreateThreads() { Thread t1 = new Thread(new ThreadStart(Run)); t1.Start(); Thread t2 = new Thread(new ThreadStart(Run)); t2.Start(); } public void Set() { this._mre.Set(); } public void Reset() { this._mre.Reset(); } private void Run() { string strThreadID = string.Empty; try { while (true) { // 阻塞当前线程 this._mre.WaitOne(); strThreadID = Thread.CurrentThread.ManagedThreadId.ToString(); Console.WriteLine("Thread(" + strThreadID + ") is running…"); Thread.Sleep(5000); } […]
View Details浅谈ThreadPool 线程池
相关概念: 线程池可以看做容纳线程的容器; 一个应用程序最多只能有一个线程池; ThreadPool静态类通过QueueUserWorkItem()方法将工作函数排入线程池; 每排入一个工作函数,就相当于请求创建一个线程; 线程池的作用: 线程池是为突然大量爆发的线程设计的,通过有限的几个固定线程为大量的操作服务,减少了创建和销毁线程所需的时间,从而提高效率。 如果一个线程的时间非常长,就没必要用线程池了(不是不能作长时间操作,而是不宜。),况且我们还不能控制线程池中线程的开始、挂起、和中止。 什么时候使用ThreadPool? ThreadPool 示例一 : ThreadPool_1.cs using System; using System.Text; using System.Threading; namespace 多线程 { public class Example { public static void Main() { // Queue the task. ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc)); Console.WriteLine("Main thread does some work, then sleeps."); Thread.Sleep(1000); Console.WriteLine("Main thread exits."); } static void ThreadProc(Object stateInfo) { // No state object was passed to QueueUserWorkItem, // so stateInfo is null. Console.WriteLine("Hello from the thread pool."); } } } ThreadPool 示例二 : ThreadPool_2.cs using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace CS_Test { class ThreadPool_Demo { // 用于保存每个线程的计算结果 static int[] result = new int[10]; //注意:由于WaitCallback委托的声明带有参数, // 所以将被调用的Fun方法必须带有参数,即:Fun(object obj)。 static void Fun(object obj) { int n = (int)obj; //计算阶乘 int fac = 1; for (int i = 1; i <= n; i++) { fac *= i; } //保存结果 result[n] = fac; } static void Main(string[] args) { //向线程池中排入9个工作线程 for (int i = 1; i <= 9 ; i++) { //QueueUserWorkItem()方法:将工作任务排入线程池。 ThreadPool.QueueUserWorkItem(new WaitCallback(Fun),i); // Fun 表示要执行的方法(与WaitCallback委托的声明必须一致)。 // i 为传递给Fun方法的参数(obj将接受)。 } //输出计算结果 for (int i = 1; i <= 9; i++) { Console.WriteLine("线程{0}: {0}! = {1}",i,result[i]); } } } } ThreadPool的作用: 参考来源: C#多线程学习(四) 多线程的自动管理(线程池) [叩响C#之门]写给初学者:多线程系列( 十一)——线程池(ThreadPool) from:http://www.cnblogs.com/xugang/archive/2010/04/20/1716042.html
View Details维基逃离MySQL 力挺开源数据库
MariaDB也是由MySQL创始人发明的。并且由于MySQL被甲骨文收购,正在成为开源数据库的主流。 据悉,维基传媒基金会负责网站架构的高层Asher Feldman透露,他最近将维基百科中的英文百科全书,转移到了MariaDB 5.5.28数据库。他透露,明年一季度末期,有望把整个百科全书切换到新的开源数据库。 在谈到更换数据库平台的原因时,这位高层表示,主要目的并不是新数据库性能更好,维基传媒基金会以及整个开源社群,都希望能够推动开源数据库MariaDB的普及。 MariaDB官网 我们可以从MariaDB官网上看到,MariaDB数据库的定位就是MySQL的替代者。 有国外媒体指出,此次维基百科选用MariaDB,势必让全球诸多采用Linux, Apache, MySQL, PHP/Python/Perl (LAMP)套件技术的开发者更多关注MariaDB。 from:http://database.51cto.com/art/201212/373189.htm
View Details