Creating a “Hello, World !” Kindle Fire app using App Inventor – it’s easy, it’s free !

I was browsing the Amazon app store today morning, looking for an app for my Kindle Fire, but unfortunately I just couldn’t find one that looked as sleek as the iPad counterparts. I even upped my budget from FREE to 0.99$, but in vain. So being a developer, I did what came naturally to me – reinventing the wheel by creating an app of my own.

Step 1 of 2 – Creating the application on your computer

So, first things first, a “Hello, World!” application. I stumbled upon the the App Inventor by Google that allows you to create apps for the android phone and as luck would have it the apps work on Kindle Fire too. A perfect start for someone like me who knows nothing about mobile development.

Installing the necessary components so that the App Inventor can work in your browser is really easy and hassle free. Just visit App Inventor Website and follow the instructions to a T !

I’m not going to repeat the instructions, as it has been explained very well on the App Inventor website. You need to follow the section that explains how to create an app using an emulator (and not the phone). I’ve added a few snapshots and some notes on slight glitches I faced.

A snapshot of the App Inventor with the “Hello World” interface – a button and a label :

Note 1. I installed the app inventor on OS X Lion and Windows 7 Home Premium without any hassle at all using Chrome.

Note 2. After I closed and restarted the browser, the app inventor did not load correctly. I fixed this by explicitly executing the adbdevices.bat file which can be found at “C:\Program Files (x86)\AppInventor\commands-for-Appinventor\adbdevices.bat” on a 64 bit windows machine.

The Block Editor allows you to define the behavior for your user interface. The graphical model for describing the logic seemed a little too cute to be very practical but it does get the job done and worked without any problems. I am going to have to dig deeper and figure out if the App Inventor allows you to define logic the ‘text editor’ way, or if I am going to have to switch development environments for building applications that do more than purr.

A snapshot of the Block Editor – toggles the label on button click :

Note 3. On the mac, the “connect to device..” button on the Block Editor was grayed out for me. I am sure this can be fixed but I just switched to Windows 7 to avoid being derailed.

So at the end of this process you should have a .apk file somewhere on your computer.

Step 2 of 2 – Installing the application on your Kindle Fire

This was easy, now comes the frustrating part of transferring the .apk file to the Kindle without a USB cable. Eventually I did find a roundabout way of getting this done.

Firstly, you need to install the ES Explorer application on your Kindle Fire. Next, you need to enable application installation from “unknown sources”. Unknown to Amazon that is, not you. If the application is unknown to you, you might be better off without it. This option can be found under settings -> More -> Device -> Allows Installation on Applications -> ON.

Install the ES Explorer app on Kindle Fire

Turn on app installation from unknown sources for Kindle

You now need to send the .APK file to your kindle. Emailing the file to your-amazon-id@kindle.com does not work. If you have a USB cable thats great, but since I didn’t have one I mailed myself a copy of the file and downloaded it via the Email app on Kindle.

You can install the application by launching the ES Explorer application and locating your .apk file. If you downloaded it via email, you will find it under the “Downloads” directory. Install the application and your app will be added to “Apps” available on your Kindle.

Our HelloWorld app under “Apps”

You are now ready to greet the world !

Advertisements

Google Chromebook – better or worse than a laptop ?

I was reading this article today at the NY Times, which offered an amusing introduction to Google Chromebook – the new laptop by Google. The article itself and a lot of comments that followed didn’t seem too impressed. Maybe you like it, maybe you don’t, but you will definitely agree that it is different. How so?

1. It does not run Windows BUT is still targeted towards people who think Ubuntu is …ummm, what exactly is it again?

2. The only thing you can do with it is surf the web BUT it still costs as much as a fully functional laptop.

Sam Grobart ends his NY Times post with this cheeky little note, which might very well reflect your state of mind.

The Common Man : So I would want a Chromebook because …?

Sam Grobart : Good question.

Though the comment above was meant as sarcasm, I believe it is a good question. When I bought my first laptop, I wanted every possible port a device could offer. What if I wanted to connect it to [any magical peripheral device here] ? By the end of its life I had used two, the Ethernet port (for internet) and the USB port (for everything else). The same holds true for the SLR I purchased with great enthusiasm. On most occasions I used two buttons, one that turned the power on and the other that took the picture.

