Search

4/29/2006

CSS-note

 margin: 2em  0      2em   0;
/* top right bottom left; */

margin: 2em 0;
/* top&bottom left&right */

margin: 2em 0 2em;
/* top right&left bottom */


我要怎樣在滑鼠游標移動到表格中某列時,改變背景色。
for Mozilla
.datatable tr:hover{
background-color: #DFE7F2;
cololr: #000000;
}

for IE (:hover在Internet Explorer上,仍無法作用於連結之外的元素)
.datatable tr:hover, .datatable tr.hilite{
background-color: #DFE7F2;
color: #000000;
}

<script type="text/javascript">
var rows = document.getElementByTagName("tr");
for(var i=0; i<rows.length; i++){
rows[i].onmouseover = function(){
this.className += ' hilite';
}
rows[i].onmouseout = function(){
this.className = this.className.repalce('hilite', ' ');
}
}
</scrit>


!important Declaration
The following example includes the !important declaration in the style rule. Normally the color of the text would be green, because inline styles override the rules set in a style tag. By including the !important declaration in the style rule, you set the content of the paragraph to red.
<STYLE>
P { color:red!important }
</STYLE>
<P STYLE="color:green">This text will be red.</P>

今日閱讀 2006-04-29

當代網頁設計,Javascript+DOM (cache)

4/28/2006

今日閱讀 2006-04-28

4/27/2006

Firefox Search Plugin

"POST類型是沒辦法做成plugin的,那些成功的,應該是因為該網站的後端程式,沒有限定參數傳送的方式是POST還是GET

拿PHP來說好了,可以用$_POST['a'],來接收一個類型為POST的參數"a",可是,如果使用$_REQUEST['a'],則無論a是透過GET還是POST
類型傳送,都可以被PHP接收到喔

[via]

4/26/2006

TestDisk

今天不小心把一個ntfs partition給誤刪了,(磁碟管理居然沒確認的動作) ,本來是刪一個linux swap的partion,不知道為啥那個ntfs partition就看到了 ,跑到ubuntu下面也看不到,看來是已經寫到table裡面去了。

然後跑去google找,找到一個叫做TestDisk的工具,兩三下就找到我誤刪的partition了,
如果用Finaldata等等工具,檔案還要一個一個救, 更重要的是,

TestDisk is OpenSource software and is licensed under the GNU Public License (GPL).

4/21/2006

常用正規表示法

中文字符     [\u4e00-\u9fa5]
雙字節字符 [^\x00-\xff]
URL a-zA-z]+://[^\s]*
ip address \d+\.\d+\.\d+\.\d+
Email \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
[via]

4/19/2006

JavaScript For Beginners-Note

JavaScript For Beginners - The Code Project - JavaScript (cache)
A very good javascript tutorials for beginners.

Object: Function, Array, Date, RegExp

Regular expression methods:
search(), replace(), match(), split()

//傳回4, i表示忽略大小寫,
//如沒有找到傳回-1, search不支援全域g
"JavaScript".search(/script/i);

//忽略大小寫將text中所有的javascript
//全置換成Javascript
text.replace(/javascript/gi, "Javascript");

//回傳一個包含了比對結果的陣列,
//以下回傳["1","2","3"]
"1 plus 2 equals 3".match(/\d+/g)

Message box: alert, confirm, prompt

<script>
function ss(){
var ok=confirm('Click "OK" to go to yahoo, "CANCEL" to go to hotmail');
if (ok)
location="http://www.yahoo.com";
else
location="http://www.hotmail.com";
}
</script>
<body onload="ss();">
</body>


Form
<form name="aa">
<input type="text" size="10" name="bb">
<input type="button"value="Click Here" onclick="alert(document.aa.bb.value)">
</form>


Date methods:
getDate, getDay, getSeconds, getTime, getMonth,
getMinutes,getTimezoneOffset, getYear, getHours

