End of Polycademy

Posted: May 3, 2013 in Uncategorized

OK, so i didn’t manage to keep up with my blog posting after all. The last few weeks was extremely hectic, what with everyone scrambling to complete their web app! The last 3 days of the course, in fact, before the demo day on 19 April, were seriously full blown crazy. We experienced the true life of programmers! -> Working 6pm to 6am, eating pizzas and drinking coke! Even more champ for me, because I was working 8am – 5pm before going to code!

But anyway, now that Polycademy is over, where do I stand? I must say I’m still hell of a long way from completing my app, but that I am happy with the outcome of the course – I now feel confident of being able to build a web app from scratch, even though it will be a lot more work to get this chess app to work. After all there’s so much logic needing to be coded! But I’m proud to say that in the last few days of the course, I managed to push myself to at least complete the bulk of the chess move validation in PHP, and some of the frontend stuff in javascript and using KineticJS and HTML5 Canvas!

They say the end of something is the beginning of something new. Even though Polycademy is now officially over, I’m determined to continue coding, and make use of these precious skills i’ve picked up. I wanna carry on with my chess app, and see it to completion. FIGHT ON!

For anyone who’s interested in seeing the (currently still extremely ugly and trial version) of Chess Dimension, you can do so at http://chessdimension.ap01.aws.af.cm/canvas (note: currently only working in Chrome)

Special thanks to Roger and my mentor Ross for their invaluable help and motivation! It is greatly appreciated.


Week 7 and 8 of Polycademy

Posted: March 28, 2013 in Uncategorized

Week 7 and 8 of Polycademy flew by, like so fast. 3 more weeks to complete the app but I’m hardly anywhere near completion. Its worrying. Will make this a short one so I can go back to the javascript/Angular JS readings.

Last week marked the transition from Server Side programming (in PHP) to client side programming (javascript, AngularJS). Actually took 2 days off work, on tuesday and wednesday to work on my PHP, and managed to get a few things done, like getting the chat and login controllers done, and successfully updating my database using JSON data from the RestClient addon to firebug, which really is a very useful tool once you’ve routed your site RESTfully. Basically it allows you to apply the HTTP methods- get, post, put, delete, even though only get and post are normally available! Was pretty pleased with myself but then now i’m worrying, because the main bit (the chess game) is still close to 0. I’ve ploughed through about 1500 lines of code in this chess PHP library I downloaded, but still I’m confused as to how I can actually implement it and use its API to create a chess game. Well I guess I might just scan through the rest of the 2000 lines of code, and get Roger to give some explanation on how the implementation is done. Really got to get this going, because it is key for the client side stuff to work.

So, on Thursday (Week 7) we started on the JS. Went through quite a number of things, like the Object Orientated Programming style in JS (using prototypes instead of classes). I actually got quite lost in class, not having time to read the JS documentation before hand, but I think everyone else was pretty much in the same situation.

For Week 8, there really isn’t much to say. My mum came to visit (from Singapore) on Week 7 Saturday, and will be staying till Week 9 Wednesday. Wasn’t well on Mon and Tues so gave Polycademy a miss. And then a full day meeting in Melbourne for work came up on Wednesday, so I fell further behind. Finally got back to class yesterday (Wed) and found myself trailing, hardly understanding what’s going on in class. ARGH. I shall endeavour to catch up by this weekend – watch the Egghead.io videos on AngularJS, play with the AngularJS phonecat tutorial, and finish my reading on Javascript. Might actually give class tonight a miss because it’s just not productive time going to class and not understanding anything. Might as well stay at home and read through more notes and catch up. But we’ll see.

Hopefully it all works out.

Week 6 of Polycademy

Posted: March 22, 2013 in Uncategorized

Fallen further back- it’s almost the end of Week 7 and here I am reflecting on Week 6. A minor consolation is that I’m still alive – despite having a number of sleepless nights, working on both ChessDimension and my Macquarie uni course. Anyway I’ll make this reflection short, I’m currently at work and writing it during my lunch break…

