10 Tips That Every PHP Newbie Should Know

March 10, 2006 at 10:18 am (WebDesign)

I wish I had known these 10 tips the day I started working with PHP. Instead of learning them through painstaking process, I could have been on my way to becoming a PHP programmer even sooner! This article is presented in two parts and is intended for folks who are new to PHP.

Tip 1: MySQL Connection Class

The majority of web applications I’ve worked with over the past year have used some variation of this connection class:

class DB {
function DB() {
$this->host = "localhost"; // your host
$this->db = "myDatabase"; // your database
$this->user = "root"; // your username
$this->pass = "mysql"; // your password

$this->link = mysql_connect($this->host, $this->user,
$this->pass);
mysql_select_db($this->db);
}
}

// calls it to action
$db = new $DB;

Simply edit the variables and include this in your files. This doesn’t require any knowledge or special understanding to use. Once you’ve added it to your repertoire, you won’t likely need to create a new connection class any time soon. Now you can get to work and quickly connect to your database without a lot of extra markup:

$result = mysql_query("SELECT * FROM table ORDER BY id ASC LIMIT 0,10");

More information can be found in the manual–be sure you read the comments: http://www.php.net/mysql_connect/

Tip 2: Dealing with Magic Quotes

PHP “automagically” can apply slashes to your $_POST data for security purposes. It’s an important measure to prevent SQL injections. However, slashes in your scripts can wreak havoc. This is an easy method for dealing with them. The way to handle the slashes is to strip them from our variables. However, what if the magic quotes directive is not enabled?

