tiistai 8. joulukuuta 2015

Node version manager and usefull NPM commands

Install Node version manager with command:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
(https://github.com/creationix/nvm/blob/master/README.markdown)

Then install Node version nvm install 5.0

Change Node version with nvm use 5.0

See what packages you have previously install globally: npm list --depth 0 -g

Node versions can be found here http://nodejs.org/dist/

To see versions of single package use command: npm view appname versions

To install specific version use command: npm install -g appname@4.3.1

torstai 29. lokakuuta 2015

Advanced git. Cherry-pick, rebase and reset.

Today I encountered the following problem: I had put code in another branch that I would need in my master branch, BUT I could not take all code, just few commits. So I first found command called cherry-pick.

With cherry-pick you can merge one (1) commit from another branch and is quite easy to do, but eventually I found out that it is not a right tool for my job. Anyway, checkout your branch where you want to pick the commit.

git checkout mysecondbranch

then do git log with oneline option to show prettier log.

git log --oneline

Then just select the commit you want and checkout back to the master branch. Do

git cherry-pick 62ecb3

And you will merge that commit to your master.

Now if you need to merge multiple commits but not the whole branch cherry-picking is not the right tool for this job. We can rebase. First create a new temporary branch from the branch you want to do the changes. Then do rebase.

git rebase --onto mythirdbranch 76cada^

This means that from our "mythirdbranch" from commit number to the last one are applied to the temporary branch. 


OK so if you mess up with the rebase thing, you can do 

git rebase --abort

or if you already did the rebase, revert it with the following:

git reflog

git reset --hard HEAD@{5}

and the number inside head is the commit where you started the rebase. 

Finally merge the temporary branch your master branch.


PRO TIP


ssh-add id_rsa will add your ssh key to keyring or something. Then you don't need to enter password every single time when you connect to git.


perjantai 14. elokuuta 2015

Potatoman adventures - Mobile game

Long time no articles for my blog. I attended to Haaga-Helias mobile programming couse last year so this post is about my experience about mobile programming.

We had to use PhoneGap for compiling our apps, but in the end we decided to use CocoonJS for building our game. The final task of the course was to create our own mobile application of course. I haven't created any mobile games yet, so I decided with my friend we will make a mobile game for Android. I also had two Android phones to test the application.

First we decided the game should be Super Mario like 2D runner game with very easy controllers. Maximum of 4 buttons. Then we decided to use only 3 buttons. Left, right and jump. The game is easy enough to be played on the mobile. The challenging part was which game engine we should use or use our own? We found many different engines, but we wanted HTML5 based game engine, because then the game would be easy to port to any operating system. Then we found Quintus which was what we were looking for. It had mobile controllers implemented already. We decided to do at least three levels for the game, create some sound effects, background music and a little starting intro like in Max Payne which is black and white comic.

It actually took us very long to do the game. If we had created the whole engine it would have taken over a year from the team of two guys.


I was in charge of the game graphics. All graphics are done with Adobe Photoshop and Illustrator. Our game engine needed Tiled map editor for the level design. I created also the levels. Then I used microphone and Audacity to create sound effects. My partner focused on game logic and programming. When all the material were ready we also created teaser video for our application and compiled it in the CocoonJS. We had some trouble converting the game but in the end we managed to do it. It was a nice little project. To keep our code nice and clean we put it to GitHub.


Till this day 14.8.2015 our game has got over 200 downloads from the Play Store.

https://play.google.com/store/apps/details?id=com.potatoman.adventures

We got 5/5 grade for creating and publishing this game.


keskiviikko 27. toukokuuta 2015

Robots.txt file for Wordpress

For Wordpress its good idea to put wp-admin in disallow. This means Google bots don't visit wp-admin page and rank it on search.

User-agent: *
Disallow: /wp/wp-admin/

sunnuntai 23. marraskuuta 2014

Android application - pixel check

I just published my second Android application to Google PlayStore. It goes by the name "Pixel check". You can change the screen color by tapping screen. If there are dead pixels they show as black/grey and if the pixel has color errors it should stand out. Try it out here: https://play.google.com/store/apps/details?id=com.shnigi.pixelcheck





perjantai 7. marraskuuta 2014

Alphabets game

When I was a kid I played game where I had to enter all the alphabets as fast as I can. Two days ago I remembered that game and wanted to create my own version. This game is written with Javascript + HTML + CSS + PHP + MySQL. Game is created with Javascript and then PHP saves results to database. Top 10 players are queried from the database. Try it out here: http://84.251.124.101/~shnigi/aakkoset/index.php


tiistai 14. lokakuuta 2014

Javascript applications

So I have been learning Javascript for a while now and I'm getting it slowly. But still it feels so hard. I completed codeacademy.com Javascript course and had some other things to read. So far I have quickly developed three little things.

First one is rock, scissors, paper game. Simple game. Try the demoversion here: http://84.251.124.101/~shnigi/kivisaksipaperi/pewi.html


Next one is coinflipper. Select your side and flip it here: http://84.251.124.101/~shnigi/kolikonheitto/


Last one is Lotto-machine where you enter 4 different things and the machine tells you which one is best. Try it here: http://84.251.124.101/~shnigi/lottokone/

I'm planning to do a mobile app (Android) later from one of these.