Week 6 proved to be more comprehensible than Week 5 (thank God)! On Monday, we went through the rest of the Server Side Architecture stuff, and learnt some theory on concurrent processing, Web Sockets and RTC. The theory is really massive, but Roger did a good job of summarising it, so I have some idea now, and can probably use it as a base for further research down the road when I actually need to implement multi-threading or multi-processing. Really grateful for all the links on the wiki for things like job managers, hosts that support them, etc. because they are going to make things so much easier! I mean there’s always google, but it’s hard to google for something when you don’t even know what you’re looking for! Anyway, about web sockets, to be honest, I didn’t know prior to this course that it was so tough to send info from one user to another user immediately. Have gotten so used to facebook chat instantly popping up, that I think it’s just a simple User A sends chat, User B receives chat thing? Then, I learnt that it’s easy for User A to send the chat to the server, but then for User B to get the chat, it requires getting the chat from the server, and that’s not easy. How does User B know that User A has sent something? Anyway, to answer my own question with knowledge i’ve acquired, there is this thing called polling, where User A polls the server at regular intervals to check if there are any new updates, and if there are, then grab the information back! But then my next question was: how then can you make it real time, unless you poll the server at like millisecond intervals? And doesn’t that take up a lot of resources? The answer to that was: there’s this other thing called long polling – where User B sends a request to the server, which stays there and waits for something to reach from User A. Once it reaches, it’s sent back to User B, who then immediately sends another long-poll to the server, awaiting more info from User A.  Complicated eh? But then Roger exposed us to this new concept called WebSockets, where it’s possible to have an connection between the two computers, where you don’t have to poll the server to pull information, instead everything that’s sent can be received directly! Really awesome stuff. If you want to see it in action, go google Ratchet. Really looking forward to implementing this.

The rest of the week- we covered more concepts – design patterns in PHP and had some time to do the PHP programming for our apps. It’s been really crazy, there’s just so much to do. But at least I can be proud to say I managed to implement a login system (based on IonAuth), mind you it’s really basic, but at least there’s something there. I’ve also done a CRUD for a chat system, and implemented the RESTful stuff, which is pretty cool! Lots more to be done, especially understanding the available chess PHP libraries out there, and actually manipulating them so they fit my project.

But more of that in the Week 7 reflection. Back to work.

Week 5 of Polycademy

Posted: March 13, 2013 in Uncategorized

Week 5 of Polycademy marks the week that I start drifting. Not in terms of interest- I’m still adamant on getting this project done- but that I’m actually feeling really lost in class. It’s not a good feeling 😦 I blame it on my having far too many activities- full time work, Macquarie University, and Polycademy all at once. But there’s no point crying over spilt milk, so I shall complete this reflection, and get back to working on my MVC. 

Week 5- Mon to Wed was still manageable. Monday, we covered some stuff on Database schemas and migrations. Basically this involved brainstorming what MySQL tables I would need in the database (for the app), and relating them to each other. The idea is- you would have a model for each table, and then when your website page requires to do something with the dynamic info, you would use the controller to call the model which in turns interacts with the database to Create, Read, Update or Delete (CRUD) records. So basically, I came up with some tables I’d need in the app, namely the user profile table, payments table, game data table, move log table, permissions group table, ratings table and chat log table. I’m pretty sure I missed out some that would be crucial, but I guess these 7 tables are more than enough to work with for now. After the database schema was completed, we implemented the tables into our actual database using this thing called Migrations. Roger explained that it was possible to simply go to PHPMyAdmin and add the tables manually, but the problem with doing that would be that when you want to change servers from say development to production, or in the future from one database to another, it would be a huge hassle inputting all the fields one by one again. The Migration capabilities of CodeIgniter really makes it much easier- all you have to do is to write your tables (migrations) in code using CI’s DBForge and ActiveRecords, and once you visit the migrations controller of your home page your database is updated to the latest migration. Way simpler than inputting everything manually again in PHPMyAdmin! Thought that was pretty cool.