So if you believe Chromebook is useless because regular laptops can do everything it does and much more, think again. When Google first launched its search engine I am sure they looked stupid with one button and one text-box, but look where they are today. And though most people think they want more features, what they really want is more simplicity. Apple and Google are organizations that get this and it is reflected in their products beautifully. Microsoft unfortunately is not one of them and anyone who has worked with Visual Studio can vouch for that ;-)

I use the computer to do three things precisely – write code, blog and surf the web (mail, news, networking). Only the first one, writing code, is something I cannot do on the Chromebook and to be honest something I prefer not doing on my laptop either. The rest of my time I spend reading and writing on the web and I think Chromebook is suited perfectly for those tasks.

So although I am not going to throw away my desktop, I can surely see myself buying a Chromebook instead of a laptop the next time. Not having to learn another Control Panel layout1 and not having to view update messages from every software installed on my machine is reason enough !

1 – Why does Microsoft do that? Am I stupid or does Administrative Services like playing hide and seek?

Solving KenKen – ASP.NET hobby project

Were you bad at math in school? Did your childhood nightmares involve floating ÷ ? If so, your math teacher was unfortunately not Tetsuya Miyamoto.

Tetsuya Miyamoto, a very intelligent math teacher from Japan is the inventor of the logic puzzle KenKen1. Tetsuya believed in the art of teaching without teaching and learnt how not to scare his pupils away! KenKen which loosely means cleverness squared (ken X ken) is very much like Sudoku with the addition of simple mathematical rules.

I love KenKen and have been addicted to it for some time now. So early one morning I decided I’d write a computer program to solve it. At first I thought it was going to be a piece of cake. One day is all it would take. After all, how hard was it to find the list of numbers that multiply to twenty four? Turns out, it was; not hard but definitely tricky. Then again, which software project ever completed within estimates ;-)

I wrote the project in C# (ASP.NET) but I wonder if F# would have been a better choice given the mathematical nature of the problem. The lazy me, who didn’t want to learn another syntax sadly skipped this. Maybe I can write an F# program to solve Sudoku ?

My program is not exactly a computerized solution to KenKen. It moves one step at a time and mimics the way a human being (mostly me) would typically solve this puzzle. This also means that the success of this approach is limited by my ability to solve it. I personally have not been able to solve a 7 x 7 hard puzzle and hence, my program can’t solve it either (any help appreciated !). The solution also doesn’t use backtracking2 because although it is very easy for a computer, it is very hard for a human being after a certain level.

So, this is how the application looks. It has been deployed using AppHarbor3 and you can check it out over here (kenken.apphb.com).

This is what those numbers mean !

So check it out, have some fun and keep that brain running ;-)

  1. KenKen® is a registered trademark of Nextoy, LLC. Puzzle content ©2011 KenKen Puzzle LLC. (www.kenken.com)
  2. Backtracking is a common technique in computer science used for finding solutions to certain problems. In simple words, you guess a solution and then move forward. If your guess was invalid you wont be able to solve the problem correctly and you will discard this solution. You then backtrack, and guess again, till finally your guess is accurate!
  3. AppHarbor allows you to deploy your application on the web and was such a joy to use (appharbor.com)

.NET Vs Java – The F5 puppets

This is more of a rant than a useful discussion, so if you’re expecting the later go write yourself a Hello World ;-)

In 2002, for a class project I had the option of working with either Microsoft Foundation Classes (MFC) or Java. After having worked with Windows SDK in the last semester, the decision was clear. Anything that didn’t come from Microsoft was going to be OK. So I started reading this book – The Java Programming Language and that is when it happened. I fell in love with James. James Gosling that is. How funny, how intelligent, how brilliant this man might be I thought. If it wasn’t for my employer who made me write Java Server Pages (JSP), I might still have been in love. I’m not quite sure, but I guess it had something to do with the fact that my job involved staring at the “Null Pointer Exception” in the Apache command window for four hours a day, that brought my love story to an end.

