Friday, April 24, 2015

Kivy on Mac

I started to explore Kivy on mac.  Its a python based UI developement tool.  It looks cool.  You can develop Mobile, Desktop and cross platform UI using this tool.  For anyone struggling to install it on mac.  Instructions look simple on their site but has missed a small note.  I googled and finally found the fix.

1.  Install Kivy from DMG
2.  script file needs a soft link created under /usr/local/bin
3.  You may need use sudo with the below command based on your setup.
ln -s /Applications/Kivy.app/Contents/Resources/script /usr/local/bin/kiv
Once this is done, you will just run any examples under  /Applications/Kivy.app/Contents/Resources/examples folder 

cd to the folder and type kivy main.py (in mycase main.py was the file i was running)


Friday, March 6, 2015

Java to Objective-C journey (J2OBJC to convert apache commons math3)

There are so many opensource java libraries that we use to develop applicaitons.  Recently, I had a need to use Apache Commons Math library.  There are phenomenal things this library can do for you.  Similarly, there may be some of these functions you wish were available for iOS.  Good Luck finding them.  Atleast, I was'nt successful.  I decided to port one of the apache commons library for my iOS needs.  It turns out that it's not so simple and too much hard work.  That's when I came across J2OBJC project.

You can find out more details on www.j2objc.org 

j2objc google group - Fantastic group of people like Tom Ball and others help you succeed with your projects.  Of course, you need to know what you are doing and not expect them to do things for you.  If you understand how to setup a project and are having issues, these guys are saviors.

 https://groups.google.com/forum/#!forum/j2objc-discuss

Please note that j2objc does not convert UI code.  It is mainly meant to convert business logic or calculation that was written in Java.

I have started converting Apache Commons Math3 or Math4 library.  I will keep my progress posted if anyone is interested.  So far, I have found that there are not very good tutorials for this.  But I was able to convert all the java files to objective-c.

Update 10/28

I have to choose a few paths to use j2objc.

Path I - Eclipse Plugin - It was not very hard to find the link to the plugin on the j2objc.org website.  Install was easy, very simple documentation.

http://j2objc.org/docs/Using-J2ObjC-with-Eclipse.html

However, to convert a large project like Apache commons math.  I could not use this plugin.  I could use it for smaller projects that do not have conflicting named files within other packages.  If you have a small library in java you want to convert to iOS, this is they for you,  If you are under taking anything big like the one i have picked, go to Path II.

Path II - Gradle -  If you have not used gradle before, I would suggest you to take a look at it.  This was the first time I interacted with gradle.  I love it.  Guys at google have built a j2objc plugin for gradle.   This will not only translate code, it will pull the sources from maven repo if needed.  Build automation at its best and simple.

Gradle j2objc plugin -- https://github.com/j2objc-contrib/j2objc-gradle

If you can follow other projects fun part begins, there is a end to end test for some common libraries in place.  Here is the location.

https://github.com/j2objc-contrib/j2objc-common-libs-e2e-test

When i started to write this post, there was no apache commons math3 in the e2e repo.  Now Advay and Bruno have created one.  However, these instructions below will help you if you are working on a different library.  Enjoy

Here are some steps

1.  Clone the e2e project.  git clone https://github.com/j2objc-contrib/j2objc-common-libs-e2e-test.git

2. Run prep.sh.  This downloads the required j2objc suite.

3.  Run run-all.sh or you can run ./run-test.sh org.apache.commons-commons-math3 to build commons math3

4.  This will invoke Gradle to download the sources from maven, compile java code, translate using j2objc, compile objctive-c code and package it for you.

This is awesome.  I used the apache commons lang3 as example to setup the commons math 3.  In my case, I had apache commons math 3 had translation errors.  Still working on fixing those.

I have configured Gradle to look into my local folder for source code instead of pulling from maven as i have to remove files to get rid of dependencies that are not covered like awt.geom etc.

Note: Observe the build.grade in the sub folder "org.apache.commons-commons-math3".  It has few new interesting things.  One is the compile argument and other is to exclude several files that will not translate.  All the work has been done.

!!!!!!!!SUCCESS!!!!!!!!

Issues (mostly user based)
1.  After removing several files due to dependencies that i cannot migrate.  I did not need them either.  I was stuck at compilation with several errors mentioned in this thread

https://groups.google.com/forum/#!topic/j2objc-discuss/chyYqJr_whM

I needed to tweak gradle task to include the compiler argument

2.  Some strange reason, i needed to change the name of my library to shorten it.  Still trying to figure that one.