Tuesday- We covered some concepts of stateless security- some elements of which included input validation (constraints, XSS/CSRF, Isolation and AJAX&CSRF), handling passwords and using SSL. It was quite complex but interesting stuff, learning about how hackers could potentially come to ruin your website. The mentality is that you have to assume that everyone coming to your website is here to be destructive, so you have to come up with ways to ensure these idiots don’t put your hard work to waste with a simple rm-rf function (!) Actually found the part about passport hashing and one-way encryption particularly intriguing -how a hacker would use brute force to try and break in, and how you would prevent it. In fact I was so interested in it that I spent 3 precious hours in the office today doing some research, going from one article to another trying to figure out how the notion of a one-way encryption was possible. For a while, I was like huh? If someone knows your encryption algorithm, can’t he just simply break it right away? But after reading some insightful articles (http://security.stackexchange.com/questions/11717/why-are-hash-functions-one-way-if-i-know-the-algorithm-why-cant-i-calculate-t), I understand it better now. 🙂 Really liked the simple but realistic example of say having two prime numbers, 10000019 and 9999991, and your algorithm is just to multiply them together to give 100000099999829. Even if a hacker knew this algorithm, and wanted to reverse engineer the two prime numbers, he would have to spend a fair amount of time to brute force it, testing number after to see if they were a factor! (i did something similar in my free time at projecteuler.net for fun). Imagine applying such an algorithm many many times – and the task of the hackers get much tougher. The adding of a salt further increases your security manyfold.

Wednesday- We started on stateful security, going through sessions, and using this library called IonAuth. This was still manageable, and I managed to understand the bulk of what Roger explained in class. We also learnt how to edit the .htaccess file so that we could access a http://www.example.com/index.php/home/controller by simply typing example.com/home/controller, making the url much more compact and pleasant! Another concept we went through was compression – the amount of space you can save is tremendous when you use gzip compression! So with compression, users can load your website faster, and you save money because you need less space to host your page.

Thursday and Friday, I basically just half listened in class because I got totally blown off my feet in the first hour of lecturing. Well to be fair, it wasn’t Roger’s teaching, more of I was dead tired and struggling to keep my eyes open. Then after missing the basics, I totally couldn’t catch up in the next hour/ day, so I pretty much just hecked and continuing catching up on my view/templating which I had missed out the previous week due to having to send my girlfriend to Sydney. It’s a vicious cycle really – once you’re behind, you can only get more behind. I’ve gone through this cycle way too many times in uni, and I know its not a good path to go down. 

Anyhow, didn’t get a chance to meet up with my mentor last weekend as he was in NZ (hope you had fun, Ross!), but looking forward to catching up with him this weekend and picking his brains on how to do some of this php stuff!

For now, got to get my models actually implemented, and catch up on the stuff I missed out in class on last Thurs and Fri, namely stateful security – including RESTFUL routing, which will be necessary to be REST compliant. Just hope I can get through this by Fri, leaving some time for me to catch up on this week’s material on the weekend. Not to mention having to spend at least 1 full day studying for the Macquarie Uni stuff. ARGH. 

Feeling this huge sense of inertia to actually get my models done, because i’m not sure how to do them at all. So I’ve been spending my time reading the wiki, and trying to understand. But ultimately I’ve got to get the MVCs done ASAP so I can use them in the client side programming starting next week. Perhaps friday I’ll spend the whole day focusing on doing that, while tomorrow I’ll try and finish the reading required. JIAYOU timwee!

seriously toying with the idea of getting my boss to approve me taking two weeks or so break. God knows how badly i need it. 

Week 4 of PolYcAdeMy

Posted: March 5, 2013 in Uncategorized

It’s been a long week. Again I find myself lagging behind- which is evident to all from my blogging on Tuesday of Week 5! Just thought I’d record some interesting things that happened today, even though I’m really supposed to be reflecting on the things I learnt last week. So, today… I was really tired driving to Polycademy from work, like to the extent that I was trying to powernap at every traffic light and awaking whenever I heard the Vroom Vroom of cars revving to accelerate. Anyhow, I was planning to drive to class, but somehow my mind totally didn’t register it, and I subconsciously drove towards home instead. Fortunately, I realised early enough and made a slight detour. Then I reached the NICTA offices, and I made a beeline for the lift. I totally forgot that the lift required an access card to work, and was thinking for a few moments why the level 5 button refused to stay lighted up. While I was still dazed, the other lift door opened, and a guy exclaimed “Hey Tim, what are you doing here?” I looked up an saw a colleague from work, and got quite disorientated for a bit. I was like “huh?”, did I just drive back to the office? Why am I seeing him here? LOL turned out he came here for a meeting with someone. So he left, and I continued to stone outside the lift. DING, the lift doors opened again and out came a stranger. “Hi, Tim”, he offered. This time I was totally stunned- who was he? I managed a weak “hey” when he asked “Are you here for the video conference?” Before I could say anything else, another guy sitting at the sofa walked over and shook his hand- The real Tim who was here for the conference. Haha the stranger in the lift must have mistook me for him because I was in business dress right outside the lift, as though waiting to be welcomed in.

OK, more about Week 4 (last week). Last week we started on PHP, basically focusing on the server side architecture. This was one of the parts I was looking forward to most, because I quite enjoy programming. But I soon found myself swept away by the pace. In 3 days, we skimmed through PHP syntax, using Codeigniter, Object Orientated Programming, the MVC, templating, and autoloading. I think what made it worse was the fact that I hadn’t managed to find the time to do the readings beforehand, so I was pretty lost in class. 

Then on Thursday, some quite horrible news came. My girlfriend’s grandmother had suddenly passed away. So I had to give class a miss on Thursday night, to accompany my gf. I also booked a flight for her to return back to Singapore on Friday immediately. So Friday I drove her to Sydney to catch her flight. The weekend was really hectic too, as I had to spend some time in Sydney. At least I managed to do some readings- up to the MVC bit, and some of databases section. But as the chinese saying goes “祸不单行” – bad things seem to come all at once. Basically, my Actuarial Part II classes at Macquarie University had started, and the workload was really crazy. I mean, I was prepared to have to study, but little did I expect to have to do assignments every week (!) Doing the readings required to do the assignments pretty much took up the rest of the weekend, and even part of monday in the office. It’s really getting tough.

So where I stand now: Still kinda behind the rest of the class, not having set up the templating and views. And kind of losing the energy to rush home after class to continue working. I could do it the first 4 weeks, but the sleep deprivation is sort of getting to me. ARGH i need some help, or some company to help me focus.

Hopefully the rest of this week goes better. Really looking forward to the weekend cuz it’s a long weekend. I need all the time I can get. Wish me the best of luck, because I need it. Back to read more about templating now. 

PS: I know this blog is getting really emo, but it really can’t be helped – it’ll be a miracle if I manage to pull through. But I must! Still loving all this, and really glad to be able to learn these skills 🙂



Week 3 Polycademy

Posted: February 26, 2013 in Uncategorized

So i forgot to write my weekly update last week. Was just too busy working on my app that I didn’t even have time for reflection! Then just yesterday I received a notification that a certain polyashemy.wordpress.com had been updated, and it occurred to me! (polyashemy is written by this dude in class called Ash, and he writes really humorously and pleasantly that I’m an avid follower of his blog now).

Anyway, to put things into context, I’ve just finished a gruelling 3.5h class on PHP. Today Roger lectured on Object Orientated Programming (OOP) and Model View Controller (MVC). It was extremely tough- especially since I didn’t have time yesterday to read the documentation so I could at best understand half of what he was teaching today. But anyway, that’s blog material for Week 4. What I wanted to say (… pause for dramatic effect…) was that I’m sooo busy that the only time I can spare to write this blog post, is after the 3.5h class, while waiting for my pizza order at Dominos (WOOT) now. I’ve been given an estimated waiting time of 15 min, so hopefully within that time I’ll be done reflecting on what progress I made last week. 

Okay, so back to Week 3. Last week we focused on learning HTML, CSS and LESS. We also used the HTML5 and Twitter Bootstrap frameworks (by downloading Initializr). Basically, HTML would allow us to enter the desired website content, while CSS (short for Cascading Style Sheets) would allow us to style the page- make it all pretty and such. LESS was a language extension to CSS which really simplified the writing of CSS code – with CSS alone we had to specify styles for every element individually, while with LESS, it works like a programming language- we could simply nest CSS elements within each other, and so some elements would inherit certain styles etc. It was pretty cool- all we had to do was to write LESS code, then use a program called SIMPLESS (or lessphp on cloud9) to convert the code into CSS. Then what HTML5 provided was a default spreadsheet with some default code embodying best practices, while Twitter Bootstrap provided alot of custom-made CSS styles – like premade carousels, modal-boxes etc. Indeed, Twitter Bootstrap really reduces the work of web designers ALOT, you can just use the custom stuff and tweak it some to give the look you want- so you don’t have to start from scratch! However,the trade-off involved is that your website could end up looking extremely like other websites which use the same template!

So we basically stepped straight into it, applying what we learnt directly into implementing our photoshop mockup into an actual webpage! It was very frustrating at times, especially when you spent half an hour on an element and couldn’t get it right. For the most bit, your website looks extremely horrible until you get everything right. I had a lot of problems particularly with the modal box and carousel, but I pretty much managed to smooth things out after many hours of arduous work. It’s really a huge sense of satisfaction when you finally get your website to look the way you wanted! Even learnt how to host my website- it’s currently hosted on Appfog: http://chessdimension.ap01.aws.af.cm/ At this point it’s not connected to my domain yet, just want to keep it private and low profile for now till I actually get it right, and put in real images instead of the placeholders I’m currently using.

Just so I remember, things that still need work are –

1) I’ve currently got placeholder images and logos on the website- these have to be exchanged for actual ones.