In 2003, I was forced to move from Java to .NET. I wasn’t ready for the separation, but the HR lady would hear nothing of it. What did I expect? Human Resources and Programmers are a match made in hell. So there I was, staring reluctantly at my first .NET program. I pressed F5. Everything worked, I didn’t see a “Null Pointer Exception”. Wait a minute I thought, what about the web server? I don’t remember starting it, or installing it, or reading the ten page documentation on how to configure it. I cried. My life as a programmer was over. I was reduced to a Visual Studio puppet – my only task henceforth would be to click F5. I starred enviously at my friends who after two days of debugging had discovered that their program was crashing because they were using JDK 1.3.2 instead of JDK 1.3.1. Oh how I missed being a programmer.

I’ve missed being a programmer for the last seven years now, but I seemed to have survived the million F5s and the zillion “Microsoft Programmer” jokes ;-) Last weekend I started a little hobby project with my husband and a friend – both loyal to the sun, who of course sold their souls to the oracle. The project was to be in Java, no discussion needed there.

So I installed Eclipse. A Java editor that looked professional and was free. Was I falling in love again? Maybe. I then needed to install some Google plugins for our project – what hobby project is complete without involving Google? Ok, it didn’t work, it couldn’t find java. Ummm… why? Well turns out because Eclipse uses its own java compiler or something (don’t ask me!), as javac clearly didn’t exist on my machine. Interesting. So after installing Eclipse I install the JDK! Fine. Subversion crashes. Ummm… Why? Don’t know again – some clash apparently with the java version and the class paths. I found myself digging through the Environment Variables and looking for issues with the “path”. I’d forgotten all about “Environment Variables” in windows, I was hoping they were dead by now. Yikes. Anyway, after it was all sorted out I created some beautiful java classes only to eventually discover that I had the wrong version of Eclipse to write JSP files!

As you can tell, I am not a good java developer. I couldn’t even install the right version of Eclipse. I gave up, someone would have to write the JSP for me. Neither my husband nor my friend seemed too keen on writing that JSP – not sure why. My husband got stuck with it as my friend had a genuine reason, he was a “server side programmer” so he couldn’t be expected to write front end stuff. As a Microsoft developer, you do not have the liberty of making such statements. If you did, it wouldn’t be long before you heard – “Geez man, my 5 year old son can create an ASP.NET website – all you have to do is click F5 !”

Chrome Extensions and Privacy – I’m Scared !

Recently Google introduced Chrome Extensions which are little applications that let you do more with your Chrome browser. Like take this Google Dictionary extension which can tell you the meaning of any word on a website. All you have to do is double-click the word.

Super cool, isn’t it? You just need to Install the Google Dictionary extension and double-click words and meanings will pop up! After you excitedly click “Install”, you get this lovely confirmation box, where things start getting interesting.

All it wants is for you to confirm that this extension will have access to your data on all websites and your browsing history. A little scared? Worried about privacy? Don’t be, Google already knows everything there is to know about you.

Google with its “open” culture allows everyone to create extensions. Developers around the world have already created tons of extensions and people around the world have dutifully downloaded them. See this one from Yoono. It claims to be the most popular extension on Firefox. I should be able to trust it right? But for some reason when the warning pops-up, demanding I allow Yoono to access ALL my web information, I freeze. I just can’t do it.

I decided I will have to be satisfied with extensions developed by Google. We all trust Google. Google’s the good guy. So I decide to Install Speed Tracer.

An even better confirmation message pops up this time. Google now requests access to all data on your computer. Thats right, all my local computer data. The message gives me the creeps! So Google will know everything I do online AND offline. Why don’t they just send me to prison and get over with it!

May be I am orthodox, but the privacy around chrome extensions frightens me, it really does. Until Google can come up with a better privacy policy, I’m definitely going to keep my hands off chrome extensions.

[There is a positive side to this; the extension code is public, so you could in theory review the code. Now, who doesn’t love code reviews?]

Windows 7 and DNS Server woes

Problem !

When I moved into my apartment this weekend I was unable to connect to the internet which lead to emotions of utter disbelief followed by despair and finally by obsessive compulsion and irritability until fixed. Despite the best intentions of my operating system to automatically diagnose and correct the problem it couldn’t. Not holding any grudges, we all have our limitations. I was stuck with –

