Skip to main content

Posts

Showing posts from March, 2010

This is pretty cool

This is pretty awesome. Try it now: "TrÆ°Æ¡ng Thúy Ngân" , "Truong Thuy Ngan" and TrÆ°Æ¡ng Thúy Ngân . The links will be opened via anonymouse.org to prevent customized search results from Google. You may want to use Google Vietnam version: "TrÆ°Æ¡ng Thúy Ngân" , "Truong Thuy Ngan" and TrÆ°Æ¡ng Thúy Ngân . You invaded my life, didn't you?

UML Diagram - Very first steps

Well, this is our second assignment of Java: writing an application which allows user to create a UML diagram and generate the code (with empty methods, of course) in Java. Actually the assignment suggested another reversed approach: reading Java source code files and generate the UML diagram but our team decided to choose it. After some discussion, yesterday, mr Tran Viet Son has done the data structure for the application which is pretty interesting and I'm showing you now. The source code can be grab here . All the core classes are under a package called com.tranvietson.uml. The test code is something like this

vBulletin users list in AdminCP Options

I intended to write about this for a while but I haven't had time. This is pretty cool stuff. When ever you want to have a users list for your plugin? Let's say you want to give some members a special permission to use the plugin. What's the best way to do that? Well, adding a field into `users` table is not really good. Setting up a new bitfield permission is interesting but if some other coder use the same bitfield value, disaster! Hmm, the most secure thing will be a separate table to store authorized userid, really good but slow and costly (and stupid somehow), nobody implements a new table just to store those userids! Many coders will use vBulletin Core Options system, create a free type input box, ask the Administrator to input userids, seperated by comma, etc... That's a good approach I think since it's quick and easy, most Administrators have enough knowledge to get the correct userids. But well, if we can make it better, why not? That's why I came up wi

Expression Handling (2nd approach)

After the first implementation, I have made a few more improvements and now, after submitting my assignment I think it's safe to post the final version of the classes here. Source code is available here  (MediaFire). You may want to read the documentation here (Google Docs, in Vietnamese). The script is now accept natural expression input from console. The most interesting feature is each variable can also be enter as an expression (and it will ask for it's variables also). What does this mean? For example, you input an expression: 5+x+y*z. Obviously, it will be calculated at 5 + x + ( y * z) But because you used 3 variables, it will ask your for x, y, z. I will assign x with value of 20, y with 10. Now is the fun stuff: I input "a-b" for z. Uhhhh. What do you think the script will do now? Ah ha, it will ask for z.a (which means the 'a' variable of 'z' expression), 100 to go And then z.b: 1000 to go The result is -17985 (I'm not really sure

Expression Handling

I intended to post the whole Java source code but unfortunately, there are 8 files in total so I think it will be better if you get them from MediaFire . Don't worry, there are only ~500 lines of code and I wrote comment for every single method. Actually, the main class (Expression) design isn't done by me 100% because I have to follow the assignment requirement (also in the uploaded file). I don't really understand why we have to have 2 constructors and then another append() method. Really, I can't get it. Tell me if you have an idea. Anyway, using the Expression class is very simple. Here is how I tested it: Please note that it will run but an Exception will be thrown about variable b hasn't been initialized yet. You can either remove b from the append() method or use setValue() method to assign an value for the variable. Also note that: currently the class support adding, subtracting, multiplying and dividing. Functions can be supported easily by wri

Dining Philosophers

Heck, this is my assignment at college. Took me 1 hour looking around to figure out how to use wait() and notify() methods of Java Object. It's kinda cool. Let's rock and roll. Full source code is available here .