2) my modal box that launches on clicking the play button has been styled, but the register modal box is yet to be completed. I expect quite a few problems because I was unable to style the modal box by id, and simply used common classes – will need to figure out a way to distinguish the second modal box from the first, and apply new attributes to it! (still can’t figure out why my CSS code doesn’t work when i specify the modal id).

3) I tested the website on my huge desktop in the office today, and it appears that on a big screen, my content is not long enough, and the footer ends up being 4/5 down the page, leaving an extremely ugly white space below. Done some research on how to fix that (using this thing called sticky footers), and will have to implement that.

4) My website is currently not responsive – just resize it a bit and all kinds of holes start appearing – things shifting into weird positions, basically its a mess. i’ll have to find some time to fix that – we don’t have any more time allocated in class for website design, so it’ll prove a challenge to find the time to actually sit down and fix it all. 

Other than that, I think I’ve made good progress! Learning how to code a website within a week, is quite impressive (if I may say). While there can be loads of things to improve on, I guess I must draw the line. As my mentor Ross commented “You can spend days and months and years on CSS, to customise your stuff. But you shouldn’t get too carried away”. Words of wisdom.

Anyway, one last thing before I put down my pen (figuratively). Just a shoutout to Ross, if you’re reading this, thanks for being the best mentor ever! Really appreciate you taking your own time to help me research on how to make the chess board thing work! 🙂

OK, so that’s it from me for now. Just in case you’re interested, I’m already back home, munching on my pizza as I type. Got to watch some shows with my girlfriend before I go to bed, hopefully I manage to catch more than 5 hours of sleep tonight before another long day tomorrow. Will have to do some reading at the office just so I don’t get totally lost at class again tmr. 

Echo “Over and Out”;

On the bright side, I just wanted to say what a great mentor I have. Appreciate him spending a precious Saturday afternoon mentoring me. Thanks so very much, Ross! 🙂

Aside  —  Posted: February 16, 2013 in Uncategorized