Windows can’t communicate with the device or resource (Primary DNS Server).

Solution !

I knew something was wrong with MY machine because by husband’s Macbook-Pro worked just fine. Damn. So here’s the deal, Windows 7 on Sony VAIO had set my DNS server to a static value. To make things work, I simply had to ask windows to obtain DNS server address automatically. Easy-peasy.

1. Select Start
2. Select Control Panel
3. Select Network and Internet
4. Select Network and Sharing Center
5. Select Change adapter settings (in the left corner)
6. Right-Click Local Area Connection and select Properties
7. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties
8. Under General select Obtain DNS server address automatically and click OK

When and why does this problem occur?

Technically I don’t know (Now I do, see update below!). But generally, the problem seems common on a Sony VAIO running Windows 7, especially if you switch between networks.

Is this solution permanent?

Apparently not! The behavior seems a bit erratic with the DNS server being reset to its static value randomly between standbys and resets. If that happens you can repeat the steps above or even try resetting the TCP/IP stack. With Windows, you never quite know the mood its in ;-)

[Update – an hour later] Understanding why this happens (technically) ! See below an as-is explanation by my friend Amit.

Step 0: The n/w is down
Step 1: You see some wlans
Step 2: You select one
Step 3: Your NIC ( n/w interface card) and the router get familiar, they authenticate
Step 4: Now the connection is established @ the “PHYSICAL LAYER”
Step 5: You now need IP to talk TCP & UDP, so send DHCP request
Step 6: Get response back from the router. It should contain among other things your MAC ( for verification), your new IP, your gateway address ( same as the router’s IP ) and DNS settings ( DNS server IP, search strings etc)

Thats it … your n/w should now be up. In your case, if the setting is disabled (Obtain DNS through DHCP) your machine will continue to use the static DNS that you have set and ignore the one given by your router.

Thanks Amit :) Life makes sense again!

Conclusion:If you want to enable DHCP on a Windows 7 machine, simply select “Obtain DNS server address automatically” in the TCP/IP settings as show above. Happy surfing!

Microsoft WebMatrix – a tool for the lazy?

Microsoft realized it was unfair that children and wives were unable to experience the joy of creating web applications. So last week they introduced a brand new shinny toy in the market – WebMatrix. Sadly, they forgot about toy-safety which any toy manufacturer will tell you is a cardinal sin.

If you want to know what WebMatrix is, you can check Scott Guthrie’s blog post here that explains it in detail. To sum it up, in Scott Gu’s very own words…

WebMatrix is a task-focused tool that is designed to make it really easy to get started with web development. It minimizes the number of concepts someone needs to learn in order to get simple things done, and includes and integrates all of the pieces necessary to quickly build Web sites.

In 2003 when ASP.NET joined web development, it was great. There was nothing like it in the market that let you create web applications so easily. You didn’t exactly have to understand how the internet worked, you didn’t have to worry about POST or GET verbs, because when ViewState, Event Handlers and Page_Load got together all you had to do was party! Unfortunately, because the entry constraints were so low, some not-so-good developers joined the scene creating some not-so-good applications that resulted in not-so-good user experiences. But the party still went on, as there was a community of very good ASP.NET developers always ready to help. Not only did they provide answers to problems, but they also developed long term solutions and methodologies like TDD, SoC that would help you create beautiful and maintainable applications.

In Scott Gu’s post on WebMatrix, he lists an example where database, business logic and user interface code all sit hand in hand on the same page. Click here for a snapshot. A decade of web development has taught us one thing – not to write such code. Numerous tools and technologies, Microsoft’s very own ASP.NET MVC prevent us from doing so. Why then would we want to teach a failing technique to a bunch of fresh minds?

Just because a child cannot fully grasp the idea behind gravity does not mean we teach children the earth is flat.

I like the idea, to be able to create web applications without knowing everything there is to know. Visual Studio can be daunting and overwhelming and a simpler tool for the beginner is a great idea. However, since the users is naive, the onus lies on the product manufacturer (in this case Microsoft) to help you create a good product.

