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.