Showing posts with label fun. Show all posts
Showing posts with label fun. Show all posts

Monday, April 06, 2009

English Talking Practice

Sau bài về cách luyện kỹ năng nghe thì có một số bạn hỏi tôi có tips nào tương tự như thế để luyện nói hay không .

Dĩ nhiên là có rồi :-)

Nhưng nên nhớ có nhiều phương pháp học tiếng Anh và bạn có thể áp dụng vài cách trong số đó miễn là bạn cảm thấy phù hợp với mình và có hiệu quả.
Điều quan trọng là không nên áp dụng TẤT CẢ quy tắc hoặc cách học của người khác. Khi học theo một cách nào đó, nên thử chỉ 1 cách đó hoặc tối đa là 2, 3 cách; đừng dại dột mà thử nhiều cách mới cùng lúc, bởi khi đó bạn sẽ khó nhận thấy kết quả.


Sau đây là một số quy tắc quan trọng để học tiếng Anh, chủ yếu giúp cải thiện khả năng Talking, mà bản thân tôi cảm thấy rất hiệu quả. Nếu bạn đã có căn bản về ngữ pháp tiếng Anh thì áp dụng những cách này sẽ giúp bạn cải thiện việc giao tiếp với người nước ngoài trong thời gian ngắn !


1/ Từ vựng: học theo CỤM TỪ (câu ngắn cũng có thể xem là 1 cụm từ)
REASON:


2/ Gặp người nước ngoài: đừng bận tâm ngữ pháp
REASON:


3/ Trong lớp học: chỉ dùng tiếng Anh (các địa điểm như English Club cũng vậy)
REASON:


4/ Nghiền ngẫm: nghe lặp đi lặp lại để hiểu (ko dùng thiết bị thì tự mình đọc)
REASON:


5/ Ngữ pháp: nắm vững cơ bản (Simple Past, Simple Present, Present Perfect, Simple Future) qua các đoạn kể.
REASON:


6/ Cập nhật: học từ vựng thực tế, hiện đại qua các bản tin và Internet sites.
REASON:


7/ Phản xạ với tiếng Anh: bằng các đoạn Hỏi Đáp đơn giản thực tế
REASON:



Have fun ! and Good Luck !

Wednesday, February 18, 2009

Tuesday, November 18, 2008

Some eponymous laws

which relates to software development or project management :D .



Brooks’ Law

Adding manpower to a late software project makes it later.



Parkinson’s Law

Work expands so as to fill the time available for its completion.



Hoare’s Law of Large Programs

Inside every large problem is a small problem struggling to get out.



Lister’s Law

People under time pressure don’t think faster.



Pareto Principle

For many phenomena, 80% of consequences stem from 20% of the causes.



The Peter Principle

In a hierarchy, every employee tends to rise to his level of incompetence.



Conway’s Law

Any piece of software reflects the organizational structure that produced it.



Fitts’ Law

The time to acquire a target is a function of the distance to and the size of the target.



Tesler’s Law of Conservation as Complexity

You cannot reduce the complexity of a given task beyond a certain point. Once you’ve reached that point, you can only shift the burden around.



Occam’s Razor

The explanation requiring the fewest assumptions is most likely to be correct.



Hofstadter’s Law

A task always takes longer than you expect, even when you take into account Hofstadter’s Law.



Ninety-ninety Law

The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.



Hartree’s Law

Whatever the state of a project, the time a project-leader will estimate for completion is constant.



Jakob’s Law of the Internet User Experience

Users spend most of their time on other sites. This means that users prefer your site to work the same way as all the other sites they already know.



Fisher’s Fundamental Theorem

The more highly adapted an organism becomes, the less adaptable it is to any new change.



Clarke’s Second Law

The only way of discovering the limits of the possible is to venture a little way past them into the impossible.




Have fun !

Sunday, November 16, 2008

Computer hackers exposed !

Alan Cox là lập trình viên máy tính và là người đóng góp chính vào sự phát triển của nhân Linux từ thuở sơ khai 1991.




