紅茶小館

一杯紅茶喜相逢 Share Web Tech and Life …
Jul 22
PHP design pattern
icon1 vincent | icon2 PHP | icon4 07 22nd, 2008| icon3157 Comments »

最近在研究 design pattern,

因為對 php 最熟, 理解比較容易,這個 site 有 詳盡的例子

http://www.phppatterns.com/docs/?idx=blogs

一理通, 百理明, design pattern 對 java , c# 也是 一樣的吧.

Jul 22
flash 優秀教程
icon1 vincent | icon2 Flash | icon4 07 22nd, 2008| icon3No Comments »

FL  大師

http://blog.sina.com.cn/s/articlelist_1053530897_10_1.html

AS 2.0 和 3.0 都有. 值得一讀。

一堆有用的 function

http://log.7thpark.com/article/Study-and-Tutorial/my-own-useful-actionscript-code-collection.html

Jul 13
Life : share blog
icon1 vincent | icon2 life | icon4 07 13th, 2008| icon3No Comments »

今天路過一個blog, 很少這麼詳細看一個 blog 的內容,
很多各種 音樂 video 和信仰的分享。也是一個WEB程式員,
有空再去看看。
http://pawls.blogspot.com/

Jul 13

用這個 function 就可防止圖片大於screen, 難於觀看。


 $("img").each(function(){
     if($(this).width() > $(this).parent().width()) {
         $(this).width("100%");
     }
 }); 
Jul 8
CSS 圖片垂直居中
icon1 vincent | icon2 CSS | icon4 07 8th, 2008| icon337 Comments »

把圖片放在 table 裡, 再把 table id 改成 wrapper 即可。



   html, body, #wrapper {
      height:100%;
      margin: 0;
      text-align: center;
   }
   #wrapper {
      margin: 0 auto;
   }


Jul 8
php text content to utf8
icon1 vincent | icon2 PHP | icon4 07 8th, 2008| icon337 Comments »

一些簡單的步驟即可。

$raw_text = file_get_contents( "http://www.google.com");
$utf8_text = iconv( $encoding, "utf-8", $raw_text );
$utf8_text = html_entity_decode( $utf8_text, ENT_QUOTES, "UTF-8" );
Jul 8
php parse content
icon1 vincent | icon2 PHP | icon4 07 8th, 2008| icon337 Comments »

在 oReilly 的書上看到一個例子, 幾個 function retrieve URL 很有用。

  1. function getURL ($pURL) {
  2.  $_data = null;
  3.  if ($_http = fopen ($pURL, "r")) {
  4.  
  5.   while ( !feof ($_http)) {
  6.    $_data .=fgets ($_http, 1024);
  7.  
  8.   }
  9.   fclose ($_http);
  10.  }
  11.  return ($_data);
  12. }
  13. function cleanString ($pString) {
  14.  $_data = str_replace ( array( chr(10), chr(13), chr(9)), chr(32), $pString);
  15.  while ( strpos( $_data, str_repeat( chr(32), 2), 0) != false) {
  16.   $_data = str_replace ( str_repeat(chr(32),2), chr(32), $_data);
  17.  }
  18.  return trim($_data);
  19. }
  20. function getBlock ($pStart, $pStop, $pSource, $pPrefix = true) {
  21.  $_data = null;
  22.  $_start = strpos(strtolower($pSource), strtolower($pStart),0);
  23.  $_start = ( $pPrefix ==false) ? $_start + strlen($pStart):$_start;
  24.  $_stop = strpos ( strtolower ($pSource), strtolower ($pStop), $_start);
  25.  if ($_start > strlen($pelement) && $_stop >$_start ) {
  26.   $_data = trim( substr( $pSource, $_start, $_stop - $_start ));
  27.  }
  28.  return ($_data);
  29. }
  30.  
  31. function getElement($pElement, $pSource) {
  32.  $_data = null;
  33.  $pElement = strtolower($pElement);
  34.  $_start=strpos(strtolower($pSource), chr(60) . $pElement, 0);
  35.  $_start=strpos($pSource, chr(62), $_start ) +1;
  36.  $_stop = strpos ( strtolower($pSource), "<!–" . $pElement . chr(62), $_start );
  37.  if ($_start–>strlen($pElement) &amp;&amp; $_stop &gt; $_start) {
  38.    $_data = trim (substr($pSource, $_start, $_stop - $_start));
  39.  
  40.  }
  41.  return ($_data);
  42. }
Jul 4
PHP plain text to html
icon1 vincent | icon2 PHP | icon4 07 4th, 2008| icon3No Comments »

工作需要把一個 folder 裡的 text file 轉成 html

這個網站有sample code, 只要寫個function read directory,

把 filename 放到 array 裡即可。

Jul 2

另一個手工打造的 Jquery 例子.較輕巧方便。

http://15daysofjquery.com/edit-in-place-with-ajax-using-jquery-javascript-library/15/

Jul 2
Jquery edit in place
icon1 vincent | icon2 JavaScript | icon4 07 2nd, 2008| icon31 Comment »

Project 需要做一個 in place edit 的表格,

JQuery 已有plug-in, 相當好用. 不用自己寫 . good~

http://blog.yoren.info/tag/edit-in-place/

Jul 2
ajax sample code
icon1 vincent | icon2 JavaScript | icon4 07 2nd, 2008| icon31 Comment »

每個 Event 都有手工打造的 ajax 例子, 可以下載 source code

研究. 用了mvc model.

http://www.studiosedition.com/?events=