function magicQuotes($post) {

if (get_magic_quotes_gpc()) {
if (is_array($post) {
return array_map('stripslashes',$post);
} else {
return stripslashes($post);
}
} else {
return; // magic quotes are not ON so we do nothing
}

}

The script above checks to see if magic quotes is enabled. If they are, it will determine if your $_POST data is an array (which it likely is) and then it will strip the slashes accordingly.

Understand that this is not true ‘validation’. Be sure to validate all your user-submitted data with regular expressions (which is the most common way to do so).

More information about magic quotes: http://www.php.net/ magic_quotes/
More information about SQL injection: http://www.php.net/manual/en/security.database.sql-injection.php/
More information about regular expressions: http://www.php.net/pcre/

Tip 3: Safely Query Database with mysql_real_escape_string

When you are ready to query your database you will need to escape special characters (quotes for instance) for safety’s sake by adding slashes. We apply these before we insert variables into our database. Once again, we need to determine which version of PHP you are running first:

function escapeString($post) {

if (phpversion() >= '4.3.0') {
return array_map('mysql_real_escape_string',$post);
} else {
return array_map('mysql_escape_string',$post);
}

}

More information about mysql_real_escape_string: http://www.php.net/ mysql_real_escape_string/
More information about SQL injection: http://php.belnet.be/manual/en/security.database.sql- injection.php

Tip 4: Debugging

If you search the forum there are many good threads with rules about debugging. The single most important thing you can do is ask PHP to report errors and notices to you by adding this line at the beginning of your scripts:

error_reporting(E_ALL);

This will keep you in line as you learn by printing out errors to your screen. The most common error that E_ALL reports is not actually an error, but a notice for an “Undefined index”. Typically, it means that you have not properly set your variable. It’s easy to fix and keeps you programming correctly.

Another convenient tool while working with queries is print_r(). If your query is returning null or strange results, simply place this after your query command and it will display all the contents of the $result array.

print_r($result); exit;

The exit command stops your script from executing any further so you can specifically review your query results.

More information about error_reporting: http://www.php.net/ error_reporting/
More information about print_r; http://www.php.net/print_r/

Tip 5: Writing Functions (and Classes)

Initially I thought that tackling functions and classes would be difficult–thankfully I was wrong. Writing a function is something I urge all newbies to start doing immediately–it’s really that simple. You are instantly involved in understanding how to produce more efficient code in smaller pieces. Where you might have a line of code that reads like this:

if ($rs['prefix'] == 1) {
$prfx = 'Mrs. ';
} elseif ($rs['prefix'] == 2) {
$prfx = 'Ms. ';
} else {
$prfx = 'Mr. ';
}

echo $prfx.$rs['name'].' '.$rs['last_name'];

You could rewrite it like this in a function:

function makePrefix($prefix='')
{
if (!$prefix) return '';
if ($prefix == 1) return 'Mrs. ';
if ($prefix == 2) return 'Ms. ';
if ($prefix == 3) return 'Mr. ';
}

echo makePrefix($rs['prefix']) . $rs['name'] . ' ' . $rs['last_name'];

Now that you’ve written this function, you can use it in many different projects!

An easy way to describe classes is to think of it as a collection of functions that work together. Writing a good class requires an understanding of PHP 5’s new OOP structure, but by writing functions you are well on your way to some of the greater powers of PHP.

More information about writing functions: http://www.php.net/manual/en/language.functions.php
More information about writing classes:

http://www.php.net/manual/en/language.oop5.php

Everything I’ve learned, more or less, came from the manual, trial and error and great help from the many fine people here at PHPBuilder. Good luck programming–and come back soon for Part 2 in this series!

Permalink Leave a Comment

第78届奥斯卡奖完全获奖名单

March 7, 2006 at 12:49 am (Wiki, movie)

 

 

  1. 最佳影片(BEST PICTURE)
    《撞车》 Crash
  2. 最佳导演(DIRECTING)
    李安 Ang Lee/《断背山》BROKEBACK MOUNTAIN
  3. 最佳男主角(ACTOR IN A LEADING ROLE)
    菲利普·塞莫尔·霍夫曼 Philip Seymour Hoffman /《卡波特》CAPOTE
  4. 最佳女主角(ACTRESS IN A LEADING ROLE)
    瑞茜·威瑟斯朋 Reese Witherspoon /《一往无前》WALK THE LINE
  5. 最佳男配角(ACTOR IN A SUPPORTING ROLE)
    乔治·克鲁尼 George Clooney /《辛瑞纳》SYRIANA
  6. 最佳女配角(ACTRESS IN A SUPPORTING ROLE)
    蕾切尔·薇兹 Rachel Weisz /《不朽的园丁》THE CONSTANT GARDENER
  7. 最佳动画长片(ANIMATED FEATURE)
    《超级无敌掌门狗》WALLACE & GROMIT IN THE CURSE OF THE WERE-RABBIT
  8. 最佳外语片(FOREIGN LANGUAGE FILM)
    《黑帮暴徒》 Tsotsi/南非
  9. 最佳化妆(MAKEUP)
    《纳尼亚传奇》 THE CHRONICLES OF NARNIA: THE LION, THE WITCH AND THE WARDROBE
  10. 最佳配乐Music(SCORE)
    《断背山》BROKEBACK MOUNTAIN
  11. 最佳歌曲Music(SONG)
    “It”"s Hard Out Here for a Pimp” 《川流熙攘》Hustle & Flow
  12. 最佳动画短片SHORT FILM(ANIMATED)
    《月亮和儿子》THE MOON AND THE SON: AN IMAGINED CONVERSATION
  13. 最佳真人短片SHORT FILM(LIVE ACTION)
    《六位枪手》SIX SHOOTER
  14. 最佳音效剪辑(SOUND EDITING)
    《金刚》 KING KONG
  15. 最佳音响效果(SOUND MIXING)
    《金刚》 KING KONG
  16. 最佳视觉效果(VISUAL EFFECTS)
    《金刚》 KING KONG
  17. 最佳改编剧本WRITING(ADAPTED SCREENPLAY)
    《断背山》 BROKEBACK MOUNTAIN
  18. 最佳原创剧本WRITING(ORIGINAL SCREENPLAY)
    《撞车》CRASH
  19. 最佳艺术指导(ART DIRECTION)
    《艺伎回忆录》MEMOIRS OF A GEISHA
  20. 最佳摄影(CINEMATOGRAPHY)
    《艺伎回忆录》MEMOIRS OF A GEISHA
  21. 最佳服装设计(COSTUME DESIGN)
    《艺伎回忆录》MEMOIRS OF A GEISHA
  22. 最佳剪辑(FILM EDITING)
    《撞车》CRASH
  23. 最佳纪录片(BEST DOCUMENTARY FEATURE)
    《帝企鹅日记》MARCH OF THE PENGUINS
  24. 最佳纪录短片(BEST DOCUMENTARY SHORT SUBJECT)
    《胜利要诀》 A NOTE OF TRIUMPH: THE GOLDEN AGE OF NORMAN CORWIN
  25. 终身成就奖:罗伯特·奥特曼 Robert Altman

Permalink Leave a Comment

Seek and Ye Shall Find: Locate original documents on the Web

March 6, 2006 at 1:33 pm (KnowHow)

by Wendy Boswell

Seek and Ye Shall Find

Finding original source documents on the Web, otherwise known as firsthand accounts, primary sources, etc., has thankfully become a pretty easy task. There are plenty of great sites out there that have made it easy for the average searcher to locate pretty much anything from the Bill of Rights to Civil War journals to the Islamic History Sourcebook to the archived Godey’s Lady Books – seriously, there is NO end to the fun stuff you can find (and don’t we all need a bit of break from reading about Google’s latest exploits?). Most of these I found using the tips and tricks I outlined in another Lifehacker article, How to Search the Invisible Web, along with a bit of special Web searchin’ sauce (I’m lying about the special sauce-although Thousand Island does seem to perk things up a bit).

Here are just a few of the sites on the Web that you can use to locate primary documents; of course there’s many, many more, but these are my favorites that I find myself coming back to again and again, just to browse (I’m such a dork, but that’s okay). Remember, if you’re searching for original documents in order to cite them in an academic paper, you need to make sure you evaluate them first, and use proper citation procedures.

This is by no means an exhaustive list. There’s the Australian National Archives Database, the Ad Access Project that “presents images and database information for over 7,000 advertisements printed in U.S. and Canadian newspapers and magazines between 1911 and 1955″, the Internet Library of 18th and 19th century Journals, Making of America, a database of American social history primary sources, Chinese cultural texts, Asian history sources…it goes on and on.

Again, even though you might not need to check out any of these primary sources, it’s nice to know that after you’ve downloaded the latest iTunes episode of “The Office” that you DO have the option of browsing through the original Louisiana Purchase documents. I mean, come on – can you imagine what kind of mad office credibility that would give you?

Permalink 1 Comment

55 reasons to design in XHTML/CSS

March 6, 2006 at 4:31 am (WebDesign)

In no particular order 55 reasons for me to do “tableless” websites using valid XHTML for markup, CSS for layout and Flash sparingly, only as an ingredient. By tableless I mean avoiding tables (or a tagsoup of unnecessary divs substituting table trs and tds) for layout purposes and aiming towards as semantic markup as possible. Some of the reasons are “over HTML”, some “over Flash full monty” and some over both.

I know this topic has been discussed a plenty, I just needed to reaffirm myself :)

