By future

online interview questions (III)

by future posted at 09-21-2008 12:07PM - Comments (0)
1. Difference between heap and stack?
2. The difference between structs and classes in c++?
3. What is virtual function? 
4. How does virtual function implemented?
Vtable:
5. What’s abstract class?
6. What is pure virtual function?
7. What’s the difference between virtual function and pure virtual 
function?
8. What’s the difference between thread and process?
9. What’s the difference between mutex and semaphore?
10. What is the difference between new and operator new?
11. What is the difference between assignment and initialization?
12. What is polymorphism? How does it implemented?
13. What is encapsulation?
14. Copy constructor
15. Difference between copy constructor and assignment.
16. What’s the difference between pointer and reference?
17. What is friend function?
18. What’s the binary search tree?
19. What’s the stack?
20. What’s LIFO (Last In First Out)?
21. Given a stack, and 5 variables, reqire you put the 5 variables into 
the stack. How would you test it before putting them in?
22. How would you test your own program?
23. Tell me the first three of your most familiar technical skills.
24. What’s the persentage of back-in, middle tier, and front-in 
development?
25. What do you think a good code is?
26. How do you keep you with the latest technologies?
27. distance vector routing protocol
28. c and c++ difference
29. explain constructor and destructor
30. what is copy constructor? When it is called?
31. overloading and overriding difference
32. what is recurcive function? Implement one recurcive funcition.
33. declare a pointer point to an interger;
point to 20 intergers;
point to 20 pointers which point to interger
34. What’s virtual destructor?
35. how is the source file compiled to executable(from source file -> 
binary file)?
36. After the source file is compiled to binary file, how is the binary 
file orgnized and stored?
37. What is overloading? How does the computer know which function is 
according to which implementation since they have the same name?
38. Memory leakage: 
How you ever met memory leakage program, is it cause severe problem?
How did you find the leakage?
Have you ever used any software to detect the memory leakage?
39. c++ file in Linux: which compiler do you use?
40. Given a file, tell me the steps of reading the file.
41. What is “IS” and “Has” in C++? What’s the difference?
42. the disadvantage of using stored procedures with parameters.
43. when inserting a record into a table, how can you let the relatived 
tables change accordingly?

Getting the Argument Names of Your Function

by future, airportyh posted at 05-20-2008 11:50PM - Comments (0)   javascript programming python ruby
In Javascript:
myfunction.toString()
This gives you the entire definition of the function as a string, with which you can parse to get the argument names, or in prototype.js you can just do:
myfunction.argumentNames()

In Python:
myfunction.func_code.co_varnames

In Ruby, there is no easy way to do this, although there is A way, which involves setting a trace function on the function and then executing it to get at the local variables at execution time, see here.




Constructor Chaining in Prototype

by airportyh, future posted at 05-20-2008 09:32PM - Comments (0)   javascript programming prototype
Ever wonder how to do constructor chaining in prototype.js?
Here's how:

var Person = Class.create({
  initialize: function(){
    console.log('hello world!');
  }
});
var Pirate = Class.create(Person,{
  initialize: function($super){
    console.log('before super');
    $super();
    console.log('after super');
  }
});
new Person();
new Pirate();

The $super parameter is "special", and is detected by the library. It gives you a reference to the method of the same name defined in the super class(Ruby style, basically). Notice that unlike Java, you can do stuff before super's constructor is called. For more, see here.

Data mining and KDD

by future posted at 03-15-2008 10:29PM - Comments (0)   tech
For the longest time I have known about data mining, I thought it's the same as KDD (knowledge discovery in database). Until today, I read some papers, did I find out they're actually two different things. "KDD refers to the overall process of discovering useful knowledge from data, and data mining refers to a particular step in this process".
Data mining is the application of specific algorithms for extracting patterns from data. KDD has evolved, and continues to evolve, from the intersection of research fields such as machine learning, pattern recognition, databases, statistics, AI, knowledge acquisition for expert systems, data visualization, and high-performance computing. The unifying goal is extracting high-level knowledge from low-level data in the context of large data sets.

