NILS Japan

Git: Deleting stubborn untracked files

Posted on

Alright I’ve ran into this problem way too many times and not kept a note on this so to save myself the trouble (and to the poor donkeys out there who are on the same boat) I’m making a note now so I won’t forget … and to help everybody out there.

Lets say you’ve finished on your assignment and you hit git status before pushing your work into your remote repository. You get something like this:

Benji$  git status
On branch feature/LOLMACHINE
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	deleted:    Animations/nyancat.meta
	modified:   LOL_Game.unity

Untracked files:
  (use "git add <file>..." to include in what will be committed)


Try as you might Git reset HEAD and Git reset doesn’t work.

Luckily you can get rid of untracked files using the simple git clean -xf

If you feel compelled to remove everything including the directories you worked on but might not necessarily be needed then you can use git clean -df and BOOM, all is good again.


Updates on Japan

Posted on

My first year in Japan as a student was (by far) the best experience I’ve ever had. And my 2nd and a half year of living here working is also pretty good!

But there are things about Japan I just cant shake off or want to get used to and the mentality here is … you are either one of us (but not necessarily treated the same anyway) or you are not part of us at all. Especially the way people think here being so different and .. to be frank, more narrow than the west which got me thinking …

Should I relocate away from Fukuoka (or Japan even) a couple years time from now and find work elsewhere? Why not? I’m still before my 30s after 2 years from now and I’ve also dreamed about living in Canada for a while too.

I don’t know, lets wait and see.

“signal 11 (SIGSEGV), code 1” – (Cocos2dx, C++ with Android & Eclipse)

Posted on Updated on

The biggest drawback I’ve been having with Eclipse and cocos2dx (not sure if this also applies to Xcode …) I can think of is the annoying “Signal 11” error. But then I ran into this thread on StackOverFlow:

I find the perfect answer in

The solution is:

When you get errors like this on the LogCat, they are saved on $PROJECT_PATH/obj/local/armeabi where $PROJECT_PATH is the path to your cocos2d-x android project. To symbolicate the messages to something understandable, you can use the ndk-stack tool.

Open up the Terminal (or Cygwin, not sure though) and type in

adb logcat | ./ndk-stack -sym $PROJECT_PATH/obj/local/armeabi


$ANDROID_NDK is the path to your android NDK

$PROJECT_PATH is the path to your cocos2d-x android project

Wow! I just hit the jackpot! okay well time to switch over to my terminal and try this out. I then get the following crash dump:

********** Crash dump: **********
Build fingerprint: 'samsung/SC-04E/SC-04E:4.4.2/KOT49H/SC04EOMUFOB2:user/release-keys'
pid: 18875, tid: 18897, name: Thread-18051  >>> com.benji.etcetc <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
Stack frame #00  pc 00000000  <unknown>
Stack frame #01  pc 000de0b9  /data/app-lib/com.benji.etcetc/ (GameScene::onTouchBegan(cocos2d::Touch*, cocos2d::Event*)+232): Routine GameScene::onTouchBegan(cocos2d::Touch*, cocos2d::Event*) at /Users/benji0110/Downloads/cocos2d-x-3.3/etcetc/
Crash dump is completed

Awesome! Finally according to my crash dump I was able to locate where my app crashes at line 355 .. it turns out I had deleted a game object at runtime and read that objects size, but because it was now destroyed the object no longer existed causing the program to terminate.

What a treat to end an awesome Friday^^

How to traverse through a 2D CCArray – Cocos2dx, C++ on Android (and 5 month workout progress)

Posted on Updated on

Couldn’t find anything on making a multidimensonal CCArray anywhere so I’m leaving this here so I don’t forget later.

Generate an array which holds an array that holds a sprite.

Adding into our 2D CCArray:
Lets open our text editor and write some code!

Somewhere in our header file

	// ... 
    Sprite*                     _spriteImage;
    CCArray*                    _arr_x;
    CCArray*                    _arr_y;
	// ...