Here we go:

  1. You can get free links from showcase sites like zengarden, stylegala, cssimport or cssbeauty
  2. You don’t have to spend extra thought and time deciding on styling the mark up of your document (upper- or lowercase, quotes or no quotes on attributes)
  3. You don’t need to spend extra thought on which tags should be closed and which can (or should) be left open
  4. You “help” the search engines to deliver more relevant content using semantic markup
  5. You can save in bandwidth costs and visitors will see them faster by making slimmer pages
  6. It’s going to be easier for you to switch to XHTML 2.0 which will give you more semantic tools
  7. Once you’ve practised enough, coding pages becomes a whole lot simpler and faster than any table/tr/td tagsoup
  8. When the coding is faster you can spend more time on thinking about the user experience
  9. Thinking about semantics of a document helps you to make design and information architecture decisions
  10. You can quickly make a dummy site to test your sites information architecture and append a look and feel later with only minor code changes
  11. You can do the design after most of the backend is done which will help your client (or boss) to think realistically about how much work is still needed
  12. It’s possible to link directly to your content pages (compared to Flash)
  13. browser controls like text-size and back and forward buttons work (compared to Flash)
  14. Redesigns and realigns over the whole site are simpler
  15. it’s simpler to make small last minute changes to your designs
  16. Clean markup makes it easier or even unnecessary to build a CMS
  17. Clean markup makes it easier for another developer to jump on board
  18. You can make the backend almost totally independently from the frontend design, by completely different person
  19. You have plenty of ways to play with the markup trying to optimize for search engines, without affecting visible layout
  20. You have total control on print layouts of your pages
  21. Your sites are automatically accessible to all kinds of browsers
  22. Promoting web standards will help your work in the future, not having to code differently to each browser
  23. With all elemets closed you mark up look cleaner
  24. Well-formed code ensures your site works in more browsers
  25. Well-formed code would help browser coders to spend more time on useful features than rendering engines that try to understand borken code
  26. Your website will work in future browsers
  27. Your website works in mobile (and other new) devices
  28. You learn the basics of XML which has many other uses
  29. CSS files are saved in browser cache for fast retrieval and less bandwidth use
  30. Your documents are easy to convert back and forth another format using XSLT
  31. Thinking semantics makes you think more about the content
  32. Learning semantics makes you appreciate organization and write your other documents (even emails) in more organized way
  33. You can write new technologies in your CV or portfolio
  34. Modern browsers render a valid document faster
  35. You feel better about yourself when you are making sites “the right way”
  36. They are doing it: Dan Cederholm, Jeffrey Zeldman, Jason Santa Maria, Shaun Inman, Cameron Moll, Douglas Bowman, Dave Shea
  37. You will belong in a “movement”, make good contacts etc.
  38. You learn to appreciate newer browsers which makes for more competition and later for better browsers
  39. Blink tag is gone
  40. Strict coding makes you learn to see mistakes quicker
  41. You can aim to making some money writing a book about it
  42. There are more job opportunities if you know these new ways
  43. You learn better to understand how a browser works
  44. You can use hacks and techniques with cool names like “be nice to Opera”
  45. you start to care more about metadata, document and character types
  46. With more people making slimmer pages, the amount of data moving in the whole web will be smaller and all connections faster
  47. XHTML has a cooler name than HTML
  48. There are more people thinking about the advantages and disadvantages and coding tricks of XHTML which makes for a bigger learning forum
  49. You can use basically same markup template for many different websites
  50. Learning to read and write it fast makes it possible to use cheaper tools (notepad)
  51. Google knows this:
    • 4,380,000 xhtml better than html > 4,370,000 html better than xhtml
    • 206 “xhtml is better than html” > 87 “html is better than xhtml”
    • 2,130,000 xhtml sucks < 10,300,000 html sucks
  52. When all browsers start to understand the correct MIME-type (xml), you don’t have to convert all your websites from html, just to switch to correct MIME
  53. By more people using xhtml you ensure that in the future IE will need to understand the correct MIME-type
  54. Accessibility is enforced with requiring Alt attribute for images
  55. There just aren’t this many reasons to use HTML or entirely Flash instead

Permalink 2 Comments

常用视频格式详解

March 5, 2006 at 4:59 am (Media, Wiki)

