HTML5 Game. Shooter Game

This is the first HTML5 game that I have really developed. Well, I have worked on creating other classic games before, but this is the first game that I have fully developed, with instruction, score and everything. This is a pretty simple game, where you have to swipe the cannon left and right to shoot down balls before they reach the line.

Some of the things that I have learnt or gathered from this game is to create game objects, with the different variables, and different functions. Another key thing that I have learnt is the array.filter function, which is a quick way to allow us to filter out objects by their properties.

Anyway, the game is available here: Shooter

Google Code Jam. 2009. 1C. All The Base

I practised on this problem today and learnt many new things trying out this problem. By trying out this problem, I learnt an alternative way to handle base conversion. In my opinion, this is a great method for converting bases, and it is especially easy to understand too.

Also, I learnt to handle huge numbers in C++. Unlike Python, C++ uses different datatypes to handle integers of different size. Well, today I learnt that the biggest integer possible is 18,446,744,073,709,551,615. This can be achieved using the datatype unsigned long long, and to format it in printf, it will then be represented by the string %llu.

#include <cstdio>
#include <map>
#include <set> using namespace std; int main(){ int n; scanf("%d\n", &n); for(int c=1; c<=n; c++){ char line[1024]; fgets(line, 1024, stdin); int l=0, cc=0; for(int i=0; line[i]; i++){ if (line[i]!='\n') l++; } set cs(line, line+l); cc = cs.size(); if(cc==1){ cc=2; } unsigned long long s=0; map<char, int> cm; int ccm=0; for(int i=0; i<l; i++){ if(!cm[line[i]]){ if(i==0){ cm[line[i]]=2; ccm++; } else if(ccm<2){ cm[line[i]]=1; ccm++; } else{ cm[line[i]]=++ccm; } } s *= cc; s += cm[line[i]]-1; } printf("Case #%d: %llu\n", c, s); } return 0; }

Tutorial – Heroku Setup

When I first used Heroku, there is this command line interface that allows you to login and easily create apps and push updates onto the platform. However, I realized that this CLI is not really that easy to use at all. After working on it multiple times, it always gives me errors during the logins that I have to solve manually.

As such, I have decided to ditch the CLI totally and work with the SSH login manually. Seeing as to how long I have taken to figure everything, I have decided to make this tutorial for those that who are will be working with Heroku in one way or another.

Step 1: Generating the SSH public and private key
Generate Key
When asked to choose a location to save the file, enter ~/.ssh/heroku .

Step 2: Open up the SSH config file using VIM or any other editor
Open File
Open ~/.ssh/config in editor of choice

Step 3: Edit the config file
Config file
Enter the following text into the config file (In VIM, use :wq to save file)

Step 4: Open up your Heroku Account Setting
Heroku Account
Login to Heroku to edit the account settings, then scroll all the way down, until the SSH keys section

Step 5: Upload the public key
SSH Public key
Copy the content of ~/.ssh/, (rememeber to copy the .PUB file)
Paste in Heroku
And then just paste it in, add the key, and you are good to go.

Step 6: Celebrate
Well, Heroku works like a Git repository. So the next time you want to push a project up, just use git push and git will use ssh to login to heroku, without you have to do a single thing.

Hopes this helps 🙂


I have seen many new platforms popping all around, letting people create their presentations online. However, when one is on the go, we hardly ever get to work on these online applications. Then I started wondering, what if people can format their text just that an application can then help convert these text into presentations.

Markdown was a great choice when it comes to having formatted text. But how am i going to create a presentation based on text alone? So, I tried it out, it worked pretty well, I added a few designs from Google Docs. There we have it: Markdown PPT.

The presentation is in the form of a html file, with the styling and javascript code all embed inside it. So, it is possible to just send over this file to someone and have them view it in a browser. Use ‘left’ and ‘right’ key to navigate the slides.

It is a rather crude application, but if anyone is interested, just try it out.

MarkdownPPTSample Presentation

UVA online 10189_Minesweeper

Since I am not going to have anymore time soon, I decided to try one more problem just to check that I still have my skills intact for school start. I tried this minesweeper problem. I passed through the sample test case the realized that I had made a terrible mistake, which took me 3 wrong submission and 9 unique test case to realize. But eventually I managed to solve it.

#include <cstdio>

int main(){
    int f=1;
    for(char line[1024]; fgets(line, 1024, stdin); ){
        int n, m; sscanf(line, "%d %d", &n, &m);
        if(!n && !m) break;

        char g[n][m];
        for(int i=0; i<n; i++) fgets(g[i], m+10, stdin);

        if(f>1) printf("\n");
        printf("Field #%d:\n", f++);
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(g[i][j] == '.'){
                    int s=0;
                        if(j-1>=0 && g[i-1][j-1]=='*') s++;
                        if(g[i-1][j]=='*') s++;
                        if(j+1<m && g[i-1][j+1]=='*') s++;
                        if(j-1>=0 && g[i][j-1]=='*') s++;
                        if(j+1<m && g[i][j+1]=='*') s++;
                        if(j-1>=0 && g[i+1][j-1]=='*') s++;
                        if(g[i+1][j]=='*') s++;
                        if(j+1<m && g[i+1][j+1]=='*') s++;
                    printf("%d", s);
                }else{ printf("*"); }
    return 0;

Starting a new development blog

I have been working on some scripts and some applications for now and I thought to myself, wouldn’t it be great if someone out there knew that I am doing all these? Wouldn’t it be great if someone shared their projects so that the next time I want to do something, I have something to start with?

Well, this is what it will be for. This will for the projects that I have worked on for now. In the past, I have managed to come up with some interesting ideas and have worked on quite a number of them. To date, these projects are quite unique and this, I hope, will be a good platform to share it too.

Lastly, this will also act kind of like a code repository for my scripts. These scripted are often my submission to programming problems. Since I am quite new in this, please do correct me or provide any advice in any matters you feel should be improved on.

Okay, really really lastly. I hope that having this will prompt me to really write more programs and write more scripts and if possible, even learn to make simple games. Yep, that is all,