Got my room already

After a few months of efforts, I finally got a room near school. It is right across the main campus, about 30 seconds away from the gate. I am very happy with it.

As I have mentioned before, I would share this room with a visiting phD Columbia student from Beijing. Nevertheless, the room is large enough to fit two people, enough space to sleep and work. The basic rent is $720 per month, shared by the two of us. Utility is electricity, and is shared among the four of us, probably between $20 - $30. To round up the total cost, $360 + $40, I am expecting $400 per month per person. This is not bad at all.

I will move in mid-Jan, probably around Jan 10 - 15.

I am looking forward with Hi My Sweetheart ep.10. Oh my god.

Anyway, tomorrow is December 31th, but I am going to stay home. It is too cold to join the crowds at Time Square tomorrow night. Oh well. I am still waiting for Ross to review my grade. I can't believe he gives me B+. My final project deserves an A.

Oh today the NYPD had an investigation near Time Squares because of a suspicious white van. By noon they found the van safe, with only clothes and tables. Man, terrorism is really bad-ass. Ruin people's life.

Si-tu-but seems to be ill today. I hope she gets well soon. <3 I love my hamsters.

Hi My Sweetheart (海派甜心)

Oh my god. I am in love with this drama. I can't stop thinking about the characters and story. It is a really cute drama fantasy. I even image-cut a scene when she cries to her pink tiger doll, and makes it my AIM default.

#

Rainie Yang is really cute, and her acting is mature and good in Sweetheart. For the last few years, I refused to watch her drama for some unknown reasons. Nevertheless, I find her a good actress in Sweetheart.

I remembered her from Meteor Garden. I was surprise to find out that she was a former member of 4-In Love at age of 16.

Rainie is now 25, and is getting older. Yet, I find her now more attractive. She has femininity - I just like how she is now. Pure and lovely.

I know she has makeup on, Mike. But in my opinion I think she still retains at least 60% - 70% of her beauty without any makeup. I am serious.

Hi My Sweetheart is hilarious. I laugh to death for every 5 minutes. They make the love scene funny too. I am looking forward with ep 10 next Sunday.

I dream that I will find a girl like Chen Bao Zhu (寶茱姐). She is not rude, just very independent and assertive.

Fisher-Yates shuffle in python

As I was writing a simple lottery program for TVBoxNow, I was wondering how module random actually worked. I wanted to write my own random module, but it turned out the mathematical philosophies were beyond my calculus knowledge. It was probability and probably also had to deal with linear algebra.

Great people from Stackflow had provided a lot of insights and useful links. There was a brief overview of what Fisher-Yates shuffle on Wikipedia.
Fisher-Yates shuffle

Mersenne Twister

It turns out that Python's random module implements Fisher-Yates shuffle and Mersenne Twister methods. Not exactly the same, of course, there are changes made for better optimizations and greater unbiased result.

1
2
3
4
5
6
7
        # only run this loop from 0 to 19 (20 times)
        for player in range(20):
            num_player = len(lst_shuffle) # get the total numbers of players
            k = random.randrange(num_player)
            random.shuffle(lst_shuffle,random.random)
            print player, lst_shuffle[k], "random:",k
            del lst_shuffle[k]

Additional Reading: The Fisher‐Yates shuffle algorithm