The data-mining component of KDD currently relies heavily on known techniquesfrom machine learning, pattern recognition, and statistics to find patterns from data in the data-mining step of the KDD process. A natural question is, How is KDD different from pattern recognition or machine learning (and related fields)? The answer is that these fields provide some of the data-mining methods that are used in the data-mining step of the KDD process.
The KDD process can be viewed as a multidisciplinary activity that encompasses techniques beyond the scope of any one particular discipline such as machine learning.

Hello Haskell

by airportyh, future posted at 01-21-2008 04:05PM - Comments (0)   haskell programming
For the past four days I've been learning Haskell. As my first real program, I wrote a file backup utility - essentially a command line wrapper to rsync. The program was probably around 200 lines, just large enough for me to get comfortable with the language. There are many things I like about the language, and some that I don't, let's get started.

Safety of the Type System
After working mainly with ruby for a while it's refreshing to go back to a statically typed language. But Haskell's type system is way better than that in Java. Now, I've used OCaml before, but that was a long time ago and I had a lot of trouble with it, so I must say I didn't "get it" at that time. This is the first time I've really gotten comfortable with this kind of type system, and I love it. When you have a type system like this, you have less need for writting tests, because the compiler catches a large class of errors for you. Like in Ruby, I write tests almost religiously sometimes because I want the luxury of the safety provided by the test suite: so that I can safely refactor my code later. Well, in haskell it's like you have that safety without having to write those tests. Granted, there are still cases when you should test for logic, but you will never have your code fail due to nil-when-you-didn't-expect-it or no-such-method(with Java it's NullPointerExceptions and ClassCastExceptions). In my short experience, it's mostly true that once you get the program to compile, "It's just works!"

Type Inferencing
This works great in practice, not just in theory. All the discussions of static vs dynamic usually ignore type systems with type inference, and so are more of comparisons between old type systems and dynamic languages, and the dynamic advocates usually point out that it's easier for them to make refactorings involving changing the type of a variable. It's easier to show with an example. Let's say you have a piece of information that you need to pass to many different places in your code. At the beginning you use just a string to store it:
String filepath;
processFile(String filepath) ...
copyFile(String filepath, String filepath) ...
updateFile(String filepath) ...
processFiles(String[] filepaths) ...

Now let's say at a later time you find that a string is not enough, you need some more information to go along with each file path. you need:
FilePath filepath;
Now you are screwed. Even Eclipse can't help you with this type of refactoring. You need to make probably hundreds of changes all through out your code base, including: 1) every method/constructor declaration  that references filepath; 2) every instance variable that holds a filepath; 3) every local variable that holds a filepath; 4) all the places where you create a filepath; and 5) all the places where you need to actually perform operations with filepaths. In dynamic languages, you would only have to make changes for items 4 and 5, because type information is not explicitly declared at function and variable definitions. But, this is true also for type inferencing languages like haskell. Therefore, if you are using one of these languages, the refactoring argument for dynamically typed languages is a moo point. Haskell is like the best of both worlds. What's more, the compiler guides you through the refactorings, whereas with dynamic languages, you need to rely on testing to make sure your refactoring didn't break any thing.

The Infamous IO Monad
To do any kind of IO in Haskell, you have to first grok the IO Monad. This is a scary proposition, but once you get it, you will be fine, and you'll be better for it. The way I look at it, there are 2 programming styles in Haskell: the functional style and the imperative style. The imperative style is required for any kind of IO operations, because IO operations are tainted, 'cause IO is a side effect, and functions shouldn't have side effects in the pure functional sense. To program in Haskell, you will need to be fluent in both programming styles. Now, the imperative style can be use for more than just programming IO, it's used for all monads. What's a monad, you ask? Oh brother, you'll have to ask me another day.