Now in our implementation file:
cpp file:

 * add sprites into a 2D CCArray
void Hoge::addIntoMultiCCArray() {
    _arr_x = CCArray::create();

    for (int i = 0; i < ARRAY_SIZE; i++) {
        for (int j = 0; j < ARRAY_SIZE; j++) {
            _arr_y = CCArray::create();

				int randomized_tag  = rand();                                  // generate a random tag to identify which element
				int pos_x           = i * 100 / 1.5f;                          
				int pos_y           = j * 100 / 1.5f;                          
                _spriteImage   	   = MySprite::create();
                _spriteImage        -> setPosition(Point(visibleSize.width / 4 + pos_x, visibleSize.height / 2 + pos_y));
                _spriteImage   	  -> setTag(randomized_tag);
                _arr_y         	  -> addObject(_spriteImage);
                this           	  -> addChild(_spriteImage);

                _arr_x   -> addObject(_arr_y);            //  Where the magic happens
    _arr_x -> retain();
    _arr_y -> retain();

Adding into a multi CCArray is quite straight forward. For each element in the first CCArray you just need to create another CCArray to produce that multidimensional array.

Now we want to do something else besides adding.

Why the traditional way is a bad idea:
The traditional way of traversing through a 2D array is with for loops:

for (int x = 0; x < ARRAY_SIZE; x++) {
	for (int y = 0; y < ARRAY_SIZE; y++) {
		// do something

Lets say we want to edit or delete something. We can’t just do the traditional way like above.

Compiling the code using this method is okay, but at runtime this will produce unexpected behavior and our app will crash due to memory leaks. So to counter this, we need to use CCArrays CCCARRAY_FOREACH method.


// ... somewhere below our implementation file

    // traverse through our multi CCArray
    CCObject*   obj_x = NULL;
    CCObject*   obj_y = NULL;

    CCARRAY_FOREACH(_arr_x, obj_x) {
        CCArray* _obj_x_arr = (static_cast<CCArray*>(obj_x));

        CCARRAY_FOREACH(_obj_x_arr, obj_y) {
            Sprite* _spriteImage_y  = (static_cast<Sprite*>(obj_y));
            Rect rect_a         = IntersectionPoint_A -> getBoundingBox();
            Rect rect_b               = _spriteImage_y  -> getBoundingBox();

            if (rect_b.intersectsRect(rect_a)) {                
                // maybe delete this element from _arr_y?
                _obj_x_arr -> removeObject(_spriteImage_y);
                this       -> removeChildByTag(_spriteImage_y -> getTag());	


Hopefully this will help someone out there. Maybe my coding still is weird (and if it is I would love some feedback on how to write better code^^)

Oh yeah before I forget, here is a recent picture of my arm after 5 months of workout!

Not bad eh? Gotta keep eating and working!
Happy coding!

Off to Japan!

Posted on Updated on


Almost set for Japan now. Decided to make this blog all english since I already have a Japanese one. And besides, I already told my family & most of my friends so I’ll use this more to update everyone back home, rather than writing separate E-mails back & forth. I think this should be better.


Some of my family and friends already know this but to those who don’t, Today’s the day I’m finally going to Japan to study for a year. Have been wanting to do this for a long while since uni but I couldn’t because of my degree (which was software engineering BSc)  and that got in the way with my minor degree. At that time (2009) it was impossible to do a year out in Japan. Although I think now Oxford Brookes University made it possible. I’m not sure, just a word of mouth so someone can correct me.


The school I’ll be going to is called NILS. If you’re interested in going too, then here’s the website: 

Ok I have to make this entry quick cause I still have left over stuff to pack then check, and then a friend is coming over to drop some stuff off and then I gotta skype some friends. Rush rush rush ……. Why in the world did I think it was a good idea to start packing 2 days before I would leave the country?!