手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表Tag:zend

jQuery插件:图片自动缩放

同事需要,就写了个插件 。。。。
原来我也写过两个,但这次是正式为jQuery写的插件。。。

JavaScript代码
  1. $(document).ready(function(){  
  2.     $('div').autoResize({height:50});  
  3. });  
  4.   
  5. jQuery.fn.autoResize = function(options)  
  6. {  
  7.     var opts = {  
  8.         'width' : 400,  
  9.         'height': 300  
  10.     }  
  11.     var opt = $.extend(true, {},opts,options || {});  
  12.     width = opt.width;  
  13.     height = opt.height;  
  14.     $('img',this).each(function(){  
  15.         var image = new Image();  
  16.         image.src = $(this).attr('src');  
  17.         //开始检查图片  
  18.         if(image.width > 0 && image.height > 0 ){  
  19.             var image_rate = 1;  
  20.             if( (width / image.width) < (height / image.height)){  
  21.                 image_rate = width / image.width ;  
  22.             }else{  
  23.                 image_rate = height / image.height ;  
  24.             }  
  25.             if ( image_rate <= 1){  
  26.                 $(this).width(image.width * image_rate);  
  27.                 $(this).height(image.height * image_rate);  
  28.             }  
  29.         }  
  30.     });  
  31. }  

原来的两篇在这里:

 

Zend framework quickstart -> create project

仍然是quickstart的内容之一:create project

Create Your Project

In order to create your project, you must first install Zend Framework.

为了创建您的ZF项目,你必须先安装ZF框架

Install Zend Framework

The easiest way to get Zend Framework along with a complete PHP stack is by installing Zend Server. Zend Server has native installers for Mac OSX, Windows, Fedora Core, and Ubuntu, as well as a universal installation package compatible with most Linux distributions.

最简单安装ZF的方法就是安装ZendServer,ZendServer可以安装在苹果系统,windows, fedora,ubuntu,而且支持大多数的linux操作系统 。

After you have installed Zend Server, the Framework files may be found under /Applications/ZendServer/share/ZendFramework on Mac OSX, C:\Program Files\Zend\ZendServer\share\ZendFramework on Windows, and /usr/local/zend/share/ZendFramework on Linux. The include_path will already be configured to include Zend Framework.

在你安装完zendserver后,如果您是使用MAC系统,你将在/Applications/ZendServer/share/ZendFramework目录下找到框架文件,windows平台的话,是在, C:\Program Files\Zend\ZendServer\share\ZendFramework目录中,而linux平台则在/usr/local/zend/share/ZendFramework目录中。同时include_path也已经被配置好支持ZF框架了。

Alternately, you can download the latest version of Zend Framework and extract the contents; make a note of where you have done so.

当然你也可以直接下载ZF的最新版本并解压到你想使用的目录中

Optionally, you can add the path to the library/ subdirectory of the archive to your php.ini's include_path setting.

或者,你也可以把library这个目录加载到你的php.ini中的include_path设置中。

That's it! Zend Framework is now installed and ready to use.

这时候,ZF框架就已经被安装好并能够被使用了。

 

zf Command Line Tool ZF命令行工具
  1. In your Zend Framework installation is a bin/ subdirectory, containing the scripts zf.sh and zf.bat for Unix-based and Windows-based users, respectively. Make a note of the absolute path to this script.  
  2. 在你的ZF安装目录下,有两个可执行文件:zf.sh和zf.bat,他们分别对应着Unix平台和windows平台。记录下这个文件的绝对路径  
  3.   
  4. Wherever you see references to zf.sh or zf.bat, please substitute the absolute path to the script. On unix-like systems, you may want to use your shell's alias functionality: alias zf.sh=path/to/ZendFramework/bin/zf.sh.  
  5. 当你想要引用这zf.sh或者zf.bat文件 的时候,请先设置它的详细路径。例如在Unix平台下,你可以使用shell功能来进行替代:alias zf.sh=path/to/ZendFramework/bin/zf.sh  
  6.   
  7. If you have problems setting up the zf command-line tool, please refer to the manual.  
  8. 如果你还对ZF命令行工具有疑问,那就只能查看官方的手册了  

Open a terminal (in Windows, Start -> Run, and then use "cmd"). Navigate to a directory where you would like to start a project. Then, use the path to the appropriate script, and execute one of the following:

 

打开终端(在windows下面为:开始->运行->输入cmd),转到你想要创建项目的子目录中,开始就可以开始使用你刚才设置的路径来运行那两个script之一了。

 

XML/HTML代码
  1. # Unix:  
  2. % zf.sh create project quickstart  
  3.   
  4. # DOS/Windows:  
  5. C:> zf.bat create project quickstart  

Running this command will create your basic site structure, including your initial controllers and views. The tree looks like the following:

 

