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

我想说一句话

对于今天晚上的闭幕式,我有一句话要讲:春晚,又见春晚。
相对于贝克汉姆的出场,和最终的群星演唱,我实在想不出有什么可以形容我的心情的。对比于历年可见的类似节目,我只能感慨一下,今年我提前看到了春晚。
估计和我有同样想法的人不在少数吧?什么事情都是虎头蛇尾的,也应该算是我们的风俗了。可怜最后几个明星演出。我只看到了三个人。还有一个穿白衣的,我死活看不到脸。

镜头,走位。唉。。。拍摄风格也是和春晚相差无几,我还能说什么?

Tags: 春晚, 闭幕式, 贝克汉姆, 伦敦

[翻译][未完成版本]Developing Desktop Applications in PHP for Beginners.

Introduction:
简价

We have been creating web-applications using PHP since it came into existence, now we can also develop Desktop or Stand alone Applications with PHP-GTK. Desktop Applications are one which does not need either a Web Server like IIS, Apache, PWS etc. or a web browser for their execution. One of the reasons why Java is so popular is because it can be used to build applications, web pages, applets and beans that can run on several platforms including Windows, Linux and Solaris. Java runs a virtual machine called JVM, and code is compiled into an intermediate format known as Java byte code, which is platform independent. When that particular piece of code is executed within the JVM, the JVM optimizes the code for the particular platform on which it is running as it is being compiled.
从PHP产生到现在,我们一直都是使用它创建WEB应用,如今,我们也可以使用PHP-GTK来创建桌面或者其他杰出的应用。桌面程序不再依靠WEB服务器(比如IIS、APACHE、PWS等等)或者通过浏览器运行他们。JAVA为什么这么流行其中之一的原因就是他不仅可以创建程序、WEB应用,小应用程序Applets和Beans,而是他可以运行在windows、linux和solaris平台上。当这些特定的代码在JVM上运行的时候,JVM会在编译的时候针对特定联台而对代码进行优化。

Microsoft's latest technology, .NET follows the same principles. Code is compiled into Microsoft Intermediate Language (MSIL) and is then executed within the .NET framework as an application domain. Microsoft is hoping to standardize C# and MSIL so that .NET code can run cross platform.

微软最近的技术声称,.net一直遵循着同样的工作原因,代码被编译成MSIL并且运行在.net framework上。微软一直希望C#和MSIL能够标准化,这样.net下的代码也就能够相对的跨平台运行了。

So what has all of this got to do with PHP-GTK? Well, both Java and .NET can be used to build windowed applications and web pages. Thanks to PHP-GTK, we can now build cross platform windowed applications with PHP as well.

可是这和使用PHP-GTK又有什么关系呢?OK,java和.net都能够创建“窗口式应用”(桌面应用软件)和网页。感谢PHP-GTK,我们也可以使用PHP创建跨平台的“winform应用”(windowed applications一直不知道怎么翻译比较好,下面如果再提到,我想,我还是用桌面应用软件来代替吧。)。

What is PHP-GTK?
PHP-GTK是什么?

GTK is an acronym for the GIMP Toolkit and GIMP is an acronym for GNU Image Manipulation Program, and is a fully featured graphics editing program that runs on Linux. It has many (if not all) of the features of popular Windows programs such as Photoshop and Paint shop. It's the graphics editor of choice for most Linux users.

GTK是GIMP ToolKit(GIMP工具包)的缩写,同时GIMP又是GNU Image Manipulation Program(开源图像处理软件)的缩写,是一个可以运行在LInux下的一款图像编辑程序。它拥有与windows平台下的photoshop和画笔程序一些相同的功能,但并非全部。它是大多数Linux用户所选择的图形编辑工作。