John Gilmore là một trong những người sáng lập ra Electronic Frontier Foundation, Cypherpunks và Cygnus Solutions. Ông tạo ra thuyết phân cấp alt.* trong Usenet và là người đóng góp chính của dự án GNU.



Jon “maddog” Hall là Giám đốc điều hành của Linux International, một tổ chức phi quyền lợi lập nên từ những nhà cung cấp máy tính muốn hỗ trợ và đẩy mạnh hệ điều hành Linux.



Grace Murray Hopper là một nhà khoa học máy tính Mỹ và sĩ quan Hải quân Mỹ. Bà là một trong những lập trình viên kì cựu của Harvard Mark I, và phát triển trình biên dịch đầu tiên cho một ngôn ngữ lập trình. Do những thành tích đó mà người ta còn gọi bà là “Amazing Grace”.



David Korn, sáng lập ra Korn Shell, thường mặc áo thun in hình ban nhạc Korn. (Cool)!



Eric Steven Raymond là một lập trình viên, nhà văn và luật sư nổi tiếng trong cộng đồng mã nguồn mở. Ông nổi tiếng với câu nói: “Câu văn luộm thuộm thì tư duy cũng luộm thuộm”.



Richard Matthew Stallman là một nhà phát triển phần mềm kiêm hacker. Năm 1983, ông khởi xướng dự án GNU tạo nên Hệ điều hành Unix. Ông còn là người phát triển trình soạn thảo Emacs gốc, GNU Compiler Collection (GCC), và GNU Debugger.



Bjarne Stroustrup là một nhà khoa học máy tính Đan Mạch. Ông đã thiết kế và phát triển ngôn ngữ lập trình C++ vào năm 1983.



Linus Benedict Torvalds - cha đẻ của chim cánh cụt Linux khi còn là 1 SV trường ĐH Helsinki (Phần Lan).



Larry Wall là lập trình viên, nhà ngôn ngữ học và nhà văn. Ông tạo ra ngôn ngữ nổi tiếng Perl. Các hacker ngày nay cần phải cám ơn ông rất nhiều.



Stephan Gary “Woz” Wozniak - đồng sáng lập Apple cùng Steve Jobs.



Dennis MacAlistair Ritchie và Kenneth Lane Thompson - cha đẻ Unix. Ken Thompson tạo ra ngôn ngữ B còn Dennis Ritchie tạo ra ngôn ngữ C.



Bill Gates và Paul Allen - miễn bình luận!



Loyd Blankenship, biệt danh: The Mentor (người cố vấn) được biết đến như 1 hacker khét tiếng và là nhà văn từ những năm 1980, khi ông còn là thành viên của các tổ chức hacker Extasyy Elite và Legion of Doom.



Riley Eller, biệt danh: Caezar, là thành viên của Ghetto Hackers.



Dan Farmer là 1 chuyên viên an minh máy tính. Sau khi tốt nghiệp ĐH Purdue, ông bắt đầu phát triển chương trình COPS, chương trình này giải thích tại sao Unix bảo mật đến như vậy. Năm 1995, ông và Wietse Venema sáng lập ra SATAN (Security Administrator Tool for Analyzing Networks). Nhìn ông này trông giống tay vocal của Kreator.



Susan Lynn Headley, biệt danh: Thunder, là 1 trong số ít ỏi các nữ hacker, cô là thành viên của Roscoe Gang.



Richard Pryce - khi mới 16 tuổi, cậu sinh viên âm nhạc này đã nổi danh như cồn vì thành tích phá vỡ hệ thống hàng trăm máy tính của Griffiths Air Force Base, NASA và Korean Atomic Research Institute.



Bruce Schneier là một chuyên gia an minh mạng, 1 nhà mật mã học. Ông là tác giả 1 vài cuốn sách viết về bảo mật và mật mã. Ông phát minh ra các thuật toán Blowfish và Twofish.






Kết luận :
Hackers là những người... tóc dài hoặc rậm râu ! (hoặc cả 2)