步入多媒体时代,计算机已经成为家庭娱乐中不可缺少的元素之一,利用电脑不但可以工作,上网查询资料,了解最新的新闻资 讯,在休息之余,我们还能利用它来听听音乐,欣赏影视大片。说到影音视频,假如你是一个电影迷,经常利用电脑看影片的话,那就应该不会对诸如AVI、 MPEG、MOV、RM等常见视频格式感到陌生吧!现如今各种各样的视频格式如雨后春笋般不断地涌出,但是对于每一种视频格式都要求有相应的软件才能够Q 放,比如MOV格式文件需要用Quick Time播放,而RM格式的文件却需要Real Player来支持,虽然现在播放器支持的视频种类也很多,但毕竟不十分完美,使得我们经常会遇到这样“尴尬”的事情:辛辛苦苦地网上Download下 来一部电影大片,准备好好欣赏时,可是安装在电脑中的播放器却不支持这个格式,不仅心急如焚!那么如何解决这个问题呢?

视频格式介绍:

所谓“知己知彼,方能百战不殆!”,熟悉了各种各样的视频格式,才能够为后来的视频格式的转换打好基础。下面就来详细地为给大家介绍一些常见的视频格式:

 1.AVI格式

它的英文全称为Audio Video Interleaved,即音频视频交错格式。它于1992年被Microsoft公司推出,随Windows3.1一起被人们所认识和熟知。所谓“音频 视频交错”,就是可以将视频和音频交织在一起进行同步播放。这种视频格式的优点是图像质量好,可以跨多个平台使用,但是其缺点是体积过于庞大,而且更加糟 糕的是压缩标准不统一,因此经常会遇到高版本Windows媒体播放器播放不了采用早期编码编辑的AVI格式视频,而低版本Windows媒体播放器又播 放不了采用最新编码编辑的AVI格式视频。其实解决的方法也非常简单,我们将在后面的视频转换、视频修复部分中给出解决的方案。

2.DV-AVI格式

DV的英文全称是Digital Video Format,是由索尼、松下、JVC等多家厂商联合提出的一种家用数字视频格式。目前非常流行的数码摄像机就是使用这种格式记录视频数据的。它可以通过 电脑的IEEE 1394端口传输视频数据到电脑,也可以将电脑中编辑好的的视频数据回录到数码摄像机中。这种视频格式的文件扩展名一般也是.avi,所以我们习惯地叫它 为DV-AVI格式。

3.MPEG格式

它的英文全称为Moving Picture Expert Group,即运动图像专家组格式,家里常看的VCD、SVCD、DVD就是这种格式。MPEG文件格式是运动图像压缩算法的国际标准,它采用了有损压缩 方法从而减少运动图像中的冗余信息。MPEG的压缩方法说的更加深入一点就是保留相邻两幅画面绝大多数相同的部分,而把后续图像中和前面图像有冗余的部分 去除,从而达到压缩的目的。目前MPEG格式有三个压缩标准,分别是MPEG-1、MPEG-2、和MPEG-4,另外,MPEG-7与MPEG-21仍 处在研发阶段。

MPEG-1:制定于1992年,它是针对1.5Mbps以下数据传输率的数字存储媒体运动图像及其伴音编码而设 计的国际标准。也就是我们通常所见到的VCD制作格式。这种视频格式的文件扩展名包括.mpg、.mlv、.mpe、.mpeg及VCD光盘中的.dat 文件等。

MPEG-2:制定于1994年,设计目标为高级工业标准的图像质量以及更高的传输率。这种格式主要应用在 DVD/SVCD的制作(压缩)方面,同时在一些HDTV(高清晰电视广播)和一些高要求视频编辑、处理上面也有相当的应用。这种视频格式的文件扩展名包 括.mpg、.mpe、.mpeg、.m2v及DVD光盘上的.vob文件等。

MPEG-4:制定于1998年,MPEG-4是 为了播放流式媒体的高质量视频而专门设计的,它可利用很窄的带度,通过帧重建技术,压缩和传输数据,以求使用最少的数据获得最佳的图像质量。MPEG-4 最有吸引力的地方在于它能够保存接近于DVD画质的小体积视频文件。这种视频格式的文件扩展名包括.asf、.mov和DivX 、AVI等。

 4.DivX格式

这是由MPEG-4衍生出的另一种视频编码(压缩)标准,也即我们通常所说的DVDrip格式,它采用了MPEG4的压缩算法同时又综合了MPEG-4 与MP3各方面的技术,说白了就是使用DivX压缩技术对DVD盘片的视频图像进行高质量压缩,同时用MP3或AC3对音频进行压缩,然后再将视频与音频 合成并加上相应的外挂字幕文件而形成的视频格式。其画质直逼DVD并且体积只有DVD的数分之一。
5.MOV格式

美国Apple公司开发的一种视频格式,默认的播放器是苹果的QuickTimePlayer。具有较高的压缩比率和较完美的视频清晰度等特点,但是其最大的特点还是跨平台性,即不仅能支持MacOS,同样也能支持Windows系列。

6.ASF格式

它的英文全称为Advanced Streaming format,它是微软为了和现在的Real Player竞争而推出的一种视频格式,用户可以直接使用Windows自带的Windows Media Player对其进行播放。由于它使用了MPEG-4的压缩算法,所以压缩率和图像的质量都很不错。

  7.WMF格式

它的英文全称为Windows Media Video,也是微软推出的一种采用独立编码方式并且可以直接在网上实时观看视频节目的文件压缩格式。WMV格式的主要优点包括:本地或网络回放、可扩充 的媒体类型、可伸缩的媒体类型、多语言支持、环境独立性、丰富的流间关系以及扩展性等。

 8.RM格式