GTK is actually part of a set of libraries that was written in C called GTK+. GTK+ was built up over time and is now a main part of Gnome, which is a Linux GUI desktop environment. GTK+ is based on an object-oriented nature and also includes two other libraries:
GTK实际上是一套用C语言编码的代码库,一般称为GTK+。GTK+一直以来就是Gnome(Linux图形界面)的重要部件之一。GTK+采用了面向对象的方面,并且引入其他两个重要的库:

  1. GLib: A library of tools that can be used to assist developers when creating applications with GTK+.
  2. GDK: Similar to GDI for Win32, GDK standard for GIMP drawing kit and wraps a set of lower level drawing functions into classes that make developing applications with GTK+ easier. If you're thinking along the lines of MFC for C++ then you're making a fair comparison: MFC wraps several controls and hides the calls to the underlying Windows API's from the developer. GDK does the same thing for GTK+.

Where to get?

We can download binary as well as source code version of PHP-GTK from http://gtk.php.net/download.php . As a beginner, it would be a difficult process to download and install in this manner. Where we need to set up another php.ini file for PHP-GTK. Instead there is another way of installing it. We can get PHP-GTK2 in an executable form as we get WAMP.EXE. (Windows, Apache, Mysql, PHP) All we have to do is just download just download the files from http://www.gnope.org/download.php ,unzip them and double click on the icon GnopeSetup-1.5.1.exe . It will run through a step by step process where it will set up PHP-GTK automatically.

How to test the installation?

Once the installation is done we would eager to know about what is special in it? When we install PHP we would run phpinfo () from root directory .For this let us run a sample script which displays Hello world (as usual) .we can use Dreamweaver for editing the code. Another important point to be kept in mind is to save the file with extension .phpw it can be saved anywhere on your hard disk.

Here is the sample code:

 

