Go to content Go to navigation Go to search

Note Config Apache

August 30th, 2009 by chaubl

Cấu hình cho Apache hiển thị file Gzip .

- Cài module mod_defalte.so vào thư mục …/apache2.2/modules

- Sửa file …/apache2/conf/httpd.conf enable mod_deflate.so
LoadModule deflate_module modules/mod_deflate.so

- Add MultiViews to Options:
Options Indexes FollowSymLinks MultiViews

- Uncomment AddEncoding:
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
- Comment AddType:
#AddType application/x-compress .Z
#AddType application/x-gzip .gz .tgz

- Để hiển thị file Gzip dưới dạng xml thêm dòng :
AddType text/xml .gz .tgz

- Khởi động lại Apache:
…/httpd restart

Actionscript 3 coding conventions and best practices

July 5th, 2009 by ngocbd

http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

MỘT NGÀY PHẢI KHÁC MỌI NGÀY

June 20th, 2009 by ngocbd

MỘT NGÀY PHẢI KHÁC MỌI NGÀY

(Sau một ngày thống kê một cách khách quan những bi hài kịch thời sự nóng hổi)

Chào một ngày giống hệt mọi ngày

Sóng truyền hình phủ toàn phim Trung Quốc

Từ HTV, VTV, BTV, Đồng Nai, Long An, Bà Rịa Vũng Tàu, Cà Mau… cho đến “cáp”

Hết “Triều Đại Mãn Thanh” đến “Đại Tống Truyền Kỳ”

Chào một ngày giống hệt mọi ngày

Đọc báo thấy cha ông mất hút

Thấy thiên hạ quỳ mọp dưới tượng đài Binh Pháp Mặc Công, Ngọa Hổ Tàng Long, Họa Bì, Xích Bích…

Con nít thuộc lòng Hoắc Nguyên Giáp, Hoàng Phi Hồng, Diệp Vấn, Diệp tùm lum hơn thuộc sử Tiên Rồng

Chào một ngày đất nước tự lưu vong

Cội rễ văn hiến 4000 năm trốc gốc

Tuổi teen gối đầu giường Lý An, Ngô Vũ Sâm, Trương Nghệ Mưu, Trần Khải Ca lạ hoắc

Pano giăng khắp nơi hình ảnh Củng Lợi, Chương Tử Di, Thành Long phơi phới toét miệng cười

Chào một ngày phát triển giống đười ươi

Đi trên xã tắc thấy người thua xa khỉ

Thấy lô cốt ngáng đường, thấy nước ngập tận mông, thấy thánh hiền sợ quỷ

Thấy truyền thống chống ngoại xâm co rúm lại vì… tiền

Chào một ngày vong bản vì… hèn

Sống chết mặc bây, túi thầy vô cảm

Ải Nam Quan nằm ngoài ranh giới Việt Nam, xưa rồi Diễm…

Nước mắt Nguyễn Trãi khóc Nguyễn Phi Khanh rơi ở tận… nước Tàu

Chào một ngày bãi biển hóa nương dâu

Thác Bản Giốc rời Cao Bằng như có cánh

Thắng cảnh để lại của tiền nhân bị cháu con ghẻ lạnh

Các di tích, kỳ quan cứ mất tích đều đều

Chào một ngày hình chữ S tong teo

Tài nguyên bôxit bị bới đào như… bọ xít

Nhôm và đô la chẳng thấy đâu, chỉ thấy đất Tây Nguyên rên xiết

Ô nhiễm mạch ngầm, nước sông làm nghẹt thở Chín Con Rồng

Chào một ngày long mạch bị xới tung

Máu bầm đất đỏ bazan, máu tràn ra hải đảo

Ai cho phép Hoàng Sa Trường Sa thành Tam Sa lếu láo

Tội nghiệp rừng cọc nhọn của Hưng Đạo Đại Vương trên sóng Bạch Đằng

Chào một ngày giống hệt cõi âm

Những xác chết anh hùng bật dậy

Máu trả máu, đầu trả đầu. Nhớ đấy

Mãi quốc cầu vinh tất quả báo nhãn tiền

Chào một ngày soi rõ mặt anh em!

21 – 4 – 2009

BÙI CHÍ VINH

Giải thử vài câu đề thi tốt nghiệp ptth môn toán

May 30th, 2009 by ngocbd

Xem đề thị tại đây : http://www.thanhnien.com.vn/News/Documents/GiaoDuc/PTTH/2009/Dapan/DeToan_GDTHPT.pdf

Tất nhiên là giải theo cách thông thường thì các bạn xem trong đáp án :P

Ở đây là phương pháp  giải “khác” :D .

Câu 1:
1.

Khảo sát và vẽ đồ thị hàm số :
http://www57.wolframalpha.com/input/?i=(2x%2B1)%2Fx-2
Câu 2
2.1.

Giải phương trình :
http://www57.wolframalpha.com/input/?i=25^x-6*5^x%2B5%3D0
2.2.