windows attributes:
width, height, toolbar, location, directores, status, scrollbars, resizable, menubar
//open("URL","name","attributes")
<form>
<input type="button" value="Click"
onclick="window.open('page2.htm','win1','width=200,height=200')">
</form>

4/13/2006

Reverse Strings in Place

/* reverse: reverse string s in place */
void reverse (char s[]{
int c, i ,j;
for (i = 0, j = strlen(s) - 1; i < j; i++, j--){
c = s[i];
s[i] = s[j];
s[j] = c;
}
}

Windows Live Academic

http://academic.live.com/
Something like "Google Scholar"

4/11/2006

AJAX Resources

Common XMLHttpRequest Object Methods

  • abort()
  • getALLResponseHeaders()
  • getResponseHeader("headerLabel")
  • open("method", URL[, asyncFlag[, "username"[, "password"]]])
  • send(content)
  • setRequestHeader("label", "value")

Common XMLHttpRequest Object Properties

  • onreadystatechange
  • readyState
  • responseText
  • responseXML
  • status
  • statusText

4/04/2006

PHP Functions

string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] )

object simplexml_load_file ( string filename [, string class_name [, int options]] )
兩個都可以取代fsockopen, 直接通過GET or POST擷取網站資料。
因為Flickr API傳回的是XML格式, 所以只能用simplexml_load_file。

Flickr API Example


//var_dum($xml) output
object(SimpleXMLElement)#1 (1) {
["photos"]=>
object(SimpleXMLElement)#2 (1) {
["photo"]=>
array(100) {
[0]=>
object(SimpleXMLElement)#3 (0) {
}
[1]=>
object(SimpleXMLElement)#4 (0) {
}
.........
[99]=>
object(SimpleXMLElement)#102 (0) {
}
}
}
}


function photo_url($p, $size='t', $ext='jpg'){
return "http://static.flickr.com/{$p['server']}/{$p['id']}_{$p['secret']}_$size.{$ext}";
}

$url ="http://flickr.com/services/rest/?method=flickr.people.getPublicPhotos".
"&user_id=79211125%40N00&api_key=YourAPIKey";

$xml = @simplexml_load_file($url) or die("Unable to contact Flickr");
$perpage = $xml->photos['perpage'];
$total = $xml->photos['total'];

foreach($xml->photos->photo as $photo){
print photo_url($photo,'s');
// print $photo['title'];
}

4/03/2006

Backup

Flickr所有相片的XML file
http://chunghe.googlepages.com/www.flickr.com.xml

目前範本剛套用的原始檔
http://chunghe.googlepages.com/chunghe.blogspot.com-original.txt

目前使用的範本(有Flickr badges)
http://chunghe.googlepages.com/chunghe.blogspot.com-final.txt

Flickr photo restore

1. go to Flickr API
2. use Flickr.people.getPublicPhotos with per_page & page arguments
3. API explorer to generate a XML file
4. Photo URLs to generate static address for each photo

Flickr Badges

Flickr Badges
Flickr Badges Formatting
Flickr相片展示教學
通過CSS定義控制Flickr的顯示效果

CSS Example:


.flickrimg {border: 1px solid #ccc; padding:4px; margin:5px 5px 5px 0px; height: 55px;
width: 55px; opacity: 0.8;}
.flickrimg:hover {border: 1px solid #777; opacity:1;}

Flickr Random Photo Demonstration:



Integer Constants

int main(){

printf("%d ", 011);
//數字011, 八進位
printf("%d ", 0x11);
//數字0x11, 十六進位

printf("%o ", 10);
//把10用八進位印出來

printf("%x ", 25);
//把25用十六進位印出來
}
output
/*
9 17 12 19
*/

getchar()

main(){
char c;

while((c=getchar()) != EOF)
putchar(c);
}

getchar returns an integer
The getchar function returns the next character from the standard input,
or EOF(a value, defined in stdio.h, which is distinct from any character)
if there is no input left.
在VC中EOF的值為-1,如果用char不帶正負號,則這個程式會出錯。
正確的寫法應該宣告c為int

#define getchar() getc(stdin)

sscanf

void main()
{
char arr[80];
int i,j,k;
strcpy(arr,"1 2 3");
sscanf(arr,"%d",&i);
sscanf(arr,"%d",&j);
sscanf(arr,"%d",&k);
printf("( %d %d %d )",i,j,k);
}
// output: (1 1 1)


in your example, when you take the first input (i) from the string,
the string itself (arr) is never changing. so whenever you take
another input (j) from the same string (arr) , they (i and j) will be the same.

void main()
{
char arr[80];
int i,j,k;

strcpy(arr, "1 2 3");
sscanf(arr, "%d %[^n]", &i, arr);
//每次都把%[^n]的結果寫回arr
sscanf(arr, "%d %[^n]", &j, arr);
sscanf(arr, "%d %[^n]", &k, arr);
printf("(%d %d %d)n", i, j, k);
}
// output: (1 2 3)


[about using "sscanf" :=)]

[problem with sscanf()]

Bitwise operation

Bitwise operation

Setting k-th bit of x:       x |= 1 [shift] k
Clearing k-th bit: x &= ~(1 [shift] k)
Getting k-th bit: return (x [shift] k) & 1
Flipping k-th bit: x ^= 1 [shift] k (replaces 0 by 1, and 1 by 0.)

ex: 10311 - Goldbach and Euler
[via]

Adobe Reader Enterprise Edition

http://www.adobe.com/products/acrobat/readstep2.html?type=distrib

http://digg.com/software/Download_Adobe_Reader_Enterprise_Edition

No download manager, No Yahoo! toolbar or PASE, Simple licensing agreement.

ACM TW Ranklist

查詢在自己國家的解題數排名
http://www.felix-halim.net/oj/ranklist.php?country=tw

幫你找到簡單的題目
http://www.felix-halim.net/oj/problems.php

大數問題

This is a list I made by searching through my hard disk for calls to bigint *, /, % and pow operations. Some problems might be possible to solve using only +, - or long long (or maybe I missed the correct way to solve it, without big numbers).

485 - Pascal Triangle of Death
495 - Fibonacci Freeze - plus Fibonacci
10007 - Count the Trees - plus Catalan formula
10183 - How Many Fibs - plus Fibonacci
10219 - Find the Ways ! - plus Catalan formula
10220 - I Love Big Numbers ! - plus Catalan formula
10303 - How Many Trees? - plus Catalan formula
10334 - Ray Through Glasses - plus Fibonacci
10519 - !!Really Strange!!
10579 - Fibonacci Numbers - plus Fibonacci

239 Tempus et mobilius, time and motion
254 Towers of Hanoi
288 Arithmetic operations with large integers
324 Factorial frequencies
338 Long multiplication
367 Halting factor replacement systems
504 Random number
560 Magic
619 Numerically speaking
623 500!
748 Exponentiation
787 Maximum sub-sequence product
10007 Count the trees
10023 Square root
10070 Leap year or not leap year and...
10106 Product
10176 Ocean deep! - make it shallow!!
10213 How many pieces of land?
10220 I love big numbers!
10303 How many trees?
10359 Tiling
10494 If we were a child again
10519 !! Really strange !!
10521 Continuously growing fractions
10523 Very easy!!!
10527 Persistent numbers
10606 Opening doors
10658 ReArrange
10814 Simplifying fractions
10836 The maximum term
10862 Connect the cable wires

I’m sure that someone who’s solved more of volume 100-107 than me can add a lot of problems to this list.

Visual C Debugging

單步除錯

Step Into:追蹤進入副程式內部,[F11]
Step Over:可跳過副程式內部, [F10]
Stop Debugging: Debug->Stop Debugging [shift+f5]