<?PHP
if (!class_exists('gtk')) {
die("Please load the php-gtk2 module in your php.ini");
}
$wnd = new GtkWindow();
$wnd->set_title('Hello world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
$lblHello = new GtkLabel("hello world");
$wnd->add($lblHello);
$wnd->show_all();
Gtk::main();
?>

 

I have saved this sample file with the name hello.phpw at c:\test\. We should run this sample code from command line interface. (CLI) There may be a question rising in your mind asking, why we should run through command prompt than by just by double clicking it as it is a stand alone application. It is possible, for that we need to have a PHP compiler which converts our PHP-GTK code to EXE file . For now, let us try running it from the command prompt.
现在我们将上面这段代码保存在c:\test\目录下,取名为:hello.phpw。我们可以在命令行下运行它。或许你会有疑问,为什么我们不是编译成一个正常的程序,可以通过双击来运行?当然,这不是问题,那样的话,我们需要通过我们的PHP-GTK程序把PHP代码转换成EXE文件。现在,让我们尝试运行一下这个命令行先。

Steps for Executing a sample code:
执行部骤

  1. Start -> Run -> cmd (for xp sp2 and later version) or command (for windows 98).
    点击开始菜单->运行,输入cmd,如果是windows2000以前的版本,请输入command。
  2. Now you could see a black window which is Command Prompt. Key in the following commands as shown below.

 

z:>c:
c:> cd test
c:\test>php hello.phpw

Once we finish this line and hit the Enter key, we should see the desired output.

This shows the successful installation of PHP-GTK2 and shouls us PHP output without a web-browser.

Some interesting Websites on PHP-GTK:

  1. http://www.kksou.com/php-gtk2/
  2. http://phpgtk.activeventure.com/gtk/gtk.gtkbox.html (describes about all base classes).
  3. http://gtk.php.net/download.php
  4. http://www.gnope.org/download.php

Tags: gtk, php, application, develop, desktop

请把最后一点纯真留给孩子

CCC透漏,YYY小朋友的落选主要是因为考虑到对外形象,是为了国家利益。

部分网友表示认同,称林杪可与YYY都是“英雄”。但是也有网友进行了反驳,认为“假唱不好,让小孩假唱更甚”、“请把最后一点纯真留给孩子”。

是不是有点没头没脑的?那是因为我担心网站上有了不该有的内容会被别人起诉。详细情况请看:http://eladies.sina.com.cn/news/2008/0812/1222752889.shtml

Tags: 失望, 纯真, 欺骗

意外的收获

飞天小肥猪的简单人生
100.0%男性倾向,0.0%女性倾向
   
评点:您的文风冷静而镇定,言语间展现出强悍的思辨能力与恢宏的胸襟,一个男子汉的阳刚形象跃然纸上。
yodao | 博客男女

看到上面的内容没有?上面的可不是我自己写的,哇哈哈哈。其实很意外,在搜索一些RSS的时候,看到了这个。然后自己检测了一下,就是这个结果。当然我也不知道它的算法是什么样的。为什么会这样。但既然是博君一样,总归是需要有点好结果的吧?本来想把复制过来的URL链接去掉的,但想想,别人也是一片心血,也做了一个这样的玩意给我们大家娱乐,总要给点别人面子的吧?
下面的还是在有道网上生成的一个FLASH,本来想放到左侧去,但想想左侧被我更多的用来使用显示广告了。因此还是先留在这里。不过我会有想法等我文章内页的广告到期后,换成首页的那个BLOGUP,然后BLOGUP的位置放上这个玩意。


定制我的博客魔方 Yodao提供

Tags: 博客, 评分, 有道, 博客男女

主键和外键的设计原则

从MYSQL4.1开始,它终于支持了外键。在数据库设计中,主键和外键是一种能够把多个表组织为一个有效的关系数据库的粘合剂。它们的设计良好与否对数据库的性能和可用性有着决定性的影响。

不得不说的是,在系统设计的时候,必须将数据库模式从理论上的逻辑设计转换为实际的物理设计。而主键和外键的结构是这个设计过程的症结所在。毕竟,一旦将所设计的数据库用于了生产环境,就很难对他们进行修改,因此,在开发阶段设计好主键和外键就显得犹为重要。

对于主键而言,它是不可被重复的,而且尽量不包含特殊含义,毕竟主键的使用只是为了让数据库多一条高效的索引,而且在被外部引用的时候不会产生重复。同样重要的是主键最好不要和其他键一起组成复合主键,而应该单独用一列来表示。

正因为主键的特殊性,所以在大多数情况下我们都采用了自增字段来表示(但由于前台应用的特殊性,建议在表字段中增加一列有唯一约束的字段,用作前台显示用。比如,原来查看新闻可能是:news.php?newsId=123,这样别人很容易猜出下一条是124,前一条是122,平时这样使用是无所谓,但如果是使用在订单上,别人就很容易知道你的订单数量等,如果采用了GUID这样的值,虽然看起来复杂了一点,但永远不会被人猜出你的订单)

当然主键也可以使用这种GUID来进行设定,但确实是不太建议使用,我主要是指MYSQL,因为MYSQL默认没有默认生成这样键值的函数。而且使用定长字符串做主键,在被外部引用的时候,就显得太长了。

而外键就相对来说比主键约束要小的多,但也是有一定规范的。比如,用主键作外键,这是大多数人的用法。即使在MYSQL尚未支持外键的时候,大多数情况下。也都是通过这样的方式来进行关联。

在使用外键的时候,一般建议是不要超过4张表关联,超过4张,可能你在某些个表里就纯粹看到的是ID记录(类似于数据库的索引),这个时候麻烦的问题就来了。该如何维护这样一个全是ID记录的表呢?一旦这个表被人误操作了。那么。所有的数据都将失去关联了。(如果数据库支持外键功能,在删除这样的外键关联数据,我记得是会出错的。)

外键,除了使用主键外,还有就是那种具有唯一索引的列,仔细想想也确实这样,如果没有唯一,那么关联出来的数据怎么能够具有唯一性?

利用外键进行数据的更新删除,应该是最方便的了。这样也可以避免数据库里会存在冗余数据。

——END——

纯粹是在这里发发牢骚,真正的表设计不是这么简单的。还要根据实际的应用,但这些可以算是一些小小的经验。也许在真正的高手眼里这些都不值一提。但,千里马常有,而伯乐不常有啊。很多人都认为是理所当然的事情,不代表我们这些新手就明白。

记录下来,作为参考,也算是一个笔记

Tags: mysql, primary key, index key, foreign key, design