Tính tích phân :

http://www57.wolframalpha.com/input/?i=integral+[x(1%2Bcos(x))%2C0%2Cpi]
2.3.

Tìm max – min trên một đoạn .
min :

http://www57.wolframalpha.com/input/?i=minimize+x^2-ln(1-2x)+over+[-2%2C0]
max :
http://www57.wolframalpha.com/input/?i=maximize+x^2-ln(1-2x)+over+[-2%2C0]

Câu 4

4.a.1

Tính toạn độ tâm và bán kính của hình cầu

(x-1)^2+(y-2)^2+(z-2)^2 = 36

http://www61.wolframalpha.com/input/?i=(x-1)^2%2B+(y-2)^2%2B(z-2)^2%3D36

vậy

tâm S(T) : (1,2,2)
bán kính :6

Câu 5
5.a.

Giải phương trình trên tập số phức
http://www57.wolframalpha.com/input/?i=8x^2+-4x+%2B1+%3D0
5.b.
Giải phương trình trên tập số phức

http://www57.wolframalpha.com/input/?i=2x^2+-+i+x+%2B++1+%3D0

Tạm vậy đã các , các câu khác ai có cách  giải thì commnet nhé  !

Funny web2.0

May 28th, 2009 by hoangnd

IE webrender – Công cụ kiểm tra web design trên IE

May 26th, 2009 by ngocbd

http://ipinfo.info/netrenderer/

Với công cụ trên không những kiểm tra đựoc thiết kế , mà còn có thể xem trực tiếp sự sai khác giữa các phiên bản IE (6-7)

Công cụ khủng hơn :D

http://browsershots.org

Demo

http://browsershots.org/http://khuvuc.com/

hay http://www.browsercam.com

Skype and Facebook plugin for Pidgin

May 26th, 2009 by ngocbd

http://code.google.com/p/skype4pidgin/

http://code.google.com/p/pidgin-facebookchat/

[Note] Sinh lại RSA Key cho ssh client

May 19th, 2009 by ngocbd

Hôm nay cài lại server ssh lên không thiêng .
Lỗi là tại RSA key ở client đã cũ (do ssh server được cài lại).
gõ lệnh sau để gen lại ssh key cho client

“ssh-keygen -R ip_addressInConflict”

TUT Làm bản đồ đại lý

May 18th, 2009 by habogay

Công việc này có thể làm bạn nghĩ đến giải pháp google maps nhưng theo tôi   dùng google map và maker api của nó là quá phức tạp . Thôi thì tự làm một cái vậy .

Yêu cầu của bài toán là vẽ một bàn đồ nước việt nam , trên đó vị trí các tỉnh thành phố có đại lý của công ty XYZ thì xuất hiện maker (Dùng hình ngôi sao hoặc chấm tròn) và tên tỉnh thành pố có đại lý đo .

Nếu người dùng click vào tỉnh thành phố nào thì xuất hiện chi tiết danh sách các đại lý trực thuộc tỉnh thành phố đó .

Các đồ nghề cần sài : Flash IDE  (CS2) , PHP 5 , Mysql 5 , GIMP (Hoặc PS)

Đầu tiên là làm một cái flash có hiển thị tên các tỉnh thành .

B1 Kiếm một cái bản đồ việt nam (dạng khung) :

google nào

Tôi chọn cái ảnh thứ 2 :

Giờ là lúc dùng đến GIMP để sửa sang nó

Kết quả :D

Cũng không tệ lắm

B2. Tạo flash document có kích thước lớn hơn bức anh một chút : 325×680

Import bản đồ vào .Kéo bản đồ từ lib vào stage nếu bạn import nó vào lib . Đặt tên cho instance là map .

Xong .

B3. Vẽ hình ngôi sao :D

Convert ngôi sao thành Moviclip (nhớ chọn option Export for Actionscript) . Đặt tên cho Class là ” Star”  .

B4. Tạo file chứa tên tỉnh thành và tọa độ của chúng . Tất nhiên cái này phải lấy từ  csdl nhưng trước mắt cứ lấy đại một cái file tĩnh đã , sau này chỉ cần sửa lại url trỏ vào file php là xong .

tạo một file data.txt để giả lập dữ liệu lấy ta từ  csdl . giả sử file này đặt ở http://localhost:81/data.txt

data.txt:
Hanoi=30-20&Saigon=40-50

Tôi lưu file theo cấu trúc : “tên tinht thành=tọa độ x- tọa độ y”

tiếp theo mở actionscript code thẳng vào frame 1 .

