Things to do when you are stuck at a technical problem

TLDR;
1. Google it!
2. Read the documentation
3. Search on Stack Overflow
4. Do nothing (consciously)
5. Explain the problem to your friend
6. Step Back, Think Again
7. Write an email / blog about it.
8. Throw money at it

Every now and then I get stuck at a problem which makes me pull my hair. I eventually get it, but after wasting a lot of time trying just one thing and not quickly switching to an alternative. I wish I could remind myself this each time I was stuck.
So here’s list of things to do whenever you are stuck at a problem.

1. Google it!
Chances are that others are plagued with the same problem as you, and someone out there has written a solution to the problem. And assuming you are expert at finding stuff (if you are an engineer, then you probably are!) you will likely find it in the first attempt. If you dont, try changing the search keywords to “What you would title the blog post if you were writing the solution”. Remove dependent specifics (such as file path, line numbers or literals), and put other specifics such as “error code” or “error message” first with the name of the technology (such as android, c++, node js, etc.)
The success of this option depends more on chance than your Googling skills, but its still worth the time it takes (next to none, I know!). And often you will find a solution, only to realize that it doesn’t work in your case. At this time you can think more about how the author solved the problem and try to apply it to your case or email the author asking for help. They usually reply if you ask politely.
Also, if this is a quick question, ask it on SO.

2. Read the documentation
This is the option we try to avoid the most. Who wants to read 10 pages about how to do socket programming in C++, lets just Google an example, download and run it. And then sit and curse the author at the first error.
So here’s the truth. You have to read the documentation. It says exactly how to use a thing. Here’s the stuff author wanted you to know before you begin using his tools/library/code. So sweat it out and read it.
P.S. Don’t give up on this option until you are absolutely sure you have read it and it doesn’t address your problems.

3. Search Stack Overflow
So Google Search returned nothing, and the documentation didn’t help, it probably makes sense to search for similar problems on stack overflow. Use tags to find similar problems on SO. Good answers on SO, don’t just give away the answer, they also explain why the problem occurred and Why the solution works. This could probably give you a hint or increase your understanding of the problem. You can do this on your other favorite QnA sites too.

4. Do nothing (consciously)
Take a break. Have a cup of coffee. Go for a long walk. Take a shower. Meditate / Pray. Whatever suits you and is appropriate at the time of the day. Do something that calms you down and you don’t consciously think about the problem. While you are doing your thing, your sub conscious mind is working at the problem in the background. Chances are you will get new ideas. When you do get them, write them down.
This option helps when you have multiple things to do (like in college). Spend some time on a problem and if stuck, move to something else. Come back to it the later that day (or next day) and you will have a few new ideas to try out.

5. Explain the problem to your friend
The first three methods focused on solving the ‘Lack of information’ problem. But may be, you are stuck at a logic problem and you just need clarity of thought. Or you just need a different perspective. So find your buddy, and explain to him the problem you are facing and what you have done. Chances are either he can provide a fix to your problem or give you new ideas to try out.

6. Step Back, Think Again
Ask yourself why you wanted to do it in the first place ? Can you do away with it? Can you change some of the requirements (technical / non-technical) ? Step back a bit and look at it from a different perspective. May be, its not intended to work this way. May be you are using the wrong tools / language to solve the problem.

7. Write an email / blog about it / ask on Stack Overflow
At this point, you have exhausted most of the sources. You must be ready to apply considerable effort to solve it now.
Document the problem in an email to the author of the code / library, or blog about it or ask on SO. Write down what your understanding of the problem is and what you have done to solve it. Note down any assumptions. If uploading a code sample, make sure to create a Short, Self Contained, Concise (Compilable), Example . Doing this will give you a clarity of thought as well as throw the problem out in the open for people to see and easily try out. Update the post, as and when you try out new things or see different results. Keep an eye out for replies / comments and add more information to it as requested.

8. Throw money at it
At this point, you have spend a few days (at least) trying to solve the problem. If you are still getting no where with it and have the financial resources, put the problem on a job site like freelancer.com or elance.com. There are good chances that some experts in the field would be willing to solve the problem for you for a fee. Or by chance if you don’t get any “bids” you can say for sure that the problem cannot be solved.

Happy Coding!

Setting up cocos2d-x with Eclipse and Visual Studio on Windows

Getting started with cocos2d-x can be tough. There’s too much information on the internet that may or may not work for you.
Unfortunately, there isn’t a perfect tutorial that will help you get started, so you may have to mix and match accordingly.
I have been asked about setting up cocos2d-x many times before and this is the collection of resources that I usually point them to –

A very good tutorial to setup cocos2d-x on windows and eclipse here-

http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started

http://www.raywenderlich.com/11338/cocos2d-x-for-ios-and-android-space-game

The official cocos2d-x wiki –
http://www.cocos2d-x.org/projects/cocos2d-x/wiki

More Help here –
http://www.jesusbosch.com/2012/06/how-to-set-up-android-and-win32-cocos2d.html
–For CDT part you can also try OpenCV’s help http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/android_dev_intro.html#android-dev-intro