运行了这个命令,你将会得到ZF框架的项目的最基本结构,包含了初始化后的控制和和视图(controllers and vews),这个树形结构类似如下:

XML/HTML代码
  1. quickstart  
  2. |-- application  
  3. |   |-- Bootstrap.php  
  4. |   |-- configs  
  5. |   |   `-- application.ini  
  6. |   |-- controllers  
  7. |   |   |-- ErrorController.php  
  8. |   |   `-- IndexController.php  
  9. |   |-- models  
  10. |   `-- views  
  11. |       |-- helpers  
  12. |       `-- scripts  
  13. |           |-- error  
  14. |           |   `-- error.phtml  
  15. |           `-- index  
  16. |               `-- index.phtml  
  17. |-- library  
  18. |-- public  
  19. |   `-- index.php  
  20. `-- tests  
  21.     |-- application  
  22.     |   `-- bootstrap.php  
  23.     |-- library  
  24.     |   `-- bootstrap.php  
  25.     `-- phpunit.xml  

 

At this point, if you haven't added Zend Framework to your include_path, we recommend either copying or symlinking it into your library/ directory. In either case, you'll want to either recursively copy or symlink the library/Zend/ directory of your Zend Framework installation into the library/ directory of your project. On unix-like systems, that would look like one of the following:

在这点中,如果你没有将ZF框架加入到你的 include_path ,我们推荐你将它 COPY或者 symlinking到你的 library目录下。两种方法其中都是将library/Zend 目录 链至你的项目。在unlx系统中,它大致是这样操作的:

XML/HTML代码
  1. # Symlink:  
  2. % cd library; ln -s path/to/ZendFramework/library/Zend .  
  3.   
  4. # Copy:  
  5. % cd library; cp -r path/to/ZendFramework/library/Zend .  

On Windows systems, it may be easiest to do this from the Explorer.

 

在windows平台下,直接在资源管理器中就能够操作完毕。

Now that the project is created, the main artifacts to begin understanding are the bootstrap, configuration, action controllers, and views.

项目创建完毕后,the main artifact【不知道如何翻译】先了角解一下:bootstrap,configuration,action,controllers和views

The Bootstrap

Your Bootstrap class defines what resources and components to initialize. By default, Zend Framework's Front Controller is intialized, and it uses the application/controllers/ as the default directory in which to look for action controllers (more on that later). The class looks like the following:

Bootstrap类定义了资源和构成的初始化。默认情况下ZF只初始化了Front Controller【前端操作器】,它使用了 application/controllers 作为默认目录,在该目录里有着controller控制类的文件。bootstrap最初是这样的:

PHP代码
  1. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap  
  2. {  
  3. }  

As you can see, not much is necessary to begin with.

就你看到的内容来说,好象没有多少是必需的。

Configuration

While Zend Framework is itself configurationless, you often need to configure your application. The default configuration is placed in application/configs/application.ini, and contains some basic directives for setting your PHP environment (for instance, turning error reporting on and off), indicating the path to your bootstrap class (as well as its class name), and the path to your action controllers. It looks as follows:

ZF本身的配置是极少的,你通常需要为你自己的项目进行单独配置。默认的配置文件是/application/configs/application.ini,在文件中定义了一些PHP环境变量(如error_reporting的打开与否)和bootstrap类的路径(甚至是bootstrap类的名称),以前你的控制器的路径,内容如下:

XML/HTML代码
  1. ; application/configs/application.ini  
  2.   
  3. [production]  
  4. phpSettings.display_startup_errors = 0  
  5. phpSettings.display_errors = 0  
  6. includePaths.library = APPLICATION_PATH "/../library"  
  7. bootstrap.path = APPLICATION_PATH "/Bootstrap.php"  
  8. bootstrap.class = "Bootstrap"  
  9. resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"  
  10.   
  11. [staging : production]  
  12.   
  13. [testing : production]  
  14. phpSettings.display_startup_errors = 1  
  15. phpSettings.display_errors = 1  
  16.   
  17. [development : production]  
  18. phpSettings.display_startup_errors = 1  
  19. phpSettings.display_errors = 1  
Several things about this file should be noted. First, when using INI-style configuration, you can reference constants directly and expand them; APPLICATION_PATH is actually a constant. Additionally note that there are several sections defined: production, staging, testing, and development. The latter three inherit settings from the "production" environment. This is a useful way to organize configuration to ensure that appropriate settings are available in each stage of application development.

关于这个文件的必须要注意一些事。首先,当你使用ini格式的配置文件时,你可以直接引用常量,如APPLICATION_PATH就是一个常量。另外,还有一些选择器是默认定义过的:production,staging,testing和defelopment。后面三个设置都是从production的环境变量中扩展的。这样,你就可以很好的为你的项目开发进行适当的配置。

 

 

 原文:http://framework.zend.com/docs/quickstart/create-your-project

