2009年02月16日
2009年02月12日
[Web] 連結分享
PHP
- Optimise all tables in all mysql dbs on your server
- Tutorial: PHP Add Text To Image
- FirePHP: Unobtrusive PHP Debugging
- Debugging PHP using Xdebug and Notepad++ : Part I
- PHP Speed: Private vs Public Member And Static Methods
- Replacing short tags with proper PHP tags
- Creating streams from strings in PHP
- 剖析PHP中的输出缓冲
- Getting information from SVN with PHP
- 国外主流php框架对比和介绍
- 一些php網頁驗證小技巧
- Convert DOC to PDF in PHP
- Cache之Mysql, Memcached, File比较
- The Big PHP IDE Test: Why Use One And Which To Choose
- HTTP Basic and Digest authentication with PHP
Zend Framework
- Zend_Tool for the Developer
- Zend_Tool for the Developer - Part 2
- Zend Framework Automatic Dependency Tracking
CSS
- 透過CSS設定,達到類似Excel凍結視窗的效果(固定上面、左邊表頭)
- New CSS Sticky Footer - 2009
- Prototyping with Malo CSS Library
- CSS Code Snippets : 15 Wicked Tricks
- 5 Popular CSS Frameworks + Tutorials & Tools for Getting Started
- CSS should not be used for layout 反面論調: Re: “Why CSS should not be used for layout”
- Defensive coding and CSS: Preventing the most common bugs
- How to solve :first-child CSS bug in IE 7
- CSS Animation
JavaScript
- C3DL: Canvas 3D JavaScript Library
- Object-Oriented JavaScript, how to achieve public properties/fields
- JSReg javascript parser
- How to check if an image exists using JavaScript
- OCR and Neural Nets in JavaScript
- 57+ Free Image Gallery, Slideshow And Lightbox Solutions
- Speed up your JavaScript, Part 2
- New in JavaScript 1.8
- Beautiful Forms with JavaScript
- 50 Websites that make amazing use of javascript
- Javascript Array Fun
- Javascript unique strings with RegExps
- 使用firebug + fireunit做javascript的單元測試
jQuery
- jMonthCalendar
- UI.Layout Plug-in - Home
- How to Make a Smooth Animated Menu with jQuery
- 邊做邊學jQuery教學系列,初登場
- jQuery 1.3.1 Release
- jQuery Selector不合用? 自己寫一個吧!
- AJAX APIs Playground
- Changing Form Input Styles on Focus with jQuery
- Easy Slider 1.5 - The Easiest jQuery Plugin For Sliding Images and Content
- jQuery Tutorial: Selecting Multiple Select Form Elements on the Fly
- Date Picker jQuery Plugin to Fit in Your Web Application
- 25 jQuery Tutorials for Improved Navigation Menus
- New jQuery plugin: ‘imgPreview’
- jQuery 1.3自訂Selector Filter注意事項
- jQuery 1.3 Cheat Sheet
- Building a jQuery-Powered Tag-Cloud
- jQuery & Ajax Fun: Implementing a Paging Listbox
- jQuery + Flot - Plots, Canvas and Charts
- jQuery Sequential List
- Using jQuery to Style Design Elements: 20 Impressive Plugins
- Quick Tip: Add Easing to Your Animations » Learning jQuery
- Mini jQuery Lab
Database
MySQL
Web Development
- Opera: Web Standards Curriculum
- 10 Brilliant Multi Level Navigation Menu Techniques
- PNGs, PNGs, and more about PNGs
- The iPhone Springboard in XHTML, CSS and jQuery
- Internet Explorer Conditional Comments
Design
- A Better Pagination / Portfolio / Christoph Pojer
- 27 Best Photoshop Web Layout Design Tutorials - Part 2
- 50 of the Best Ever Web Development, Design and Application Icon Sets : Speckyboy - Web Design, Web Development and Graphic Design Resources
Browser
Programming
Software
- Comodo Registry Cleaner 優化系統登錄檔,讓電腦更快更穩定
- 如何用7-ZIP分片壓縮?(分割成多個檔案)
- 對一堆正在執行的 svchost.exe 好奇嗎?Svchost Viewer 可以給你答案
Other
2009年01月22日
[Web] 連結分享
PHP
- Five good programming habits in PHP
- PHP myths confused
- Working with checkboxes and a database
- Learning OOP in PHP ASAP!
- What's new in PHP V5.3, Part 3: Namespaces
- Minify - Combine & Compress CSS or Javascript Files
- The Cost of Test Isolation - Follow-Up
- PHP Quick Tip: Using the Ternary Operator
- 50 Extremely Useful PHP Tools
- 5 Helpful Tips for Creating Secure PHP Applications
Zend Framework
JavaScript
- How to make a Sudoku (Only javascript used)
- getElementsByTagName() - Compact Implementation of the Method
- Speed up your JavaScript, Part 1
jQuery
- jQuery and Closures
- 45+ New jQuery Techniques For Good User Experience
- jQuery 1.3: Plugins continue to migrate to the core
- jQuery Price Format Plugin
- 17 “Must see” Menu in jQuery
- Use the jQuery UI to Control the Size of Your Text
- jQuery UI 1.6 Slider from a Select Element
- LavaLamp 1.3.1 - a jQuery plugin
- The Sexy Curls jQuery Plugin by Elliott Kember
- Tracking Clicks, Building a Clickmap with PHP and jQuery
- jQuery Tip: Font Resizing With Animation Effects
- Jquery Series Part 1:- Basics & Introduction
- JQuery HowTo: Working with jQuery 1.3's new Event object (jQuery.Event)
- Bookmark: 50+ stunning jQuery applications
- Delete a Record with animation fade-out effect using jQuery and Ajax.
- jQuery Full Month Calendar Plugin Supports Events
- Build a Tabbed Box with CSS and jQuery
- Customizing jQuery innerfade plug-in - Adding controls, navigation and caption
CSS
- Warning: This Secret CSS Technique Will Surprise You!
- css基础教程布局篇之一
- How z-index Works
- CSS3 . Info - All you ever needed to know about CSS3
- 快速定位页面中复杂 CSS BUG
- Fixed Footer Backgrounds with CSS
- Professional Forms using CSS
- CSS-Reset.com
- Free Customizable CSS Menu For Everyone
- Better Image Caching with CSS
Web Development
- MySQL Query Cache, WP-Cache, APC, Memcache - What to choose
- 網頁開發人員應了解的 HTTP 狀態碼
- 5 Cool Ways to Support the W3C – Jens Meiert
- 開發手機版網頁
- 為網站製作圖示:Favicon
- 写javascript是否要“预留退路”
Browser
Database
MySQL
Design
- Using Light, Color and Contrast Effectively in UI Design
- 12 Useful Techniques For Good User Interface Design
Game
Other
Service
Software
System
2009年01月15日
[JavaScript] 如何讓 reset.css 和 HTML 預覽功能並存?
問題描述
現在 CSS 排版技術越來越盛行,很多網頁設計師為更精準地控制頁面呈現效果,都會使用 reset.css 來將 HTML 元素在瀏覽器的預設呈現效果給移除 (例如 YUI 的 reset.css 或 Eric Meyer 的 reset.css ) 。
雖然這個技術很好用,但在需要讓客戶自訂畫面的專案上就會遇到一個問題:如何讓客戶的 HTML 呈現出瀏覽器原本預設的效果?
像 YUI 有提供一個 base.css ,可以稍微幫我們將 HTML 元素回復原本的呈現方式。但我們有時只是需要在畫面上一小部份轉換為原來的效果,這時就勢必得修改 base.css ,在它的各項元素定義前加上某區塊的 class 或 id ;不過這不是一個好選項,因為大多數狀況我們還是沒辦法百分之百讓畫面呈現它原本的樣子。
解決方案
其實用 iframe 就可以幫我們解決這個問題。
步驟很簡單:
- 建立一個動態 iframe 。
- 將原本的 html 內容指定給 iframe 的 document 。
- 把 iframe 高度調整至和 html 內容一般高。
這裡我用 jQuery 來實作囉。
建立一個動態 iframe
假設我們的 html 內容已經放在 div.htmlContent 這個區塊中,我們可以用以下程式來動態建立一個 iframe ,並將它 append 在 div.htmlContent 中。當然也別忘記把原來的內容清掉:
$(function () {
var $iframe = $('<iframe src="about:blank" width="100%" height="300" frameborder="0"></iframe>');
var $htmlContent = $('div.htmlContent');
var html = $htmlContent.html();
$htmlContent.html('');
$htmlContent.append($iframe);
}
這裡要注意一點,就是 iframe 的高度一定要設定一個大於 0 的整數值,不然等一下 IE 在自動調整高度時會出問題。 (別問我為什麼...我也是自己試出來的 Orz)
至於 iframe 的來源,我們設定為 about:blank 就好,也就是瀏覽器預設的空白頁。
將原本的 html 內容指定給 iframe 的 document
在建立好動態的 iframe 之後,我們要先等它將內容載完。在載完之後,我們就可以將原來的 html 放到 iframe 裡的 docuement 物件的 body 中。
$iframe.load(function () {
var iframeDocument = getIframeDocument($iframe.get(0));
$(iframeDocument.body).html(html).css({ margin: '0', padding: '0' });
});
這裡用到了一個自訂函式 getIframeDocument , 它可以幫我們取得 iframe 裡的 document 物件,而且是跨瀏覽器的:
function getIframeDocument(iframeObject) {
if (iframeObject.contentWindow) {
return iframeObject.contentWindow.document;
} else if (iframeObject.contentDocument) {
return iframeObject.contentDocument.document;
}
return null;
}
註:getIframeDocument 暫時不支援 Google Chrome 和 Safari 。
把 iframe 高度調整至和 html 內容一般高
接著我們要調整 iframe 的高度,讓它能完整呈現出 html 的內容。
在 html 載入完畢後,body 的 offsetHeight 就會是我們所需要的內容高度:
$iframe.load(function () {
var iframeDocument = $.wacow.getIframeDocument($iframe.get(0));
$(iframeDocument.body).html(html).css({ margin: '0', padding: '0' });
setTimeout(function () {
var bodyHeight = iframeDocument.body.offsetHeight + 20;
$iframe.height(bodyHeight);
}, 0);
});
這裡有個小技巧,就是重新指定 html 內容時, load 事件並不會被觸發,所以我們要利用 setTimeout 來確定 html 已經全部加載完畢 (讓它跳離到另一個執行空間) 。
到這裡就大功告成啦~謝謝收看~
[Web] 連結分享
PHP
- Fetch twitter updates via PHP
- [PHP]製作類似 google 網頁認證碼
- PHP中 Magic quotes 的问题探讨
- require(), require_once() and Dynamic Autoloading in PHP
- Cool PHP Objects Sleep on the Couch
- Introduction to writing a REST server in PHP
- So phar so good.
Zend Framework
JavaScript
jQuery
- 8 Sites with Excellent jQuery Navigation
- jQuery plugin - Easy Image or Content Slider
- Improving Search Boxes with jQuery
- How to Validate Forms in both sides using PHP and jQuery
- jQuery 1.3 and the jQuery Foundation
- jQuery 1.3 正式版出爐了!
- XML Parsing with jQuery
- jQuery1.3和里程碑式的新选择器引擎
- How jQuery Makes Your JavaScript Code Simple
- jQuery 1.3來了!!
CSS
- 5 Techniques to Acquaint You With CSS 3
- Safari 3.2 和 Opera 9.63 的 CSS Hack
- 10 Dirty CSS Tips and Tricks
- 5 more CSS frameworks
- Select Cuts Off Options In IE (Fix)
Web Development
Database
MySQL
Programming
Software
- PotPlayer 1.4.183720 - 即將把KMPlayer幹掉的影音播放器
- 如何利用 7-zip 設定自動解壓縮並解壓縮後自動啟動程式
- 5 Reasons VirtualBox Rocks My Socks
System
Other
2009年01月5日
[程式開發] 抽象的意義
上次教育訓練完,小魚問我抽象的意義是什麼?知道它對寫物件導向有什麼幫助嗎?
在課程中我舉了人開車的例子,但充其量只是解釋了「抽象」的抽象意義而已 (還真繞口) ...
就讓我用新的例子來說明吧。
資料庫抽象層
不曉得各位有沒有轉換過資料庫系統的經驗,撇開政治因素不談,其實以往在轉換資料庫時常是一件麻煩事。
以 MySQL 轉換成 Oracle 為例,在 PHP 中 MySQL 通常是用 mysql_* 的函式來處理資料庫,而 Oracle 則是用 oci_* 的函式來處理。
這樣在轉換資料庫系統時,程式改動所要耗費的心力將會是難以想像的估計,尤其在大型程式上面。
如果在初期開發時,我們能夠不必受到不同資料庫系統的限制,而能專注於處理資料上的邏輯,那不是很好嗎?
所以我們就有了 ADOdb 、 PEAR::DB 或是 PDO 等等資料庫抽象層類庫可使用了。
以 PDO 為例:
<?php
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
sql = 'SELECT ...';
foreach ($dbh->query($sql) as $row) {
// ...
}
在系統底層, $dbh 其實是以 MySQL Driver 在連結 MySQL 資料伺服器。我們只要能夠使用它的 query() 方法,就能夠操作資料,而 $dbh 這個物件到底是怎麼跟 MySQL 溝通的,我們其實不在乎。以下是圖解:

如果現在要將資料庫系統轉換成 Oracle ,我們只要換掉 DSN 就好了,這樣不是很方便嗎?
註:當然 MySQL 所支援的 SQL 語法和 Oracle 還是有些許不同,但改動幅度已大大降低。
抽象的意義
所以抽象其實在物件導向開發中,是個很重要的觀念;它可以讓我們從不同卻又類似的模型中,找出一致性的操作方式。
而且像是「繼承」、「多型」及「封裝」其實都和「抽象」有著密切的關係,更可以說它們其實是一體的。
希望這個補充說明可以幫助上次沒聽懂這部份的伙伴們對物件導向有更深的體會囉!
如果有空,我會再對其他主題再做進一步說明的。
2009年01月4日
[Web] 連結分享
PHP
- Tutorial: Protecting php applications with PHPIDS
- Data structures in PHP 5.3
- Using PHP to Create and Draw Images
- Using PHP to Create and Draw Images pt. 2
- Creating Images with PHP Part 3
- Improved getopt() in PHP 5.3
- GZip files with .htaccess and PHP
- 用php做出類似Google的字詞驗證圖片
- Create a TinyURL with PHP
- 2½ Cool Hacks in PHP
- PHP 编程的 5 个良好习惯
- What's new in PHP V5.3, Part 1: Changes to the object interface
- What's new in PHP V5.3, Part 2: Closures and lambda functions
Zend Framework
- Using Zend_Form in Your Models
- PHPUnit: Testing Zend Framework Controllers
- Conditional Form Validation with Zend_Form
- Memcached in PHP Made Easy With Zend Framework
JavaScript
jQuery
- jQuery 不再使用 browser-detecting 的技巧
- jQuery.Modularize
- Peeling Away the jQuery Wrapper and Finding an Array
- What`s new in jQuery 1.3
- Ajaxify - jQuery plugin
- 10 Easy Tutorial jQuery
- jQuery 點擊 Input / Textarea 全選、複製的寫法(Widget)
- jQuery 樹狀勾選選單 - jquery.checktree.js
- jQuery Logging Plugin
- jQuery UI 1.6rc3 rc4: It’s getting really close
CSS
- Blurry Background Effect
- Background Images into Form Fields with CSS
- CSS Lightview Style Popup
- 53 CSS-Techniques You Couldn't Live Without
Web Development
Database
MySQL
Design
Security
Service
Software
System
2008年12月21日
[Web] 連結分享
PHP
- PHP V5.3新特性 第1部分
- A Simple PHP Publish-Subscribe System
- A hidden gem in PHP 5.3: fileinfo
- The adventure of PHP and the magic quotes
- PHP performance: error suppression
- 用 gd 做网页截图
- 40条PHP代码的优化技巧
Zend Framework
- ZendFramework version requirements
- On models in a Zend Framework application
- Tutorial: Using Zend_Captcha_Image
JavaScript
- XBug - The Javascript Debugger
- Javascript 抓取跨網域外的資料
- JavaScript timers - using functions and scope
- TIPS-依條件決定要呼叫的函數
- 25 Amazing JavaScript Games (Some Fun And Inspiration)
- FireUnit: JavaScript Unit Testing Extension
- FireUnit: Firebug Unit Testing for Firefox
- How to debug JavaScript with Visual Web Developer Express
jQuery
- Equal Height Columns with jQuery
- jQuery Random Link Color Animations
- jQuery Music Player Using Mouse Gestures & Hotkeys
- jQuery Countdown Plugin
- jquery.pngFix.js - PNG transparency for Windows IE 5.5 & 6 (IE PNG Fix)
- Improve your jQuery - 25 excellent tips
- Useful jQuery Cheatsheet
- Create a smooth tabbed menu in jQuery
- Using jQuery Clone
CSS
- 50 Extremely Useful And Powerful CSS Tools
- 40 Beautiful Dark CSS Website Designs
- CSS Stacked Bar Graphs
- Converting a Design From PSD to HTML
- How to Convert a PSD to XHTML - NETTUTS
- Extending CSS Spriting
- 5 Ways to Spice up Your Images with CSS
- 使用 CSS Sprites 設計網頁但不用 background-image 的技巧
- Pressed Button State With CSS
- CSS Navigation Bar Code Generator
- Advanced CSS Accordion Effect
Browser
- Re: The IE 6 Equation
- IE 6 方程式爭議
- The IE6 Equation
- It's Not a Bug, It's a Feature… No, It Really Is. Microsoft vs. Linux
- [FF] 在 Gmail 裏使用 Reader、Calendar、Picasa、News 等眾多 Google 服務
Database
MySQL
Programming
SCM
Security
Software
- 令人愛不釋手的免費磁碟重組軟體 - Defraggler
- phpMyAdmin的替代品:SQL Buddy
- SQL Buddy - Web based MySQL administration
- 8 Useful WordPress SQL Hacks