———————
For setting up in Visual Studio
http://www.jesusbosch.com/2012/06/how-to-set-up-android-and-win32-cocos2d.html
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-x_Application_Wizard_for_Visual_Studio_User_Guide
———————————

Other notes while setting up cocos2d-x on windows with eclipse:

Always run cmd and cygwin with administer privileges.
1] Unzip ndk and add to “path” variables
2] Install Cygwin and select “make” for sure among the utilities that you install
3] Run “create-android-project.bat” in cmd.exe . If it gives error in location of sdk or ndk, then edit the .bat file and change location in there.
4] After creating the project, run the ‘build native.sh’ script using the command
sh build_native.sh
5] If you get permission denied error for any file, then manually select the file and change its permission to Full Control for Everyone. (Alternative run following command in the target folder “chmod 777 -R * “)
6] When you import the project in eclipse then also add the ‘cocos 2d sdk’ library project
7] If you get error while running the project and it points to some file in assets then change permission for that file. or Type this in command line – chmod 777 -R *

Migrating from SVN to Git

Using a live SVN repository

1] Create directory for the git project. Navigate to the directory and do
git svn init -t tags -b branches -T trunk [svn-repo-url]
eg: git svn init -t tags -b branches -T trunk https://subversion.assembla.com/svn/my-repo-name/

and then do a
git svn fetch
This will download all the commits in git. If you get this error

error 0: REPORT request failed on ‘/svn/project-name/!svn/vcc/default’: Path https://Asloob-PC/svn/project-name is not canonicalized; there is a problem with the client.

its because of upper case letters in the url. In this case, my svn was hosted in Visual SVN server locally and the url was https://Asloob-PC/svn/my-project/ I just changed it to https://127.0.0.1:443/svn/my-project/.  Do confirm the port no.

2] Push to git server
Create a repository on GitHub / Bitbucket / Any other git service  and push the changes
git remote add origin https://asloobq@bitbucket.org/asloobq/my-project.git
git push -u origin –all

Using a svn dump file

If you want to migrate a svn dump file to git use the following method. Basically we are going to host it locally on Visual SVN server and then use the above method. Do install Visual SVN server before proceeding.

1] Creating SVN repository from dump the file.
On command prompt go to the path where svn repositories are stored . For me its G:\Applications\Repositories
svnadmin create [project-name]
svnadmin load > [dump-file-path]
Use lower case characters for name of the repository. Launch ‘Visual SVN server’ and check if the repository is shown. Copy the repository url

2] Migrate to git
Use the above method to migrate using the live svn repository.

How to import gmail or yahoo contacts to twitter

Stage 1:
Import facebook contacts to yahoomail!

http://www.ehow.com/how_6960454_import-facebook-friends-twitter.html

(rewriting the part about importing facebook contacts to yahoo mentioned in above link)
Import Email Addresses from Facebook to Yahoo! Mail

Step1
Create a yahoo account or log in to one if you already have one.

Step2
Log in to your Facebook account.

Step3
Type in “Address.yahoo.com” in your browser’s address bar and click “Enter.”

Step4
Click the Facebook icon on the next page.

Step5
Click “OK” in the pop-up window that reads, “Do you want to share your contacts with Yahoo?”

Step6
Click “Done” on the page that tells you how many email addresses you have successfully imported.

Stage 2: Importing from yahoo to twitter!

Step 1: Sign in Yahoo. Click on Contacts on the left Tab. Select Tools List Box-> Export.Now click Yahoo! CSV: Export Now

Step 2: Open the file with notepad and save it as a Text File.

Step 3: Open the file in Notepad. Perform Replace of “”, with space. Again perform replace of “” with space. Now you should see records of each contact on a single line with First Name, Last Name and email address.

Step 4: Delete the first line which says “First Name”, “Last Name”, etc.

Step 5: Now browse the text file and cut the records which dont have @email.com after the email id. For example “myyahooid@yahoo.com” will appear as only “myyahooid” in the text file. Cut and paste these records in a different file.

Step 6: Check for Irregularities in the file like blank line, etc. It should be very uniformly distrubuted. This is an important step.

For example each line should be like this

“firstname”,”lastname”,”emailid@gmail.com”,
Step 7: open Microsoft Excel Sheet. Select Date Tab -> get external data FROM TEXT and select the above text file.

Step 8: Press Next on Step 1 of Wizard. In Step 2 check box saying Comma . Say next and finish. Press OK.

Step 9: Delete the first two columns of first name and last name

Step 10: Copy the whole column of email address and paste in a notepad file. Now you should simply have a list of email address. Next we need to separate the ids with a comma.

Step 11: Find Replace “.com” with “.com,” (without the double quotes)

Step 12: Additionally find replace any other domains like “.in” with “.in,”

Step 13: In Twitter goto Find People-> Invite by email. And paste the email addresses(not more than 50 at a time) and say invite.

Now only thing remaining is the list of yahoo ids. I think you can figure them out yourself! 🙂

Have a nice day!