3.  Using the compiled static library was not hard, but I did not read all of Tom's documentation.  I made it hard on myself.  You need several dependencies listed here

http://j2objc.org/docs/Xcode-Build-Rules.html


If you are still have questions, leave me a note.  Eventually, I plan to create a github project.




Tuesday, April 1, 2014

Multi OS boot for Raspberry Pi


The hard disk drive for the Raspberry Pi is the SD card.  There are many ways to put an OS (operating system) image on the SD card.  I usually prefer to boot my raspberry pi with options to switch different OS. Instead of assigning a new SD card for a OS, I would like to put a few of them on one SD card.

Berry Boot - It has been out there the longest.  It's very easy to install new operating systems on your Pi. You can chose one OS as your default and others will be displayed booting.  Berry Boot site has more instruction on how to install it.
http://www.berryterminal.com/doku.php/berryboot


NOOBS - New Out Of the Box Software - Pi foundation with the authors of Berry Boot put together NOOBS.   It is very similar to Berry Boot for the user, internal implementations have a few changes.  You can download NOOBS from here http://www.raspberrypi.org/downloads.  I found the install tutorials here to be useful https://github.com/raspberrypi/noobs

Berry Boot is my choice of OS loader.  As you learn Linux and choices of OS, you will want to try new OS on the Pi.   NOOBS or Berry Boot's offers a lot of operating systems to choose from.  If you ever want to install an OS that is not listed on either, both loaders will allow you to install it from the image.  Its not very easy for a beginner, but its not too hard.  There is some complexities involved.  You will need to learn some Linux commands to navigate yourself.

How to install custom OS on Berry Boot -  I installed pwnpi from pwnpi.net (penetration testing tool).  You can learn a ton about web security wired or wireless using this. Here is an awesome tutorial to add and boot a custom OS downloaded (not included in berryboot list of OS)



How to install custom OS on NOOBS - I have not used NOOBS, but know of a few folks who did.  It also involves some complexities. Here is the link to that https://github.com/raspberrypi/noobs .  Just scroll down till you find the advanced usage section.

Enjoy your Pi.  Feel free to shoot any questions.

Monday, March 31, 2014

Raspberry Pi - $35 Wonder


Raspberry Pi - $35 wonder



I came across this gadget over a year ago.  You will find the descriptions of this wonderful gadget all over the web.  There are tons of youtube channels like https://www.youtube.com/user/RaspberryPiBeginners that will show you possibilities of this device.

Total Cost :- $60 approx.

  1. Raspberry Pi - $35
  2. Power Source  - $5 - eBay  (Android Phone Charger will do)
  3. SD Card (2Gb) - $5 - eBay (Any camera one will do)
  4. HDMI or RGA cable - $10 on Amazon 
  5. USB Keyboard & Mouse - $5 - eBay (use one lying around from your computer)


It is not a replacement for your laptop or home PC.  What is all this hype about Raspberry Pi?  The device was mainly built for kids to learn programming in parts of the world where they could not afford a expensive computer.  Powerful applications are possible using this small little wonder gadget.  I built a few things listed below,


  • GPIO Ports -   Raspberry Pi provides you access to control external devices connected to it.  This means you can control a light bulb, garage door, video camera, quad coptor, r/c car and so many more.  I played around building a remote garage door opener.

  • Media Center - Stream HD quality movies online directly into your TV.  Yes! Chromecast can do the same.  Stream videos from your iPad, iPhone or iPod directly into your TV without wires. Yes, chromecast can do that too.  You can watch almost anything that plays on your comptuer on the Pi.  Use either of the following 

  • Linux Desktop - There are several images out there that you can install on your Pi.  Rasbian Wheezy is a simple light weight desktop and official choice of Raspberry Pi foundation.  I used this one.  Using linux you can build limitless things.  Some I built are,
    • Scratch - Visual programming for Kids.  Built by MIT
    • Web Server - To serve webpages
    • Live web camera stream - Stream live video
    • Time Lapse (stop motion) videos
    • Home Automation 
    • Node JS server - Harness the power of Node JS.  Create simple webservices.


Over next few weeks and months, I will put my pet projects on Raspberry Pi here.    Feel free to comment or ask questions if I may help.

Friday, September 21, 2012

Building my own SIRI

I was working on a mobile app for both android and iOS using titanium.  Found two interesting things.  Apple does not allow developer community access to SIRI and my phones do not have SIRI (iPhone 4).  But I want my app to be voice enabled.  How can I do this ?  Is this even possible?

