Monster Oasis
覺得累就是進步的開始!

2009/08/20

編程最佳的字型 consolas / notepad++ 及 winscp 設定 / Best programming fonts

http://www.sitepoint.com/blogs/2009/05/01/top-10-programming-fonts/

173dd6cf51cee56ee41c03a4eea53d43 5f51869c4d702101b28643d2ce7ee81f eb97be5da4e6ee5ee99f97467c5b3187

Related URL:
  1. unix shell programming / sh / csh syntax

2009/07/16

Protected: 程式開發 的 Application Layout — Javascript 建立物件的方法

This post is password protected. To view it please enter your password below:


2009/04/02

50 好看好用的 icon

這個讚! 寫程式的都缺這東西

http://speckyboy.com/2009/02/02/50-of-the-best-ever-web-development-design-and-application-icon-sets/

感謝ㄚ毛

Related URL:
  1. 使用 memcache 的 design pattern

2009/03/14

Hypertext Transfer Protocol — HTTP/1.1 – 這可是現今最偉大的 protocol 呀!

The Hypertext Transfer Protocol (HTTP) is an application-level
protocol for distributed, collaborative, hypermedia information
systems. It is a generic, stateless, protocol which can be used for
many tasks beyond its use for hypertext, such as name servers and
distributed object management systems, through extension of its
request methods, error codes and headers
http://tools.ietf.org/html/rfc2616

Status Code Definitions
http://tools.ietf.org/html/rfc2616#section-10

204 No Content

The server has fulfilled the request but does not need to return an
entity-body, and might want to return updated metainformation. The
response MAY include new or updated metainformation in the form of
entity-headers, which if present SHOULD be associated with the
requested variant.

If the client is a user agent, it SHOULD NOT change its document view
from that which caused the request to be sent. This response is
primarily intended to allow input for actions to take place without
causing a change to the user agent’s active document view, although
any new or updated metainformation SHOULD be applied to the document
currently in the user agent’s active view.

The 204 response MUST NOT include a message-body, and thus is always
terminated by the first empty line after the header fields.

可以利用這點作一些事, 譬如記錄 user 的訪問, log 等等

Related URL:
  1. Protected: 觀察 22:40 – 23:15 apache log 的變化
  2. 解決用 NFS 當 documentroot 時會當掉的方法
  3. debian / ubuntu 裝 oracle instant client / sqlplus / oci8 / apache2 config / steps by steps
  4. [ubuntu] apache server module 的 enable / disable
  5. apache Custom Log Formats – 好用的參數
  6. Simple Monster Tracking System – step by step
  7. Protected: apache mod_rewrite , rewrite , rewriterule 真難搞
  8. 好用的 iptables rules – 限制 client 連 http port 的次數
  9. Monster LAMP Pack Lite – ver.317
  10. 安裝 apache / mod_memcache

2009/03/11

PHP Coding Standards

參考: Mantis : http://www.mantisbt.org/guidelines.php

中文翻譯: http://www.ichiayi.com/wikipage/tech/mantis_coding

First, start off by reading the PHP Coding Standards document. I’ve deviated in a few places but just about everything in the document applies here as well.

Above all, write code that is easy to read and maintain. Comment blocks of code and functions at all times. And get on my case if I deviate too much as well!

Naming Variables
  • Use all lower case.
  • Use _ to separate words, e.g. $green_color_value
  • Use descriptive names (except loop variables).
  • Loop variables can be of the usual variety: $i, $j, $k, etc.
  • Count variables should follow the format $*_count, e.g. $bug_count
  • Global variables should be prefixed with g_
  • Temporary variables should be prefixed with t_
  • Parameters and variables passed from forms that have been cleaned of any special SQL chars (i.e. slashes) should be prefixed with c_
  • Uncleaned function parameters should be prefixed with p_
  • Uncleaned variables passed from forms should be prefixed with f_
  • Other variables are prefixed with v_, v2_, etc.
  • Never prefix with l_ or o_ or q_ (visually confusing)
  • $query and $result should be used for SQL query and results respectively
Naming Functions
  • Use all lower case.
  • Use _ to separate words, e.g. setup_page_breaks()
  • Keep functions to 5 words or less
  • Functions that print should be prefixed with print_.
  • Try to use prefixes to group functions (i.e., email_, news_, etc.)
Naming Classes
  • Use FirstLetterOfWordIsCaptilized style
  • Variables that are class objects should have the prefix coo_
Naming Files
  • Use all lower case.
  • Use _ to separate words, e.g. view_new_bugs_page.php
  • Use .php file extensions
  • Filenames must be less than 32 characters in length. This plays nice with older file systems like Mac OS.
  • Included files should be suffixed by _inc.php
SQL formatting
  • UPPERCASE all SQL keywords:
    $query = "SELECT *
    	FROM $g_mantis_bug_table
    	WHERE id='1'";
  • Always assign a query string to a variable. This makes code easier to debug when problems occur. Do not create the query in the call to the function.
  • Break up SQL queries over multiple lines to be easy to read.
