Saturday, August 17, 2013

Java: File and Buffered Reader/Writer

Well, this is kind of logical situation, but I thought it should not matter since all of them would be closed anyway. Here's the story:

So my task was to build a Java application which would accept commands and ultimately you want to record everything that you have done in a text file (you could also open the file to continue the work). Without hesitation, I looked at an old code that has text file reading function (written by my Prof. of course as a template to do tutorial), thus I decided to use FileReader and BufferedReader instead of other methods available around. Logically, I looked up into FileWriter and BufferedWriter, and both of them do exist.

Here comes my stupidity: I close the FileWriter before the BufferedWriter. I thought it was fine, since that was what happened in some old template code given to me (for reader and not writer). The problem was, in those codes, the reader was only called once for every program execution. In my case, I repeatedly call FileWriter and BufferedWriter for every operation that changes the text file as a risk mitigation in case my program crashes due to invalid and error-causing input or the computer crashes. And that, somehow somewhat, makes closing BufferedWriter before FileWriter important! Otherwise, I would get run time error and my text file would just be reset into empty forever and ever.

So folks, remember to close what's opened last before closing what's opened first (like chestception where you would need to close the innermost chest first before closing the outermost one).

Thursday, August 8, 2013

NUS ModCrasher: Behind the Scene #1 - GQL Restriction



While we were doing the search system, we ran into a trouble: GQL query restriction. It only allows one inequality to be in the query, while we need two to find lectures between the start time and the end time. So, how should I approach this, since I was the one in-charge of the search system?

Initially, I thought of appending the search result one by one, meaning since lectures start time is on half-hourly period, I could just make a loop between start time and end time, essentially no inequality in the query at all. But then, I did not know how to append the queries, and time was not on our side. I decided to find something else.

I was thinking that Jinja2 template that we are using supports python one way or another. Could I utilize that? Probably! So I tried it; our GQL query run with one inequality and our Jinja2 template would do the other by using "for if" statement. It works! I am not sure about the performance of such solution, but it works for the time being and we are keeping it for now.

Tuesday, August 6, 2013

Svbtle Kudo button Copy

I have been fascinated by Svbtle Kudo button since I first saw it. Thus, my intuition was to try make one. Actually, the button has been done for some time. (I was on holiday and on holiday mood)

To try it out, go to:

I hacked most parts of the button, such as the size and positioning so that it looks perfect. I am not sure the reason behind some bugs if I didn't hack it, such as 1 px lines between the outer ring and the inner circle even when I have normalized the web page and clear all margin and padding of the two.

There are differences between the Svbtle real button and mine, though:
  1. Svbtle button has the inner circle even before the mouse cursor hovers in it while mine has none. I could do the same but I prefer no inner circle on initial state.
  2. Svbtle button has constant speed while my button has constant time. This means that for Svbtle button, if you move your cursor away from the button then put it in again before it returns to initial state, the time taken to make it finish is lesser than if it was from initial state to final state. For my button, it takes the same amount of time to go from any state to final state, thus slower animation if you move the cursor halfway then continue on.
  3. I didn't do the decoration, such as the "don't move" command and successful notice.

Note: It seems there is a lag for the Javascript online. It works fine locally.

Saturday, July 27, 2013

GitHub Repo Slimming Down

As I scrapped some projects that I had in mind, I ensure my Github repo is maintained. I deleted my Android Live Wallpaper repo since I am not continuing that, and also deleted Scipane (Scissor Paper Stone) HTML game as my knowledge now is not enough to make such and when I have the knowledge probably I forget about it already. My Chrome Social Extension is still there because I believe it could work, though I put it away for now in my mind.

I am very out of focus for side project. I will do what I can.

Wednesday, July 3, 2013

Scrapping Projects

I am going to scrap most of my Android projects. It just seems that my interest is really on graphic, design and game. Anyway, my NUS Orbital app is online. Visit NUS ModCrasher to know more about it! (Built by me and Yos Riady)

Thursday, June 13, 2013

Messed up situation

I know I have been posting several posts on different projects, but I am kind of having difficulty to focus especially that I am stuck in all my projects. Currently, my main project is still my NUS Orbital project on a lecture crasher for NUS students. Whenever I am stuck and dunno what to do, I tried to work on other ideas instead of wasting time on the Internet as an escape. That's why I have different ongoing ideas (when I am stuck on one, I work on another which stuck again thus another one and so on so forth). Still, sometimes I am trapped on other stuff. Hopefully all my ideas come to fruition.

Social Network Blocker Chrome Extension #0

Github repohttps://github.com/HansNewbie/Social-Chrome-Extension

This idea actually came up a while ago for a school project (that is still ongoing). The idea was to make a counter for how long have you spend on social network. Now I am making it into a personal project. Since I am still new to JavaScript and I would like to avoid making the time counter, I am making instead a blocker which would close the Chrome Tab if it is read as a registered social network (now I am trying to make it work for Facebook first). I am facing difficulties due to the unknown territory I am in (new in JavaScript and using chrome API).

Thursday, May 30, 2013

Dropdown Menu #2

Project Page: http://hansnewbie.github.io/DropdownMenu/

I found out that the problem with the gap is the Github CSS. I tried to override everything, but it seems that there is a problem with the user agent stylesheet from Chrome (webkit), which I checked on StackOverflow and tried everything with no yield. The clean code would works perfectly though. If you could help me on the matter, could you contact me (probably through comment on this post)?

Thanks!