Answer is Yes.  its possible.  Here is my approach.  If there is any interest I can share the code.

My requirement:

  1. App should be able to talk to user
  2. User should be able to respond specific commands by voice.
  3. App should be able to respond with action or error voice.


In my case i want get the user input via Voice like numbers.

Voice Synthesis (Talk your text to user)

  • I wanted the app to ask the user for inputs. Keeping it dynamic.
  • I used google to synthesize the voice
    • http://translate.google.com/translate_tts?tl=en&q=text”
    • You send the question in text field of the above url, you will recieve a wav file back.
  • Use Ti.Media to play back the way file. Note: Ti.Media does not work for android.  Need to use third party module.

Voice Recognition

  • Use Ti.Media to get the input from speaker from user.  Note:  Android will have to use a thrid party module.
  • Record the wav file.  I recorded it as 8KHz file to keep the wav file small.
  • Send to to a conversion service online.  There are many services available online to accomplish this task.
  • I used this site http://api.ispeech.org/api/json which converts the voice to text.

Error Handling

  • When the text is returned from recognition call.  My call back will analyse if the data recieved is relevent.  There is confidence level also returned.  Based on confidence level and data recieved, I make decision to use the text or play back a custom error message.
  • For example:  I ask to enter numbers.  The translated text has alpha, then i play back a message that i expected only numbers.
Observation was that over 3G the recognition service was slow.  On LTE and WiFi it worked almost like SIRI.  But I used a non paid service.  Using google translate and voice you can have the app speak different languages too.  I tried using the codebox module for android got stuck, now am writing my own.

Any thoughts welcome.

Tuesday, September 18, 2012

Innovation Buzz

There is a lot of buzz these days about innovation.  Everyone wants to innovate.  Everyone wants a piece of it.  How can we be Innovators ?  I saw Pranav Mistry's Sixth Sense project video a while ago.  It was an out of the box thought.  But if you looked closely, Pranav used what was at his disposal and gave life to an idea of gesture based system.  Sometimes we forget that innovation is not always the next FaceBook or Apple. We forget that assembling what is available for a different purpose is also innovation.

I attended a session on Medici Effect by Frans Johansson a while ago.   It was an awesome experience. Frans was mainly talking about finding intersection.  Intersection of different thoughts of life.  Frans was telling all of us, it's about the number of ideas you have.  More the ideas,  better the outcome.  Some ideas will die and some will make more sense to move forward.  If you have not read Medici Effect by Frans, I would highly recommend it.




Tuesday, September 4, 2012

Mobile App development tutorial

Titanium Development

Here are some links that were quite helpful.

Drilldown navigation tutorial
http://mobile.tutsplus.com/tutorials/appcelerator/drilldown-navigation-with-titanium/

SQL Lite - Database driven tables
http://mobile.tutsplus.com/tutorials/appcelerator/titanium-mobile-database-driven-tables-with-sqlite/

Videos on tips and tricks of Titanium
http://vimeopro.com/appcelerator/forging-titanium

Charts in Titanium - Raphael JS, D3JS
http://boydlee.com/appcelerator-titanium/creating-charts-for-titanium-using-raphael-js.html

I have been able to use d3 successfully.

Tip: Ensure you rename the other java libraries to .lib instead of .js

let me know if you have any specific issues you need some advice on.

Funding your ideas

Well,  all of us are passionate about our ideas and thoughts.  One of us could have the idea for the next face book or google.  But, how can we take our idea further into making a tangible product or prototype ?  Now comes lots of questions.

Is it just funding my idea ?  What about the skill set that i need to get it accomplished ?  What about infrastructure ?  Hmmmm as I start thinking the list grows.   As am passionate about my ideas,  I dont want to let them die just yet.

Here is what i will do.  Make a list of what it takes and put a price tag around it.  Now I know tentatively what i need and money i need to raise.  Get ready to market the idea.

Create a power point presentation  
1.  Why my idea ?
2.  What does it do ?
3.  Why should you buy it ?
4.  Does it solve world peace ?  I guess not.

Create a 3 minute video about your idea and include a proto type if there is one.  We have a way to showcase it to the rest of the world.


Crowd source the funding for your project.  Create different tiers of support for your sourcing.  No amount is small amount.  Do not think $1 is small.  Ocean was created with droplets of water.  Have a strategy for these tiers.  Here is a sample.