Networks公司所制定的音频视频压缩规范称之为Real Media,用户可以使用RealPlayer或RealOne Player对符合RealMedia技术规范的网络音频/视频资源进行实况转播,并且RealMedia还可以根据不同的网络传输速率制定出不同的压缩 比率,从而实现在低速率的网络上进行影像数据实时传送和播放。这种格式的另一个特点是用户使用RealPlayer或RealOne Player播放器可以在不下载音频/视频内容的条件下实现在线播放。

 9.RMVB格式

这 是一种由RM视频格式升级延伸出的新视频格式,它的先进之处在于RMVB视频格式打破了原先RM格式那种平均压缩采样的方式,在保证平均压缩比的基础上合 理利用比特率资源,就是说静止和动作场面少的画面场景采用较低的编码速率,这样可以留出更多的带宽空间,而这些带宽会在出现快速运动的画面场景时被利用。 这样在保证了静止画面质量的前提下,大幅地提高了运动图像的画面质量,从而图像质量和文件大小之间就达到了微妙的平衡。

Permalink Leave a Comment

Web 2.0 DNA

March 3, 2006 at 9:46 am (Web 2.0)

Posted by Michael Arrington From http://www.techcrunch.com


Brandon Schauer’s
post and associated PDF historical timeline is an excellent resource to put web 2.0 companies into perspective and to understand their place in the overall ecosystem. I’ll be referring to it often in TechCrunch posts. More on CrunchNotes.

Permalink Leave a Comment

数字技术新法则-功能不再重要

March 2, 2006 at 9:39 am (Design)

这是一位咨询专家的意见,算是对iPod成功的一个解释。说起来,所有不喜欢网页翻几十页、不喜欢满屏飞来飞去、不喜欢聊天时穿个小裤衩的人民都已经产生了这种朴素的思路。

作者认为现在功能并不重要,而用户体验的时代已经到来。在这个时代里10个基本法则是:

  1. 更多的功能并不好;
  2. 增加功能不会让事情更容易;
  3. 让用户迷惑是毁掉业务的终级手段;
  4. 风格很关键;
  5. 只有在一项功能可以提升用户体验时才加上它;
  6. 任何需要学习的功能都只会吸引一小部分用户;
  7. 无用的功能不止是无用,它会破坏易用性;
  8. 用户不会关心技术,他们只想知道产品能做什么;
  9. 忘掉关键功能,关注最重要的用户体验;
  10. 简洁很难,因此少就是多。

这 段话看似很有道理,所以值得大家学习和思考,单纯从用户的角度来看,在许多场景都是适用的;尽管我们的手机现在天天更新换代,但是除了打电话和发短信以 外,其他的功能很少被用及,饭团自己的SE K700,第三常用的功能居然是摄像功能附带的那个“灯”,可以用来当小型手电筒用;在这个层面上来说,简洁就是好

但是,如果作为商人,这样的思路则近似在谋杀自己的发展。

  • 其一,功能众多也许用不上,但销售方面却是一大考虑因素,许多人在买东西的时候会不自觉地考虑这个那个功能(虽然95%都用不上),但是如果没有 这些功能 就会觉得跟不上潮流或者不够完善,这种想法几乎无人能够免俗。电视里经常销售的那些数码相机+摄像机+MP3+DVD播放等等跟“十全大补丸”一样的怪 物,懂行的人往往不会考虑,但是不可否认的人确实很多人被吸引甚至购买了,这也就达到了商人的销售目的。所以,很多时候,功能齐全并不是为了给大部分用户 使用,而只是为了让他们购买
  • 其二,作为商人,销售的并不是当前,还要考虑“当后”;所以几乎所有的商人都会不断地加入新功能,10项新功能里有一项能成为销售的有利因素甚至 成为未来 的主要功能,就是大获成功;为什么现在的手机都会带相机功能,2、3年前大部分可能都不会把这两者放在一起,可是现在要买不带相机的手机已经很难了
  • 其三,功能的众多其实也就体现了个性,在什么东西都越来越讲个性的时候,光秃秃的东西就变得没有了个性(当然,不可否认的是,有个别例外:例如饭 团买了个 Ipod shuffle,这个MP3最大的特点就是几乎什么都没有,收音机、彩屏、电话本、闹钟等都没有,甚至根本就没有显示屏,但的确个性十足,问题是,这东西 只此一家,如果大家都是这样,就谈不上个性了)。对广大的用户来说,或多或少都会在基本功能之外有自己个性的一点;还是以饭团的K700手机为例,谁会想 到那个手机可以当手电筒用的功能会这么重要呢?

所以,功能多并不是没用的,只不过体现的地方不一样罢了。扯远点,单纯和简洁虽然看起来是当前最好的,但却是扼杀发展的。就好像美国一直想把他们的 价值观 普及到全世界一样,如果全世界都跟美国一样信奉同样的东西用同样的方式做事,那也许会真的少很多战争;可惜那样的世界是很无趣的,没有发展动力的(是谁说 过,战争是人类世界进步的主要推动力?),所以,事实上也是不可能发生的。

Permalink Leave a Comment

Data Mining using Google

March 2, 2006 at 1:51 am (KnowHow)