Con đường thành nerd/geek vẫn còn xa quá !!

Friday, October 17, 2008

Interview Question: FizzBuzz

Đây là 1 câu hỏi phỏng vấn dạng simple programming test (không dùng computer), nhằm loại bớt những người dự tuyển tuyên bố là thông thạo về 1 ngôn ngữ nào đó (nhưng thực tế rất ít viết code).

Theo tôi dạng phỏng vấn này khá hiệu quả, bởi nó cho thấy ứng viên có lập trình bằng ngôn ngữ này trong vòng 3 tháng gần đây, và cũng phần nào phản ánh suy nghĩ, phong cách lập trình của người viết.
Ít ra cũng không thuộc dạng stupid-interview-questions (cái này khi nào có dịp sẽ bàn kỹ hơn) .


Đề bài:
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
(Viết 1 chương trình in các con số từ 1 đến 100. Tuy nhiên ở những con số là bội số của 3 thì in ra "Fizz", bội số của 5 thì in ra "Buzz", bội số của cả 3 và 5 thì in ra "FizzBuzz" thay cho các con số đó.)


Dĩ nhiên là There's More Than One Way To Do It (TMTOWTDI, đọc là "tim-toady") , câu nói yêu thích của các lập trình viên Perl.


Ở đây tôi nêu lên vài cách giải mà theo tôi là ổn (if I were the interviewer) :

* Đơn giản: (KISS, YAGNI)
Code đơn giản không có nghĩa là code ngắn nhất, hay là phải dùng những phần tử cơ bản nhất, mà là dễ dàng đáp ứng ĐỦ yêu cầu (kết quả đúng ngay từ lần đầu chạy), trong khi trình bày ngắn gọn và dễ hiểu.

(Python)

for i in range(1, 100):
if (i % 3 == 0) and (i % 5 == 0):
print “FizzBuzz”
elif i % 3 == 0:
print “Fizz”
elif i % 5 == 0:
print “Buzz”
else:
print i

(Ruby)

1.upto(100) do |number|
if number % 15 == 0 then
puts 'FizzBuzz'
elsif number % 5 == 0 then
puts 'Fizz'
elsif number % 15 == 0 then
puts 'Buzz'
else
puts number
end
end

(Lisp)