import flash.net.*;
var myLoader:URLLoader = new URLLoader()
//the data will come as URL-encoded variables
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Load using an URLRequest, even beeing local
myLoader.load(new URLRequest(“http://localhost:81/data.txt”));
//add a listener for the complete event
myLoader.addEventListener(Event.COMPLETE, onLoadHandle);
function onLoadHandle(ev:Event):void{

for (var name in myLoader.data){
trace(name+”:”+myLoader.data[name]);

}
}

Chạy thử đoạn code trên :

kq:

Hanoi
30-20
Saigon
40-50

Tiếp theo là thay vì trace ta sẽ add các ngôi sao lên các vị trí tương tứng :

var mc:Star = new Star();
var valuePair:String=String(myLoader.data[name]);
var arr=         valuePair.split(“-”);
mc.name=name;
mc.x=arr[0];
mc.y=arr[1];
addChild(mc);

Thay đoạn code này vào trong vòng for .

Ta sẽ thấy xuất hiện 2 ngôi sao ở vị trí 30-20 và 40-50 .

Giờ là lúc tìm vị trí chính xác cho 2 ngôi sao này (Dùng GIMP đo tọa độ trên ảnh )

Đây là kết quả của tôi :D (chắc chắn là chưa chính xác vì tôi áng khoảng thôi , bạn phải khớp với bản đồ thật)

Hanoi=137-108&Saigon=179-570

Chạy lại : Hai ngôi sao đã phù hợp với vị trí các tinht thành , nếu muốn có thêm các tỉnh thành khác bạn chỉ việc thêm vào file data.txt .

B5. Xử lý tên tỉnh thành nằm cạnh ngôi sao :

import flash.net.*;
import flash.text.TextField;
var myLoader:URLLoader = new URLLoader()
//the data will come as URL-encoded variables
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Load using an URLRequest, even beeing local
myLoader.load(new URLRequest(“http://localhost:81/data.txt”));
//add a listener for the complete event
myLoader.addEventListener(Event.COMPLETE, onLoadHandle);
function onLoadHandle(ev:Event):void{

for (var name:String in myLoader.data){

var mc:Star = new Star();

var valuePair:String=String(myLoader.data[name]);
var arr=         valuePair.split(“-”);
mc.name=name;
var txt:TextField = new TextField();
txt.text=mc.name;

mc.x=arr[0];
mc.y=arr[1];
mc.addChild(txt);
addChild(mc);

}
}

Tạm thế đã . :D

Copy and paste Programming VIA Copy and paste Writing

March 19th, 2009 by ngocbd

I was always against Copy and Paste programming. I condemned people who use this practice as discrediting the honorable profession of The Programmer. This evil activity inflates application code without adding anything useful. This shameful practice causes various complications – more code, more things to remember, needless complexity, and difficulty to manage and synchronize related changes in the future. But at some point, I admitted to myself – things are not so black and white. I do Copy and Paste in my code, it is difficult to resist this seductive activity.

The only indulgence is that I’m very keen to eliminate bad effects of Copy and Paste before finishing my task.

I use two main approaches for writing new code. The first is Top-Down – I have clear design ideas how I should program and I know what classes and components to use. I go ahead and write code from scratch using my memory and power of intellect :) . There are few problems with this approach. Unfortunately, my memory is not so great and knowledge is not so vast. Regularly I have new tasks that I don’t know or don’t remember how to program. Sometimes I don’t get immediately what other people programmed without debugging. And often I want to save time and avoid re-implementing the same idea again. And that is why I also use the second approach – Bottom-Up. I copy and paste code first. And after I figure out how this code works, how to use, fit and improve it.

When is Copy and Paste approach useful?

Shamelessly, I can come up with few cases:
1. Work by example – you found new code through search and want to  use it immediately to solve your problems.
2. Quick start – you copy code (including your old code) to save time.
3. Test in the new context – you want to quickly assess if code will be correctly running in the context of your application
4. Too hard to reuse – if you cannot reuse, just copy code. For example, you don’t have time to build common framework with separate application or another team owns code and don’t want you to touch and spoil it.
5. Series of experiments – you try to find the best way to solve a problem and copy code to try if it solves a problem well.

How to eliminate bad effects of Copy and Paste

Now I’m going to return to canonical view on evilness of Copy and Paste. Even if you have legitimate reason to use Copy and Paste, it is acceptable only on temporary basis before you commit your code or your team granted absolution (probably for very short time) :) .
Therefore, after committing Copy and Paste scandalous act, do following:
1. Understand what have you done - any code that you don’t understand is ineffective for future use, and potentially excessive, wasteful and dangerous.
2. Clean, minimize and shape – remove all useless, over-engineered and questionable pieces; consider yourself as a jeweler, who is converting rough crystals in beautiful diamonds that fit well into solid code and concepts in your program.
3. Refactor and Integrate – use refactoring techniques to integrate new cleaned code into existing application: improve design, simplify and increase power of your code.
4. Learn - the best outcome of this sinful activity is gained knowledge and experience that will make Copy and Paste unnecessary next time.

With age and experience of harsh programming reality, I’m becoming less purist and more pragmatic. I have started to accept everything what makes me effective. The only rule – I shouldn’t be ashamed of my code after the finish… even if I did Copy and Paste couple times ;)

What do you think?

source  : http://softwarecreation.org/2008/a-few-words-in-defense-of-copy-and-paste-programming/

« Previous Entries