$1 Tier -   Will get a Thank You note
$5 Tier -   Will get your name as bronze sponsor on our site
$15 Tier - Will give you a T-Shirt with our logo
$25 Tier -  Will get the app this idea is all about for free without any ads along with support and free updates
$50 Tier  - You get the idea.

Go to http://www.kickstarter.com/  and create your kickstarter.


All the best.

Monday, September 3, 2012

Mobile development Native vs Webcontainer vs hosted

I got my hands around developing a few mobile apps.  I will put my thoughts here.  It all depends what you plan to do.  What features do you need for your app?  The last one I worked on needed OCR (image recognition).  I was developing for both iPhone and android.

When you need to access the hardware, hands down native offers lot of tools. Titanium has ways to plugin native libraries into th app.  I did try both native and titanium.  I am happy camper for both of those.   But phone gap surprised me as well,  I found a way to write plugin for native libraries using phone gap.  My only soap box on phone gap is, I don't like performance of JQ touch yet.  The is lot of room for improvement.  

If your app is a simple one,  that uses simple device features like camera and geo location.  You could do with a webcontainer (Phone Gap + JQTouch/Sencha Touch).    But, I still have not found a web library (open source ) that does good job for UI.  Sencha touch does a good job for web container UI but, it's not free.  It's gpl v3 license.  Sencha touch costs about $199 for now.  Not too bad.  Combination of Sencha Touch, HTML5 and Phone Gap could give you a decent mobile app.

Hosted apps, for now are too slow.  With bandwidth becoming premium,  I'd stic to native for UI and hosted svcs for data.  REST based services to retrieve data from server. 

So for now, am sticking with free version of Titanium.  The main reason being, that i can develop both Android and iPhone apps from the same code base.  However, their supported version costs an atrocious $7500 which is too heavy for an entry developer.  Adobe's flash builder is also capable of delivering native apps.  My next task is to take a look at flash ( I know flash is dying).

BTW,  Phone Gap is now owned by Adobe.  Adobe donates Flash to apache open source foundation.  

Please share your thoughts.

Thursday, October 27, 2011

Mobile Application Development

Quest of developing mobile phones got to me as well. With 140,000 application in the Apple appstore and similar number of apps in android store, I was fascinated to realize that sooner or later our phones will be the most powerful device that we will own.

I started in this journey to develop my first application on a iOS or android device. Being a developer already with 17 years of development experience under by belt made me wonder, do i learn a new programming language another platform. How do i go about developing new application for these new devices.

Here is the infrastructure needed to develop for these devices

iOS
  1. Need a MAC computer with OSX (Snow Leopard or Lion) . -- Cost $800 - $1200 approx.
  2. Registration to the Apple developer program -- Cost $99/year
Android
  1. PC with atleast 4 Gb or RAM (2Gb works will be too slow) -- Cost $300 - $800
  2. Operating system is more flexible here. Any Java compatible OS (windows, Linux, OSX, Ubuntu, Solaris, etc.)
  3. Registration to Android market

That costs a ton of money if i want to develop applications in both iOS and Android. For someone with serious product vision and ROI planning, this amount may seem miniscule. But for a hobby developer who is starting from scratch it costs a ton. Dont get disappointed just yet. There are other ways you can go about this.

Introducing Hackintosh
You could use a PC dual boot it to have Windows 7 or XP on one partition and MAC on the other. Although, according to Apple it is not legal to install OSX on non Apple hardware.

More Options
If you possess a intel based PC and the processor is capable of VT (virtual technology). You will not need to install OSX instead run it using VMWare or Virtual Box.

Tools
Traditionally for iOS development, programmers would need to use XCode and program using objective-C. Another new language to learn and adopt.

Android developers need to know Java (which is quite common) and use Eclipse IDE along with Android tool kit.

New Tools (Popular ones)

Titanium - Appcelerator - Javascript based development platform. Javascript being one of the widely used web development scripting language. Titanium API are integrated into well known Aptana IDE. Titanium based application provides native look for the application.

Requires: iOS SDK for iOS development, andriod SDK for android development.
Website: www.appcelerator.com
Cost : Free, starting from $49/month and more


Phone Gap - Javascript based library. Can be used used on OSX along with XCode and Eclipse on PC. Phone Gap library can be used to develop application on various platforms eg:- iOS, Android, Palm, Symbion, Web OS. One draw back on Phone Gap is the apps developed do not have a native look.

Requires: iOS SDK for iOS development, andriod SDK for android development.
Website: www.phonegap.com
Cost : Free


More to come on tools, tips, tricks and samples