I was wondering why there is an optional random.random() function in the end (I know it's optional). Here was a statement I found from the additional reading:

Pseudo random number generators
Most, if not all programming languages have libraries that include a pseudo-random
number generator. This generator usually returns a random number between 0 and 1 (not
including 1). In a perfect generator all numbers have the same probability of being selected but
in the pseudo generators some numbers have zero probability.

Christmas Eve? Hungry.

Yes. Christmas Eve already. Happy Christmas.

Nevertheless, what I really want to do is work. Well, actually, I want to eat first, but my refrigerator is empty.

So I have been looking for a room near City College for two months already. I have visited one, which is only two blocks from City and with utilities I am expecting $550 a month. The landlord is a nice lady, but I really want to minimize my expense.

After spending more than a thousand dollar on Wendy last year, I am really broke. I did have a summer job and it was quite good bonus. Two months ago I decided to save all my money into my bank account, and I have $2200 left.

A Columbia PhD student spoke to me if I would share a room with him, between $600 - $700 a month. The deal is that if we divide it half, each of us will only pay $300 - $400. Although I always hate sharing a bedroom with another person, I guess I just have to learn it since MIT and Cornell only provide shared dormitories.

After speaking to an admission staff at Cornell, since I have course conflict this year, I would have to apply as a junior standing. For MIT, it's worth a try this year, just to get the experience. To get admitted to MIT, one must demonstrate its unique potential contribution to MIT community, and I already have a concrete idea about what I need to do. It's worth that $70 this year and next year again.

Double standard!? phpBB4

I am very disappointed with phpBB team. Their team members are so double standard. While their own people proposing feature implementations, and have no problem with those, they would warn users not to jump ahead the schedule.

While there is no specific restriction or vision what they want since the beginning, they police my thoughts and ideas. I am totally sick of their tones and attitude. I was the first one asked people not to draw any tangent, and later they came back to lecture me.

What a shame to these experience software engineers. I am only a freshman in college, and I find myself a better engineer than they are. They tell users their expectations implicitly. They want to discuss archeiture, then please have the developers start the discussion first. Users' engineering experiences do not matter at all. It is about correcting the attitude.

They make users uncomfortable to give in. Users are penalize when their comments offend the developers even if they are facts. They police users' thoughts and ideas. I agree that we need to monitor every reply and to keep our discussions relevant to the subject, however, phpBB team does not let users know their expectations.
(more...)

phpBB4 vs cloud?

It is still at its brainstorming stage, but I do expect a lot from phpBB4 and so I decided to spend time with it. Here is the link to the discussion board
http://area51.phpbb.com/phpBB/viewforum.php?f=75

I think most softwares today are in concrete form and I am a fan of abstraction. I like to make software cloud-based. The Internet is a cloud, a globally interconnected network. I can literally predict that this is the only way software will be written in the future.

Look at Google Wave, an amazing application which embeds all the top Internet features into one: E-mail, IM, game, community, wiki and ect. The only obstacle is hardware. Most American users are probably still using DSL, or those cheap Cable services. They are not fast enough to support cloud computing like Chrome OS and definitely not ready for Google Wave either.

My suggestion is to make phpBB4 an extension or an application based on Google Wave. Use the existing resources to enrich phpBB4. However, I think the developers hate this idea and they definitely do not want to re-invent forum's paradigm.

I can hardly accept their bigot minds and I cannot see the future of any forum software at the moment. I told them forum is an obsolete and they probably thought I was referring to social network. No, not exactly. In fact, social network was not a new thing at all. We had a fixed definition of forum - this killed forum.

In my mind, we need to make every user an object, a cloud. This is the new definition of a forum - everything is a cloud. This is very abstract and indeed I like to make things abstract so that I can get the best innovations out of the box.
(more...)

My python final [simple database analysis]

My python final project was to write a simple database analysis based on any given data. I thought about it and I decided to have the entire class use the same sets of data. I created a Google form and let them fill them out. I sent out the result in csv and a few other formats, which really made the whole programming easier.

Python has a very nice module called csv. It is already included in 2.6.4 so there is no need to find it. All we need to do is to import it. After a few days fighting with this program, I finally had finished my project.

Here each student is an object. This program is not very complicated. It is very portable. We can control each column at any instance. It is not the best, but good enough to earn an A.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import csv
class Student(object):
    sports = []
    ftopics = []
    stopics = []
    genders = []
    movieyrs = []
    countrys = []
    def __init__(self,row):
        # we set up the row from the csv data
       self.lname, self.fname, self.ID, self.gender, self.sport, self.movie, self.movieyr, self.country, self.ftopic, self.stopic = row
        # we import each column into our pre-defined lists
       self.sports.append(self.sport)
       self.ftopics.append(self.ftopic)
       self.stopics.append(self.stopic)
       self.genders.append(self.gender)
       self.movieyrs.append(self.movieyr)
       self.countrys.append(self.country)
        # functions to print results anytime we want
    def print_information(self):
       return (self.lname, self.fname, self.ID, self.gender)
    def print_first(self):
       return (self.lname, self.fname, self.sport)
    def print_second(self):
        return (self.lname, self.fname, self.movie, self.movieyr)
    def print_third(self):
        return (self.lname, self.fname, self.country)
    def print_fourth(self):
        return (self.lname, self.fname, self.ftopic, self.stopic)

#########################   THIS IS OUR WELCOME MENU    #########################
#
#               Welcome to CSC 1000 (Fall 2009) - Final Project
#
#
#                           Author: John Yeukhon Wong
#                           E-mail: gokoproject@gmail.com
#
#       Select one of the following to retrieve speific database analysis
#
#           [0]: Basic Information (Last name, first name, ID, gender)
#           [1]: My Favorite Sport (Last name, first name, favorite sport)
#           [2]: My Favorite Movie (Last name, first name, movie title, movie year)
#           [3]: My Favorite Country to Visit (Last name, first name, country name)
#           [4]: My Favorite class topic (Last name, first name, first preference, second preference)
#
#
#           Each item has its own speific analysis result
#           A while = True loop to re-request a new analysis
#           Enter QUIT to leave this program
#
#########################   THIS IS OUR WELCOME MENU    #########################  


# let us initalize some stuff we will use throughout
# we use csv.reader module here to read csv data
choice_list = []
choice_dict = {}

# assuming our csv data in the same path as the python directory
reader = csv.reader(open('new_mondy_csc_data_revise.csv'), delimiter=',', quotechar='"')
header = tuple(reader.next()) # make sure our reading in tuple form

students = list(map(Student, reader)) # read all remaining lines
num_students = len(students) # get the total numbers of students in this survey

def search_function(x):
    if x == 0:
        print "%-17s|%-10s|%-6s|%s" %header[:4] # running header from column 0 to 3
        print "-" * 45
        for student in students:
            print "%-17s|%-10s|%-6s|%3s" % student.print_information()
        print '\n'
    # gender
        for s in set(Student.genders): # class attribute
            print s,":", Student.genders.count(s),"student(s)", "or",round(((float(Student.genders.count(s)) / num_students) *100),1),"%"

    if x == 1: # Basic information
        print '\n' * 2
        print "Students' Sport Preference"
        print '\n'
        print "%-17s|%-10s|%s" %(header[0],header[1],header[4])
        print "-" * 45
        for student in students:
            print "%-17s|%-10s|%s" %student.print_first()
        print '\n'
        # Printing all sports that are specified by students
        for s in set(Student.sports): # class attribute
            print s,":", Student.sports.count(s),"student(s)", "or", round(((float(Student.sports.count(s)) / num_students) *100),1),"%"

        # Printing sports that are not picked
        allsports = ['Basketball','Football','Other','Baseball','Handball','Soccer','Volleyball','I do not like sport']
        for s in set(allsports) - set(Student.sports):
            print s,":", "---", '0%'
        print '\n'
        # Here we list sports most favorite and least favorite
        choice_list = Student.sports
        for choice in choice_list:
            choice_dict[choice] = choice_dict.get(choice, 0) + 1
        print "The MOST favoritable sport is: ", max(choice_dict)
        print "The LEAST favoritable sport is: ", min(choice_dict)
       
    elif x == 2: # My favorite movie
        print "%-17s|%-10s|%-16s|%s" %(header[0],header[1],header[5],header[6])
        print "-" * 45
       
        for student in students:
            print "%-17s|%-10s|%-16s|%s" % student.print_second()
        print '\n'
        # number of old / new movie
        newyear = ['2001','2002','2003','2004','2005','2006','2007','2008','2009']
        counter = 0
        freq = {}
        for i in Student.movieyrs:
            if i not in newyear:
                freq[i] = freq.get(i, 0) + 1
                counter = counter + 1
        print "Numbers of students' favorite movies are OLDER than 2001: ", counter
        print "Numbers of students' favorite movies are NEWER than 2001: ", (num_students - counter)
        print '\n'
    elif x == 3: # My favorite country to visit
        print "%-17s|%-10s|%s" %(header[0],header[1],header[7])
        print "-" * 45
        for student in students:
            print "%-17s|%-10s|%s" %student.print_third()
        print '\n'
        for s in set(Student.countrys):
           print s,":", Student.countrys.count(s),"student(s)", "or", round(((float(Student.countrys.count(s)) / num_students) *100),1),"%"

        choice_list = Student.countrys
        choice_dict = {}
        for choice in set(Student.countrys):
            choice_dict[choice] = choice_dict.get(choice, 0) + 1
        print "The TOP country wanted to visit is: ", max(choice_dict)
       
    elif x == 4: # First and Second class topic preference
        print "%-17s|%-10s|%-15s|%s" %(header[0],header[1],header[8],header[9])
        print "-" * 45
        for student in students:
            print "%-17s|%-10s|%-16s|%s" % student.print_fourth()
        print '\n'
       
        # first topic preference
        print "My first most preferred class topic"
        print "-"*20
        for s in set(Student.ftopics): # class attribute
            print s,":", Student.ftopics.count(s),"student(s)", "or", round(((float(Student.ftopics.count(s)) / num_students) *100),1),"%"

        alltopics = ['Matrices','Probability','Object Oriented Programming','Matlab','Python']
        for s in set(alltopics) - set(Student.ftopics):
            print s, 0, '0%'
           
        choice_list = Student.ftopics
        choice_dict = {}
        for choice in choice_list:
            choice_dict[choice] = choice_dict.get(choice, 0) + 1
        print "The TOP class topic is: ", max(choice_dict)
        print "The LEAST wanted class topic as first preference: ", min(choice_dict)
        print '\n'
       
        print "My second most preferred class topic"
        print "-"*20
        # second topic preference
        for s in set(Student.stopics): # class attribute
            print s,":", Student.stopics.count(s),"student(s)", "or", round(((float(Student.stopics.count(s)) / num_students) *100),1),"%"
        for s in set(alltopics) - set(Student.stopics):
            print s, "---", '0%'
           
        choice_list = Student.stopics
        choice_dict = {}
        for choice in choice_list:
            choice_dict[choice] = choice_dict.get(choice, 0) + 1
        print "Second most TOP class topic is: ", max(choice_dict)
        print "The LEAST wanted class topic of all: ", min(choice_dict)

# Let us bring our menu interface, or instruction to the front

print """
#########################   THIS IS OUR WELCOME MENU    #########################
#
#               Welcome to CSC 1000 (Fall 2009) - Final Project
#
#
#                           Author: John Yeukhon Wong
#                           E-mail: gokoproject@gmail.com
#
#       Select one of the following to retrieve speific database analysis
#
#           [0]: Basic Information (Last name, first name, ID, gender)
#           [1]: My Favorite Sport (Last name, first name, favorite sport)
#           [2]: My Favorite Movie (Last name, first name, movie title, movie year)
#           [3]: My Favorite Country to Visit (Last name, first name, country name)
#           [4]: My Favorite class topic (Last name, first name, first preference, second preference)
#
#
#           Each item has its own speific analysis result
#           A while = True loop to re-request a new analysis
#           Enter QUIT to leave this program
#
#########################   THIS IS OUR WELCOME MENU    #########################
"""

while True:
    x = raw_input("Enter a number to print specific table, or enter QUIT to leave: ")
    print '\n'
    if x == 'QUIT':
        print "Thank you for using our service!"
        break
    search_function(int(x))
    print '\n'

(more...)