Runtime Errors
Now, even though with all it's safety, you can still have runtime exceptions in Haskell. But exceptions can't happen in functional code, only imperative code. So, an example would be file-not-found. Unlike the interpreted languages though, you don't get a stacktrace when you have an exception, so this is actually a minus for Haskell.

Weak Regex Support
I found the regex support a lot weaker than say perl/ruby/javascript, in fact even than python and Java. There's no syntax support for it, and the regex library in the standard distro is a bit hard to use. I was told that regex is not in the spirit of Haskell. Haskell hackers are more hip to something called Parsec. Fair enough, but I think having good regex support will help Haskell's popularity.

Third Party Libraries
In Haskell, the package system is Cabal. It's closer to Python's Eggs, I would say, but slightly lower level. Because Haskell is a compiled language at heart(although there is a bytecode mode), there are more C-isms in Cabal. Many third party libraries require compiling C code, and I've had problems with many of these on cygwin.

Interactive Shell
Give me my interactive shell or give me death! Thank god there's an interactive shell for Haskell. Again, best of both worlds. Although, the shell is limited - not like in ruby or python where you can pretty much type in any thing, in Haskell, you don't really have access to the full power of Haskell at the prompt. But still, it's a very very useful tool during rapid prototyping.

Haskell Deserves a Great IDE
It's my opinion that a compiled language nowadays really need an IDE to be pleasant to work with. If for nothing else than the ease of getting error markers inside your code editor; clicking an error to jump to its line number; and having it auto-compile when you save a file. I used the haskell plugin for Eclipse briefly, but it stopped working after the first session - some Java runtime exception =( There's no reason that Haskell can't have all the features of the cool Java IDEs out there and more, other than manpower.

Namespace Polution
Haskell is not an OO system. And as such it's more vulnerable to namespace polution, because objects act like little namespaces. This shows up in some of the standard library code for example: hGetContents, hGetLine are actions that read from a file handle. Those are not pretty names. I guess h stands for handle. In an OO system, this could have been h.GetContents. The problem of namespace collison is handled at compile time. If you imported 2 modules that both have a function called map, for example, you'd have to prefix "map" with the name of the module, like Data.List.map. But needless to say, that is not nice. You could alleviate this somewhat by passing functions around as values(ah, caught myself before I said variables).

Overall, I really dig Haskell and I plan to use it for more of my work as well as play, and I am sure I will have more to say about it as I learn more. Like, I haven't even dug into testing in Haskell, and QuickTest looks really cool.

When You Think You Are All That

by future, airportyh posted at 12-22-2007 10:28PM - Comments (0)   programming
You learn the ropes. You start with the basics. You learn to walk the walk before you talk the talk. But you learn fast, and you learn often, and very soon you learn to do interesting things. You get beyond the basics. You learn the tools of the trade. But beyond that, slowly, you learn to talk to talk, and not just walk the walk. You learn the frame of reference, the state of mind, the philosophy - if you will - of your beautiful craft(not art) - that's right, your beautiful craft(not art). It is so called yours, because of all the time you put into it. It is yours because all the thought you put into it. It is yours because you enjoy it, but even more so, because you live and breath it. At this point, you are an expert. You are an elite among your peers. You are no longer a fish in a pond. You are somebody. You grow satisfied with yourself. And you begin to think: that your are all that.

It is at this point, that you stop learning. You stop learning because you don't need to anymore. You think you've seen it all. When new things come along, you dismiss them. Because you know it all, you can do it all, and you've been doing it right all along, and so why would you need something else that you haven't heard before? The problem is, as time progresses, other practitioners developed new techniques, new frames of reference, new states of mind, new philosophies, what may seem alien - at first glance - to your own - the one that you had known. Now they all embrace new techniques you ignored, ever since the day when you thought you knew it all. You see that your expert status could be weakened, so you belittle the new, and promote the old. You attack with logic, you attack with examples, you attack with stories that you heard - second hand from your sources. The problem is that since you decided to stop learning, you don't know the new techniques, you refused to learn them. You can speak ill of them but it won't convince the others, because you - although the expert that you are - do not have the benefit of knowing both sides of the story - you know only one.