Google has quickly become one of the most well known words in the world and is used by millions daily, including myself. In an advanced database class back in university, we spent a couple of weeks studying the inner workings of search engines, and one topic which happened to come up was data mining using Google. Much to my surprise, out of a class of 80 fourth year computer engineers maybe four or five knew how to use Google to perform any sort of advanced queries.Google (and many other search engines) has the ability not only to search on keywords, but also using a more “database-ish” query language to really narrow down your search results. Below is a summary of a few of the most useful lesser known features.

Note: in the examples, replace cyberwyre.com with your own domain.

Basic Usage:

  • Use quotation marks ” “ to locate an entire string.
    eg. “bill gates conference” will only return results with that exact string.
  • Mark essential words with a +
    If a search term must contain certain words or phrases, mark it with a + symbol. eg: +”bill gates” conference will return all results containing “bill gates” but not necessarily those pertaining to a conference
  • Negate unwanted words with a -
    You may wish to search for the term bass, pertaining to the fish and be returned a list of music links as well. To narrow down your search a bit more, try: bass -music. This will return all results with “bass” and NOT “music”.

General Tips: (I use many of these almost on a daily basis)

  • site:www.cyberwyre.com
    This will search only pages which reside on this domain.
  • related:www.cyberwyre.com
    This will display all pages which Google finds to be related to your URL
  • link:www.cyberwyre.com
    This will display a list of all pages which Google has found to be linking to your site. Useful to see how popular your site is
  • spell:word
    Runs a spell check on your word
  • define:word
    Returns the definition of the word
  • stocks: [symbol, symbol, etc]
    Returns stock information. eg. stock: msft
  • maps:
    A shortcut to Google Maps
  • phone: name_here
    Attempts to lookup the phone number for a given name
  • cache:
    If you include other words in the query, Google will highlight those words within the cached document. For instance, cache:www.cyberwyre.com web will show the cached content with the word “web” highlighted.
  • info:
    The query [info:] will present some information that Google has about that web page. For instance, info:www.cyberwyre.com will show information about the CyberWyre homepage. Note there can be no space between the “info:” and the web page url.
  • weather:
    Used to find the weather in a particular city. eg. weather: new york

Advanced Tips:

  • filetype:
    Does a search for a specific file type, or, if you put a minus sign (-) in front of it, it won’t list any results with that filetype. Try it with .mp3, .mpg or .avi if you like.
  • daterange:
    Is supported in Julian date format only. 2452384 is an example of a Julian date.
  • allinurl:
    If you start a query with [allinurl:], Google will restrict the results to those with all of the query words in the url. For instance, [allinurl: google search] will return only documents that have both “google” and “search” in the url.
  • inurl:
    If you include [inurl:] in your query, Google will restrict the results to documents containing that word in the url. For instance, [inurl:google search] will return documents that mention the word “google” in their url, and mention the word “search” anywhere in the document (url or no). Note there can be no space between the “inurl:” and the following word.
  • allintitle:
    If you start a query with [allintitle:], Google will restrict the results to those with all of the query words in the title. For instance, [allintitle: google search] will return only documents that have both “google” and “search” in the title.
  • intitle:
    If you include [intitle:] in your query, Google will restrict the results to documents containing that word in the title. For instance, [intitle:google search] will return documents that mention the word “google” in their title, and mention the word “search” anywhere in the document (title or no). Note there can be no space between the “intitle:” and the following word.
  • allinlinks:
    Searches only within links, not text or title.
  • allintext:
    Searches only within text of pages, but not in the links or page title.
  • bphonebook:
    If you start your query with bphonebook:, Google shows U.S. business white page listings for the query terms you specify. For example, [ bphonebook: google mountain view ] will show the phonebook listing for Google in Mountain View.
  • phonebook:
    If you start your query with phonebook:, Google shows all U.S. white page listings for the query terms you specify. For example, [ phonebook: Krispy Kreme Mountain View ] will show the phonebook listing of Krispy Kreme donut shops in Mountain View.
  • rphonebook:
    If you start your query with rphonebook:, Google shows U.S. residential white page listings for the query terms you specify. For example, [ rphonebook: John Doe New York ] will show the phonebook listings for John Doe in New York (city or state). Abbreviations like [ rphonebook: John Doe NY ] generally also work.

Putting it all Together:

Now it’s time to start to get creative with our search terms and really narrow down our results. Now that we have the basics, let’s start to combine them all into one search term.

Example #1: Search for some MP3s
Let’s say you’re a Beatles fan and want to see if you can find some of their songs on the Internet without using Kazaa, etc. Try this query:

>“index of” + “mp3″ + “beatles” -html -htm -php
or you could try this query:
* “index of/mp3″ -playlist -html -lyrics beatles

Right away on the first few results returned by Google you can download MP3s.

Example #2: Mixing some techniques together

Here’s a simple exercise. We’ll mix around a few terms to get more accurate results. Let’s say we want to research sleep recommendations. One assumption could be that research papers on this topic would most likely be on an educational website — perhaps with a .edu domain. We could try this query:

sleep recommendations site:edu

Maybe we’re in my situation, and am thinking of applying to grad school. Let’s see if we can find the Graduate Studies Admissions Requirements at the University of Toronto. We could try this query:

grad school admission requirements site:utoronto.ca

Summary:

After reading this article, you might be thinking “well, I could probably find those results without remembering these advanced search terms”. Well, the truth is that you probably could. The reason you want to start to use these advanced search tips is because they will help you find what you’re looking for faster. They greatly help narrow down the results, and more often than not, the information you were looking for will be in the first two or three results.

Permalink 1 Comment

Web 2.0 API Reference

March 2, 2006 at 1:51 am (Web 2.0)

API Description Category Updated
411Sync SMS messaging Messaging 2005-10-03
43Things Social goal setting Other 2005-10-30
activeRenderer Outline publishing for Radio UserLand Other 2005-09-04
Amazon Online retailer Retail 2005-12-02
Amazon A9 OpenSearch Search services Web Search 2005-09-04
Amazon Alexa Search Other Search 2005-09-04
Amazon Mechanical Turk Request services of humans Other 2005-11-07
Amazon Queue Service Internet-based queuing service Other 2005-09-06
AmphetaRate News aggregator News 2005-09-18
Backpack Online information manager Other 2005-09-04
BBC Multimedia archive database Media Management 2005-10-29
Blogger Blogging services Blogging 2005-09-04
Bloglines Online feed aggregator Feed Aggregation 2005-09-04
Blogmarks Social bookmarking Bookmarks 2005-10-30
Blogwise Blog and feed search service Blog Search 2005-11-19
Buzznet Photo sharing Photos 2005-10-30
CafeSpot Social guide to cafes Other 2005-09-04
Cdyne Data delivery services Other 2005-10-01
CommonTimes Community based media distribution Other 2005-10-04
cPath Medical database lookup Medical 2005-09-04
Creative Commons Licensing engine integration Other 2005-09-04
Data On Call Fax services Fax 2005-09-07
del.icio.us Social bookmarking Bookmarks 2005-10-30
Digital Podcast Podcast search Music 2005-09-04
Dropcash Fundraising tools Other 2005-12-13
eBay Online auction marketplace Auctions 2005-12-05
ecommstats Web analytics Other 2005-12-28
ESV Bible Lookup Bible lookup service Other 2005-09-04
EVDB Events database Events 2005-10-31
FedEx Package shipping Shipping 2005-09-04
FeedBurner Blog promotion tracking service Blogging 2005-09-04
FeedMap Blog geo-coding Mapping 2005-10-30
Findory Personalized news aggregation Feed Aggregation 2005-09-04
Flickr Photo sharing service Photos 2005-09-04
Freedb / CDDB Online CD catalog service Music 2005-09-04
geocoder Geocoding services for US Mapping 2005-09-04
geocoder.ca Geocoding services for Canada Mapping 2005-11-13
GeoNames Geographic name and postal code lookup Mapping 2006-01-12
Gigablast Search service Web Search 2005-09-09
Google AdWords Search advertising Advertising 2005-09-04
Google Desktop Search Search tools Search 2005-11-09
Google Homepage Portal gadgets Gadgets 2005-12-14
Google Maps Mapping services Mapping 2005-12-05
Google Search Search services Web Search 2005-09-04
Google Talk Chat application Chat 2005-12-03
GraphMagic Graph and chart services Other 2005-09-12
Gtalkr Flash chat wrapper for Gtalk Chat 2005-12-03
hostip.info IP lookup Other Search 2005-09-04
HotOrNot Dating rating site Dating 2005-10-30
indeed Job search services Job Search 2005-09-04
Interfax Fax services Fax 2005-12-06
Internet Archive Non-profit Internet library Other 2005-09-10
Jots Social bookmarking Bookmarks 2005-12-13
JotSpot Wiki-style collaboration tools Wiki 2005-10-30
Kayak Travel search service Travel 2006-01-10
Last.fm Music playlist management Music 2005-10-30
Library of Congress SRW Information database search Other 2005-09-04
LiveJournal Blogging software Blogging 2005-09-06
Mappr Photo mapping Mapping 2005-09-04
Microsoft MapPoint Mapping services Mapping 2005-11-19
Microsoft MSN Messenger Chat and messaging Chat 2005-12-08
Microsoft MSN Search Internet search Search 2005-11-09
Microsoft MSN Spaces Blog services Blogging 2005-12-14
Microsoft start.com Portal service Portal 2005-09-04
Microsoft Virtual Earth Mapping services Mapping 2005-12-02
Mint Web site metrics and reporting Other 2006-01-06
Moreover News delivery News 2005-09-12
Movil SMS messaging Messaging 2005-10-05
NASA Satellite mapping images Mapping 2005-09-06
NCBI Entrez Life sciences search services Medical 2005-09-04
NewsGator Feed aggregation Feed Aggregation 2005-09-04
NewsIsFree Online news aggregation News 2005-12-28
Ning Service creation playground Other 2005-10-11
NOAA Weather Service Weather forecast database Weather 2005-09-08
O’Reilly Safari Book search Other Search 2005-09-04
Ontok Geocode any US address Mapping 2005-11-01
Openomy Online file system Other 2005-11-25
OpenStreetMap Open source mapping Mapping 2005-12-28
Orb Digital media access Media Management 2005-09-25
PartySync Messaging services Messaging 2005-12-31
PayPal Online payments Payment 2005-09-04
Pixagogo Online photo services Photos 2005-12-28
Plazes Location discovery service Mapping 2005-09-04
Plurn Music playlist management Music 2005-09-06
Prodigem File sharing via BitTorrent File Sharing 2005-10-30
PubSub Blog and feed search Blog Search 2005-09-04
Qurl URL redirection services Other 2005-12-28
Rhapsody Online music services Music 2005-12-05
Salesforce.com CRM services Other 2005-11-09
Scribble Link manager Bookmarks 2005-09-07
SeqHound Bioinformatics research database Medical 2005-09-04
Serence Klip Desktop gadgets Gadgets 2005-11-09
Shadows Social bookmarking and community Bookmarks 2005-11-19
Simpy Social bookmarking Bookmarks 2005-10-30
Skype VoIP software VoIP 2005-09-11
SmartTravelDeals Travel offer publishing and search Travel 2005-09-14
SmashFly Job board posting service Job Search 2006-01-08
Smugmug Photo sharing service Photos 2005-11-01
StrikeIron Web services marketplace Other 2005-09-15
Syndic8 News feed aggregation services Feed Aggregation 2005-11-03
Tagalag Email tagging Tagging 2005-10-05
tagthe.net Tag recommendation service Tagging 2005-12-02
Tagyu Tag recommendation service Tagging 2005-10-29
Technorati Blog search services Blog Search 2005-09-04
Telcontar Location-based services Mapping 2005-09-11
Textamerica Moblogs Messaging 2005-09-04
Trekmail Messaging services Messaging 2005-09-05
TypeKey Authentication Framework Security 2005-09-23
TypePad Blog management Blogging 2005-09-04
Upcoming.org Collaborative event calendar Events 2005-11-19
UPS Package shipping Shipping 2005-09-04
UrbanDictionary Slang dictionary lookup Dictionary 2005-10-31
UrlTrends Link tracking and search optimization Advertising 2005-09-08
US Postal Service Package shipping and postage Shipping 2005-12-06
Vazu SMS messaging service Messaging 2005-11-27
voo2do Task management Other 2005-09-04
WebJay Music playlist management Music 2005-09-04
Where’s Tim Web Service Location tracking Music 2005-12-22
Wiggle Wireless network mapping Mapping 2005-10-09
Wordtracker Search engine optimization services Advertising 2005-09-05
WSRelater Recommendation engine Recommendations 2005-11-27
Yahoo Ads Online ad management Advertising 2005-11-19
Yahoo Audio Search Music search services Media Search 2005-09-04
Yahoo Geocoding Geocoding services Mapping 2005-11-03
Yahoo Image Search Image search services Web Search 2005-11-19
Yahoo Konfabulator Desktop gadgets Gadgets 2005-11-09
Yahoo Local Search Local search service Web Search 2005-11-19
Yahoo Map Image Map image creation service Mapping 2005-11-19
Yahoo Maps Mapping services Mapping 2005-11-19
Yahoo Music Engine Desktop music player Music 2005-11-09
Yahoo Search Search services Web Search 2005-09-04
Yahoo Shopping Shopping services Shopping 2005-11-19
Yahoo Term Extraction Contextual search service Web Search 2005-11-19
Yahoo Traffic Traffic data and routing Other 2005-11-19
Yahoo Travel Online travel services Travel 2005-12-21
Yahoo Video Search Video search Media Search 2005-11-19
YouTube Video sharing and search Media Search 2005-09-04
ZeeMaps International geocoding service Mapping 2005-10-31
ZipCodes Zip code lookup service Other 2005-10-31
Zvents Local events search and community Events 2005-10-30