有点长,写的也乱。先写这么多,下次补全。

其实不太想翻译这个,毕竟太初级了。。。我想翻译的是这个:http://devzone.zend.com/tag/PHP101

但是翻译现在这个QuickStart是可以让我在言语组织上学习点东西。先为我想翻译的东西打点基础吧。

 

 

 

 

 

 

哦哦哦,电池要被召回了

昨天把笔记本带到学校去用的时候,发现用了半小时突然提示没电,一直以为是电池长时间插着充电,需要激活的原因。
于是晚上回来进行了一次电池重置,到早上还没有结束。就关闭了。

然后把电源拔掉使用,又是半小时,突然提示没电。这才发现电池好象坏了。

把电池的型号进行搜索,发现居然是联想召回电池中的一款。郁闷啊。下载了测试软件进行测试,还真的有提示:http://batteryprogram.lenovo.com/ljbr/ValidateQuery.aspx?mt=7674&mm=HE1&ms=LV16N17&bbc=532FA251B4CE0B3FB64F4A4702A8735EBFE2999865874C5D9B6B6B640066B95772BC3ADD8C281AD19B6664CBB74E11C14BDF1DE7FFA60B0E0EAACA1BBC27569A&bf=1755C8FE9BDD2EC3920C06111C622AC6CEF389C52338E39AEAB73E19ACA96915C41A0E08E67B67ABCEB9AE50B5B256AC8F97E8E1ECD63BE2653136121D6C7DDC&ll=zh

准备打电话,可心里紧张,毕竟是水货。唉。。。。早知道不买水货了,购买商的素质又低,换根电源线都要拖个一星期。

如果不能召回更换,只能淘宝购买了。。。

Tags: 联想, thinkpad, 42t4568

FireFox下载将破10亿次 占浏览器市场份额超30%

firefox虽然吃内存很厉害,但不失为一个不错的浏览器。目前已经全部基于firefox在应用。只是让我痛苦的是,几乎所有的银行都 不支持。。。再支持一下吧。

http://www.cnbeta.com/articles/89942.htm

Mozilla基金会FireFox浏览器下载总量即将突破10亿次,这将是FireFox浏览器的一个重大里程碑.
微型博客Twitter上设立了一个专门统计FireFox浏览器下载次数的帐号.该帐号页面提供的数据显示,美国东部时间7月30日清晨(北京时间7月 30日夜间),FireFox浏览器的下载总次数已达到9.99亿次.按照用户下载FireFox浏览器的速度计算,FireFox浏览器下载总量最快将 在明日突破10亿次.

Mozilla 目前正准备设立一个新网站,庆祝FireFox浏览器下载总量突破10亿次这一历史性时刻的到来.该网站的网址为 www.onebillionplusyou.com.目前,该网站还未正式上线,准备在下周一正式上线.在该网站上,用户可以查阅到有关FireFox 浏览器发展历程的相关信息.

在过去的几年里,FireFox浏览器已成为了浏览器市场一支不可小觑的力量,并吞噬了IE浏览器不少的市场份额.最新的统计数据显示,IE浏览器的市场份额仅为54%,FireFox的份额已超过30%.要知道,几年前IE浏览器还占有市场超过90%的份额.

很明确,10亿次的下载数量包括了自2002年发布以来(尽管FireFox这一名称自2004年正式启用)各种版本的FireFox浏览器下载数量.一 个月前刚发布的FireFox 3.5,在发布之后受到了用户追捧.仅仅发布一天时间,FireFox3.5的下载次数就达到了500万次.尽管这一下载量非常大,但仍不及 FireFox3.0上市后受用户追捧的程度.

简单的处理thunder,flashget,qqdl的加密下载字符串

其实这些东西都是根据网上的资料来解决的。
那些下载字符串,在去除协议后,都是采用BASE64加密过,所以,先解密一下,再处理,就很方便了。

其中,迅雷是在解密后的字符串两头加了“AA”和“ZZ”两个字符串
flashget则是加了[FLASHGET]标签
QQ则最简单,啥也没加,解密后就能用。

flashget在处理前,需要先把&以后的字符串全部清空再作Base64的解密转换。

不多说,源码如下:

PHP代码
  1. function decode ( $string )  
  2. {  
  3.     $exp = explode"://"$string );  
  4.     $type = strToLower$exp[0] );  
  5.     if ( $type == 'thunder' ){  
  6.         return str_replace(array("AA","ZZ"),"",base64_decode$exp[1] ));  
  7.     }else if ( $type == 'flashget' ){  
  8.         $exp[1] = subStr$exp[1], 0 , strPos$exp[1], '&' ) );  
  9.         return str_ireplace("[flashget]","",base64_decode$exp[1] ));  
  10.     }else if ( $type == 'qqdl' ){  
  11.         return base64_decode$exp[1] );  
  12.     }  
  13. }  
Records:201234