General Formatting
  • Use TABS with a size of 4
  • Follow the table formatting of existing pages
  • Use <?php ?> for php delimiters.
  • Try not to print/echo HTML unless it’s short or in a function loop
  • Do not use the EOF construct
Miscellaneous
  • Don’t use the ?: construct except in very rare cases. It is confusing and has a lot of bug potential.
  • Avoid magic numbers. The only magic numbers in use should be 1 and 0 and their meaning should be obvious.
Page Guidelines
  • The first item should be the copyright notice
  • At the bottom will be the footer information and closing print_ functions.
Braces and Parantheses
  • Parantheses should be right after a function name, e.g. function() not function ()
  • Parantheses should have a space right after a keyword (if, while, for), e.g. for (…)
  • Formatting of braces is illustrating below. We use unmatched placing.
  • Arrays should be referenced with no spaces, e.g. $arr['index'] not $arr[ 'index' ]
    for (...) {
        blah
    }
    
    or
    
    if (...) {
        blah
    }
  • if … else blocks should be in this format:
    if (...) {
        blah1
    } else {
        blah2
    }
Comparisons
  • The NOT operator should be placed next to its operand. No spaces, e.g. !$value
  • Parentheses should be used for grouping, especially with multiple comparisons, e.g. if ( ( null == $val ) && ( null == $val2 ) )
Strings
  • Use spaces around the string concatenation operator, e.g. ‘str ‘ . $value . ‘ str2′;
  • Use ‘ instead of " if there are no variables or special characters.
Comments
  • Use the # symbol for line commenting, not //
  • Use /* */ for block commenting unless you nest /* */ comments. Generally, only use this during development.
  • Use @@@ followed by a brief message (BROKEN, TEMPORARY, etc) as a "look at this" indicator. Leaving your name next to is a good idea. This way critical items can easily be found.
Editor Features
  • Search and replace in multiple files
  • Goto line number
  • Syntax highlighting
  • Adjustable TAB spacing
Related URL:
  1. Protected: [sample code] preg_match , regular expression match ,
  2. debian / ubuntu 裝 memcached 跟 pecl memcache
  3. 一些 memcache 的資料
  4. debian / ubuntu 裝 oracle instant client / sqlplus / oci8 / apache2 config / steps by steps
  5. gentoo emerge php options
  6. 用 pecl inclued 產生關聯圖
  7. oci / compile php with oracle instant client
  8. [note] javascript 的 foreach / split / php explode style 寫法
  9. Codeigniter 聯接 Oracle database 要改的地方
  10. install oracle instant client basic on gentoo linux step by step

2009/02/24

[note] javascript 的 foreach / split / php explode style 寫法

var loc="25.258861, 121.509389";
var arr=loc.split(","); 

var content = '';
for (var key in arr) {
  content += key + ' : ' + arr[key] + "\n";
}

另一個

var myarr = new Array('red','green','blue');

var content='';
for(var key in myarr){
	content += key+' : '+myarr[key]+"\n";
}

alert( content );
Related URL:
  1. Protected: Top 10 custom JavaScript functions of all time
  2. jQuery 學習程式

2009/01/18

[摘] Javascript MIME type / Apache 的 javascript default MIME type 跟 official MIME type of javascript 設得不一樣

Filed under: Programming/javascript — Tags: , — 10:43 am

http://jsgears.com/thread-158-1-1.html

org: http://annevankesteren.nl/2005/02/javascript-mime-type

Google 有部份 .js 從 server 端送出時是給 text/javascript

Related URL:
  1. Protected: 觀察 22:40 – 23:15 apache log 的變化
  2. 解決用 NFS 當 documentroot 時會當掉的方法
  3. debian / ubuntu 裝 oracle instant client / sqlplus / oci8 / apache2 config / steps by steps
  4. [ubuntu] apache server module 的 enable / disable
  5. apache Custom Log Formats – 好用的參數
  6. Simple Monster Tracking System – step by step
  7. Protected: apache mod_rewrite , rewrite , rewriterule 真難搞
  8. 好用的 iptables rules – 限制 client 連 http port 的次數
  9. Monster LAMP Pack Lite – ver.317
  10. 安裝 apache / mod_memcache

2009/01/04

Blog 裡飄雪的效果

Filed under: Copy_N_Paste,FUN,Programming/javascript — 9:59 pm

12c0c8b7d4634ebee4f9d57c09f9398c

把這行加到網頁中就好囉
http://s1.wordpress.com/wp-content/plugins/snow/snowstorm.js

2008/11/11

[影片] The Ajax Universe

Filed under: Programming/javascript — 9:52 pm

From jsGears.com 技術論壇 http://www.jsgears.com/thread-133-1-1.html

如果程式語言是艘船, 那麼 …. 是….

http://compsci.ca/blog/if-a-programming-language-was-a-boat/

這個議題肯定引起 programmer 的大戰

下頁»

www.monster.com.tw , © Copyright 2008