dad email

by future posted at 11-22-2007 03:15PM - Comments (0)

是啊,最近忙得不得了。本来toby可以请两个星期的假,不过
公司有所变动,所以他提前回去上班了。小宝一切都好,就是
太活跃。这几天长大一些了,也开始变坏了。每天几乎都要大
闹一场。吃完了不睡,张着嘴哇哇哇的哭。大家轮流抱着也没
啥用。宝宝的医生一看她就说这是个以后满房子乱跑的小孩。
平时好动得不得了,连吃奶也是手脚挥舞个不停。喂她的时候
得要不停的回避

Fritz Zimmer Riesling Kabinett

by airportyh, future posted at 11-03-2007 11:29PM - Comments (1)   wine
Going to branch out a bit in my quest to find a white wine that I like, and try the German Reislings, because Gary told me to =) This one is an 06. I got a lot more nose after I switched to a smaller glass, the one for tasting white wines. This Reisling is sweet, and sour. So much so that it tastes almost like some kind of lemon extract/syrupy kinda thing. The buttery oak flavor that I don't like is still there, but toned down. The flavor is very tropical and fruity. Not too different than the last German Reisling I tasted, so I am actually a bit disappointed. The score I'll give it is 87.

Wario's Smooth Moves

by future posted at 11-03-2007 10:41PM - Comments (0)   review wii
This WII game is highly recommended. It really shows you all the different possiblities of using the wiimote. Other than wii sports this is the best game I've encountered yet.

programming projects

by airportyh, future posted at 09-19-2007 04:53PM - Comments (0)
I program not only for my job but also as a hobby. I blog about programming here. Here are some of my projects.

Things that are out there(sort of)
  1. justtodolist - yet another web based todo list
  2. twitterme - a twitter notify for windows using snarl
  3. jsMockB - a fork of jsMock that adds the ability to stub out individual methods on an object and has a BDD style
  4. This wiki/blog - you are looking at it.
  5. osspinions.org - a place for user ratings and reviews for Open Source Projects
  6. JYaml - bringing YAML to the Java community
  7. MapIt - a firefox plugin to search google maps easily
  8. Autofresh - automatically refresh your test browsers the moment you hit 'Save'
  9. swing4rb - program Swing using a declarative syntax in ruby
Coming soon
  1. A web interface for your iTunes Library
Things not designed for public consumption
  1. Our personal financial budget app written in rails - closed source =)
  2. Our personal automatic backup solution written in Java Haskell - also closed source
  3. GA400 Traffic Widget - konfabulator widget written specifically for me!
  4. TextSync - a tool to sync text commentary with music.

Toby

by airportyh, future posted at 09-19-2007 04:46PM - Comments (0)

My name is Toby Ho. I am a software developer programmer of sorts. I am happily married with one child and live in Atlanta. On this site I blog about programming, gadgets, tech, music, wine, and whatever happens to be on my mind. I subscribe to these podcasts. I have my own podcast The Music Chair. Checkout my last.fm profile, I have great taste =) Have a look at my del.icio.us page and my google shared news feed. Look for me on Facebook and twitter(airportyh).
Take a look at my programming projects.

Dad's Famous Dish

by airportyh, future posted at 08-30-2007 04:46PM - Comments (0)   family food
Dad gave us the recipe for his famous dish, we decided to try making it ourselves. This was the result:


这道菜是把苦瓜和南瓜一同用蒜蓉和豆豉来炆。南瓜和苦瓜一甜一苦,于是被命名为甘苦与共。旁边的小蝶里是用辣酱,番茄酱和醋配的调料。吃的时候沾沾调的酱,味道出奇的好。
The dish contains 5 flavours: sweet, salty, bitter, sour, and spicy which is analogue to how there are so many different flavours to life.