There should be no way to write the example code shown. A tool like WebMatrix should force constraints and restrict users from creating such a mess. Maybe a user might not understand why he is forced to write database code in one file and user interface code in another. He might even find it an inconvenience. But you the manufacturer know what is good for this child-developer. It is for the developers of WebMatrix and not its users to identify pitfalls and force constrains around them. This might reduce flexibility, but wan’t this tool meant for simple applications in the first place?

I’m still not sure who WebMatrix is for. Microsoft says it is not for professional web developers. So is it then for people who can write SQL queries, learn Razor (MS’s new MVC view engine), understand open source projects like BlogEngine.Net, purchase web domains and hosting, but simply cannot take the effort to create good applications, even if it was for their own good? The word that comes to mind is Lazy.

Version Control: Do you need both TortoiseSVN and Subversion?

Installing a version control system for my local machine left me confused. Did I need Subversion and TortoiseSVN? If TortoiseSVN is only a “client” can it work without Subversion? If it can’t, why does TortoiseSVN allow me to create repositories without me having installed Subversion yet?

After having wasted a day googling, good sense prevailed and I mustered the courage to go through the FAQ (which thankfully is very clear and to the point). And voila!

So what did I learn? If you want a version control system for your local files and folders you only have to install TortoiseSVN. It has everything you need for creating local repositories on your hard drive, which can be accessed via file:///C:/YourProject. In this case the working folder (the ones you check-out & check-in) and the local repository (where version control data resides) are on the same machine – your personal computer.

Version Control for Local files & folders for a single user => TortoiseSVN

If however you need a version control system that would be accessed by a small team (of 2 or more users) you also need Subversion. Subversion is a source control “server” which allow multiple users and machines over a network to access the central shared repository in a safe and consistent manner. Your repository is now on a server. When using Subversion, you access your files via svn://server-ip/YourProject (or svn://localhost/YourProject if the server is running on your local machine). Subversion can be used via the command line, however TortoiseSVN for Windows provides a wonderful GUI that integrates with Windows Explorer.

Version Control for shared data over Network (multiple users) => Subversion (source control server) + TortoiseSVN (on each client machine)

You can avoid installing Subversion (server) by placing your local repository on a network drive (accessed via file:///server/sharedfolder/YourProject). This is however not a recommended approach (read FAQ or see the Mind Map below for ‘why’).

Do you need both TortoiseSVN AND Subversion

Mind Map: Explains if you need both TortoiseSVN and Subversion
Personally, only after I had installed and setup Subversion did I realize I didn’t need it. Oh well, I’m going to use it anyway! Feels cool :-o

ASP.NET MVC – The ‘Hello, World!’ Mind Map

Update [19th July 2010]: I’ve uploaded the mind map on MindMeister here. This should allow you to download and view the mind map in any format you wish.

Mind Map 2: A mind map to understand your first ASP.NET MVC Application

For an introduction to ASP.NET MVC you can find my first Mind Map here.

Summarized View- Quick glance
Mind Map: Understanding your first ASP.NET MVC application (summarized view)

Mind Map: Hello World in ASP.NET MVC (summarized view)

Detailed Mind Map – Click image to load full size readable Mind Map
Mind Map: Hello World in ASP.NET MVC (detailed view)

Mind Map: Hello World in ASP.NET MVC (detailed view)

My iPod crashed after iOS 4 iPhone update !

Today the iPod app on my iPhone 3GS crashed along with my belief that Apple was invincible.

When my friend Biswa told me about the new OS release I couldn’t wait to get my hands on it. All seemed well before I developed the urge to listen to KT Tunstall! No sooner had the album downloaded, iPod started acting up. The iPod app refused to stay alive for more than 5 seconds. Playing a track either caused iPod to shut down abruptly or hang the application. Being an Apple fan, I was sure this was only a minor glitch and an iPhone restart was sure to solve the problem. It didn’t. And neither did the three re-starts that followed.

I finally Googled the Apple Support pages to find that I was not alone. Someone out there had fixed the problem by doing a re-sync. This did the trick for me too! Phew! I can only hope the bug doesn’t pop up each time I download a new track!

Problem: iOS 4 update on iPhone 3GS causes iPod to crash after you download a new track via iTunes.
Solution: Re-sync your Music library.

Makes me wonder, is there such a thing as software without bugs?