This list tries to include all APIs that may be considered “Web 2.0 APIs”, but likely doesn’t, so please feel free to recommend others.

Permalink Leave a Comment

WordPress 2.0 – The Good and the Bad

March 1, 2006 at 11:35 am (Web 2.0)

By Michael Arrington | From TechCunch.com

wordpresslogoWe’ve switched TechCrunch over to WordPress 2.0. Not everyone is interested in the feature set of the WordPress
blogging platform, so I’ll keep this brief.

To see a good overview of the new features, see Asymptomatic.

A big change is the ability to create categories on the fly, from the post page, with Ajax. This was previously a multi step process. Since Technorati and other blog search engines view categories as synonyms to tags, this is a quick way for most users to quickly and easily tag their posts without adding additional code.

Another big improvement is the enhanced “view post preview” function. This shows the post exactly as it will look on the blog, with all formatting and CSS that will be applied. This is a welcome feature.

They’ve also added a wysiwyg rich text editor. I disabled this immediately, although many users will like it.

Now for the bad. The new image uploader is a train wreck. Yes, they’ve moved it to the post page which removes a click. However, what took a couple of steps before now takes five or six because I format images in a very particular way which the uploader doesn’t support. It also has default settings, like thumbnails, that require extra clicks to get This needs to be fixed or I will literally go crazy. At the very least, just showing me the URL string for the uploaded image will get me back some of the functionality lost.

The image URL folder is now reset every month as well, and so I can’t easily find old images, either. They didn’t think through this very well, or at all.

Transition took a few days (yes, days) before comments and images were showing properly (thank you, Bryan, for doing this) The support site provides some help, but the depth of questions and obvious user frustration shows that many, including me, should have tested it out before transitioning our entire blog there.

Permalink Leave a Comment

Next page »