(for (i 1 100)
(if
(= 0 (% i 15)) (set 'i "FizzBuzz")
(= 0 (% i 5)) (set 'i "Buzz")
(= 0 (% i 3)) (set 'i "Fizz"))
(println i))


* Dễ dùng lại và mở rộng: (DRY, DRW)
VD nếu như sửa Blah là bội của 4 (thay vì Fizz của 3), hoặc thêm vào FizzBuzzBlah là bội của 60 (3x4x5) , thì liệu code bạn viết lại có đỡ tốn công và vẫn giữ được các ưu điểm (dễ hiểu, chạy nhanh, ...) hay không?

(Ruby)

a = nil, 'fizz', 'buzz', 'fizzbuzz'
1.upto(100) { |a[0]| puts a[(a[0]%3 == 0 ? 1 : 0) + (a[0]%5 == 0 ? 2 : 0)] }

(Ruby - extended)
a = nil, 'Fizz', 'Buzz', 'FizzBuzz', 'Blah', 'FizzBlah', 'BlahBuzz', 'FizzBuzzBlah'
1.upto(100) { |a[0]| puts a[(a[0]%3 == 0 ? 1 : 0) + (a[0]%5 == 0 ? 2 : 0) + (a[0]%4 == 0 ? 4 : 0)] }



* Dễ nhìn, thanh thoát: (Refactoring, DRY)
Thường sau khi viết đạt yêu cầu KISS ta sẽ refactor code để củng cố YAGNI và DRY , cũng để code dễ nhìn và dễ hiểu hơn, mặc dù về performance hoặc line-of-code thì có thể không tối ưu lắm.

(Java - verbose)
public class FizzBuzz {
public static void main(String[] args) {

for(int i = 1; i <= 100; i++) {
if (((i % 3) == 0) && ((i % 5) == 0))
System.out.println("fizzbuzz");
else if ((i % 3) == 0)
System.out.println("fizz");
else if ((i % 5) == 0)
System.out.println("buzz");
else System.out.println(i);
}
//System.out.println();
}
}


(Java - shorter)

public class FizzBuzz {
public static void main(String[] args) {

for(int i = 1; i <= 100; i++) {
System.out.printf("%s\n",
i%15!=0?i%5!=0?i%3!=0 ? i :"Fizz":"Buzz":"FizzBuzz" );
}
}
}



CÒN VÀI KIỂU CODE KHÁC, THAM KHẢO CHO VUI:
(chứ phỏng vấn thiệt mà tìm tòi hướng này chắc là ít nhất cũng cả tiếng cho 1 bài cỡ FizzBuzz)

* Cực ngắn, gõ ít nhất: (one-liner, Perl-Golf)
Bạn phải đam mê lập trình thực sự mới tham gia được loại này. Cái kiểu one-liner này xuất phát từ Perl, do sự linh động, uyển chuyển và mạnh mẽ của Perl trong xử lý text của Perl. Bây giờ các lập trình viên ngôn ngữ hậu duệ của Perl (như Python, Ruby) cũng bắt đầu thích trò brainstorming này :D

(Python)
for i in range(1,101):print”FizzBuzz”[i*i%3*4:8–-i**4%5]or i

(Ruby)
1.upto(?d){|i|puts"FizzBuzz"[4&a=i*i%3*5,9-a-i**4%5]||i}

(Perl)
print$_%3?$_%5?$_:"":Fizz,$_%5?"":Buzz,"\n"for 1..100;



* Phức tạp hóa, làm rối rắm: (complicated, obfuscated)

(Csharp)
using System;

namespace FizzBuzz
{
internal class Program
{
private static void Main()
{
IFormatProvider formatProvider = new FizzBuzzFormatter();

for (int i = 1; i < = 100; i++)
Console.WriteLine(String.Format(formatProvider, “{0:FB}”, i));

Console.ReadLine();
}
}

internal class FizzBuzzFormatter : ICustomFormatter, IFormatProvider
{
public string Format(string format, object arg, IFormatProvider formatProvider)
{
if (format == null)
return String.Format(”{0}”, arg);

if (format.StartsWith(”FB”) && arg is int)
{
int val = (int) arg;
bool mod3 = val%3 == 0;
bool mod5 = val%5 == 0;

if (!mod3 && !mod5)
return arg.ToString();

string s = String.Empty;

if (mod3)
s += "Fizz";

if (mod5)
s += "Buzz";

return s;
}

return String.Format(”{0:” + format + “}”, arg);
}

public object GetFormat(Type formatType)
{
if (formatType == typeof (ICustomFormatter))
return this;
else
return null;
}
}
}


(Csharp - longer)
public abstract class Factory
{
public string ToString(char[] chars)
{
return new string(chars);
}
}

public class FizzFactory : Factory
{
private const char F = 'F';
private const char i = 'i';
private const char z = 'z';

public bool isFizz(int input)
{
if (input == 3) return true;
else if (input == 6) return true;
else if (input == 9) return true;
else if (input == 12) return true;
else if (input == 15) return true;
else if (input == 18) return true;
else if (input == 21) return true;
else if (input == 24) return true;
else if (input == 28) return true;
else if (input == 30) return true;
else if (input == 33) return true;
else if (input == 36) return true;
else if (input == 39) return true;
else if (input == 42) return true;
else if (input == 45) return true;
else if (input == 48) return true;
else if (input == 51) return true;
else if (input == 54) return true;
else if (input == 57) return true;
else if (input == 60) return true;
else if (input == 63) return true;
else if (input == 66) return true;
else if (input == 69) return true;
else if (input == 72) return true;
else if (input == 75) return true;
else if (input == 78) return true;
else if (input == 81) return true;
else if (input == 84) return true;
else if (input == 87) return true;
else if (input == 90) return true;
else if (input == 93) return true;
else if (input == 96) return true;
else if (input == 99) return true;
else return false;
}

public string GetFizz()
{
return base.ToString(new char[4] { F, i, z, z });
}
}

public class BuzzFactory : Factory
{
private const char B = 'B';
private const char u = 'u';
private const char z = 'z';

public bool isBuzz(int input)
{
if (input == 5) return true;
else if (input == 10) return true;
else if (input == 15) return true;
else if (input == 20) return true;
else if (input == 25) return true;
else if (input == 30) return true;
else if (input == 35) return true;
else if (input == 40) return true;
else if (input == 45) return true;
else if (input == 50) return true;
else if (input == 55) return true;
else if (input == 60) return true;
else if (input == 65) return true;
else if (input == 70) return true;
else if (input == 75) return true;
else if (input == 80) return true;
else if (input == 85) return true;
else if (input == 90) return true;
else if (input == 95) return true;
else if (input == 100) return true;
else return false;
}

public string GetBuzz()
{
return base.ToString(new char[4] { B, u, z, z });
}
}

public delegate void FizzBuzzWriter(string input);
public class Looper
{
private FizzFactory Fizz;
private BuzzFactory Buzz;
public event FizzBuzzWriter OnFizzBuzz;

public Looper(Factory fizzFact, Factory buzzFact)
{
Fizz = (FizzFactory) fizzFact;
Buzz = (BuzzFactory) buzzFact;
}

public void execute(int start, int finish)
{
for(int i = start; i<=finish; i++)
{
string val = String.Empty;
if (Fizz.isFizz(i)) val += Fizz.GetFizz();
if (Buzz.isBuzz(i)) val += Buzz.GetBuzz();
if (val == String.Empty) val = i.ToString();

if (OnFizzBuzz != null) OnFizzBuzz(val);
}
}

}

public class TheFizzBuzzProgram
{
public static void main(string[] args)
{
Looper l = new Looper(new FizzFactory(), new BuzzFactory());
l.OnFizzBuzz += new FizzBuzzWriter(l_OnFizzBuzz);
l.execute(1,100);
}

static void l_OnFizzBuzz(string input)
{
Console.Write(input + Environment.NewLine);
}
}



* Hiệu quả, chạy nhanh nhất: (performance, effectiveness)
Chưa test, ai có kết quả test vài trường hợp thì post lên thử nhé ^_^



Search vòng vòng Internet còn thấy thêm khá nhiều implementation với nhiều ngôn ngữ nữa, có thể kể JavaScript, ASP, Pascal, C++, VB, Groovy, Prolog, SmallTalk, Scheme, Haskell, Erlang, COBOL, bash, batch, ... thậm chí cả SQL (yay!), XSL (wow!), hợp ngữ IL (cool!), ASM86 trên Windows lẫn Linux (cooler!) , ASM51 (w00t!), etc ; nhưng nhìn chung mấy đoạn mã ở trên là đủ tiêu biểu rồi :D

Have fun !

Wednesday, October 15, 2008

Self-reproducing programs

Also known as quine :D

My quick try:
(Java)


import java.io.*;

public class PrintMySelf { //Print the very source code
//this simple version replace line comment by blank line

public static void main(String args[]) throws IOException {

//use PushbackInputStream to get/unget each character
FileInputStream fileIS = new FileInputStream("PrintMySelf.java");
PushbackInputStream pushbackIS = new PushbackInputStream(fileIS);

int dataByte = 0;

while ( (dataByte = pushbackIS.read()) != -1 ) {
char dataChar = (char) dataByte;

if (dataChar == '/') { //strip all line comments
dataChar = (char) pushbackIS.read();

if (dataChar == '/') {
dataByte = pushbackIS.read();

while ( (dataByte != -1) && (dataByte != 13) ) {
dataByte = pushbackIS.read();
dataChar = (char) dataByte;
}

} else {
pushbackIS.unread( (int) dataChar );
}
}

System.out.print(dataChar);
}

fileIS.close();
pushbackIS.close();
}
}



Some other solutions:

(Python)

s = 's = %c%s%c%cprint s %% (39, s, 39, 10)'
print s % (39, s, 39, 10)


(C#)

class PrintMyself { static void Main(string[] args) {string x1 = ";char[] x2 = {'c','l','a','s','s',' ','P','r','i','n','t','M','y','s','e','l','f',' ','{','{',' ','s','t','a','t','i','c',' ','v','o','i','d',' ','M','a','i','n','(','s','t','r','i','n','g','[',']',' ','a','r','g','s',')',' ','{','{','s','t','r','i','n','g',' ','x','1',' ','=',' ','{','0','}','{','1','}','{','0','}'};System.Console.Write(string.Format(new string(x2), (char)34, x1) + x1);}}";char[] x2 = {'c','l','a','s','s',' ','P','r','i','n','t','M','y','s','e','l','f',' ','{','{',' ','s','t','a','t','i','c',' ','v','o','i','d',' ','M','a','i','n','(','s','t','r','i','n','g','[',']',' ','a','r','g','s',')',' ','{','{','s','t','r','i','n','g',' ','x','1',' ','=',' ','{','0','}','{','1','}','{','0','}'};System.Console.Write(string.Format(new string(x2), (char)34, x1) + x1);}}


Have fun,

Sunday, October 12, 2008

Ubuntu Linux clothes !

Canonical's Ubuntu (including kUbuntu, Xubuntu, Edubuntu, ... ) has surpassed RedHat's Fedora Core to be the most used Linux distribution since 2006:

http://google.com/trends?q=Fedora%2CDebian%2CUbuntu%2CSUSE%2CGentoo
http://google.com/trends?q=windows xp%2Cwindows vista%2Cubuntu


Based on that reputation, Canonical has lauched a series of T-shirt, hat, etc... with the Ubuntu logo:

Second Edition Hardy Heron Mens T-shirt
Second Edition Hardy Heron Mens T-shirt
£ 13.62
Ladies Hardy Heron T-shirt
Ladies Hardy Heron T-shirt
£ 13.62
Organic Circle of Friends Mens T-shirt (White)
Organic Circle of Friends Mens T-shirt (White)
£ 12.77
Organic Circle of Friends Mens T-shirt (Black)
Organic Circle of Friends Mens T-shirt (Black)
£ 12.77
Ubuntu Fleece Jacket
Ubuntu Fleece Jacket
£ 21.28
Organic Circle of Friends Ladies T-shirt
Organic Circle of Friends Ladies T-shirt
£ 12.77
Ubuntu Circle of Friends Hoody (black)
Ubuntu Circle of Friends Hoody (black)
£ 21.28
Ubuntu Beanie Hat - Black
Ubuntu Beanie Hat - Black
£ 6.81
I Do it with Ubuntu Mens T-shirt
I Do it with Ubuntu Mens T-shirt
£ 10.21
Baseball Cap
Baseball Cap
£ 4.26
Hoody (Chocolate Colour)
Hoody (Chocolate Colour)
£ 16.17
Sweatshirt (Fawn Colour)
Sweatshirt (Fawn Colour)
£ 14.47
Mens T-Shirt (White)
Mens T-Shirt (White)
£ 6.38
Mens T-Shirt (Black)
Mens T-Shirt (Black)
£ 8.51
Ladies T-Shirt (Black)
Ladies T-Shirt (Black)
£ 8.09
Polo Shirt (Fawn colour)
Polo Shirt (Fawn colour)




More to see here:
http://shop.canonical.com/index.php?cPath=14



My favourite ones:



UBN00058 - Ubuntu Ogio Metro Backpack





Price : £ 51.06




UBN00052 - Ubuntu Ogio Messenger Bag





Price: £ 45.96




UBN00080 - Ubuntu Drinking Mug

Enjoy your favourite hot drink with this white earthenware mug. 92mm tall.





Price: £ 4.26


:-)

(Thanks KinqV for hosting images)