Tuesday, February 9, 2016

push plugin V5, ngCordova, Ionic Framework usage and example

Phonegap Push Plugin, ngCordova pushV5, Ionic Framework

Example and usage

Currently there are two different Cordova PushPlugin's available, one is now deprecated.

Both have support in ngCordova, one is supported as $cordovaPush (the depreceated one) and the new one is supported as $cordovaPushV5 (the new one). The documentation of the new push_v5 ngCordova is very limited and you need to go into quite some details in order to get it working. As well you need probably to work with the dev-next version of ngCordova (or browse the related tags in github).




Monday, April 6, 2015

Apache Cayenne, Tomcat, Wicket and CXF together on docker and shippable

Yafra provides since Apache Cayenne 2.x an example of how Apache Cayenne can be used within some J2EE tools.

Till now it was always time consuming to build a running example which can be reproduced quickly by anyone else. But with services like Docker and Shippable it changed.

Shippable is an internet service which allows you to automate the build. With public repositories like a github repository it is free of charge. Every time you push changes to your github repository it will trigger a build on Shippable. The Shippable build makes use of the maven setup. Of course you can build it as well on your local desktop. The build includes as well unit tests and code coverage reports. Shippable uses docker for the build process which makes it very nice to combine with your own dockers.

Docker is a kind of virtual operating system, but not like a full VM, it re uses existing linux resources. Installation of docker is simple and getting a new image is as simple as executing docker pull xxxx. Docker makes use of the Linux Namespace feature. I personally see this development as replacement of existing VM technologies which still have too much overhead. Of course it restricts you on linux, however for yafra there is no dependency on an operating system, all applications/examples run on every operating system.

The Yafra Java examples makes use of relational databases (MySQL and Derby are used but other can easily be enabled). It provides a HTML client created with Apache Wicket. It provides EJB3 services using Apache OpenEJB/Tomee. It offers as well Web Services and RESTful API through Apache CXF.

A fat client exists using Eclipse RCP and EJB3, however this was archived and I'm doing a rewrite with an Eclipse RCP e4 client using RESTful API. Currently the RCP client has no network access to the RESTful server, however it runs and can be build with maven and tycho.

The full example shows how easy it is to work with Cayenne and still having a very readable code.

Follow the quick install on the Yafra Wiki to get it up and running with docker and see how things are working. The idea is to get a full example which runs and which you can apply to start up your own application.

Yafra Wiki: https://github.com/yafraorg/yafra/wiki

Yafra Quick Start: https://github.com/yafraorg/yafra/wiki/Quick-Start-Java

Yafra Projects: https://github.com/yafraorg/yafra/wiki/Projects

Sunday, June 1, 2014

Eclipse RCP application based on e4

Finally I got the build process clean and running to produce a headless eclipse based RCP application, including e4 support. Maven and Tycho is the key to a successful build and packaging process. A clear setup of plugins, features, product and a master pom within a build project makes the whole process clean and simple.

Beside the standard approach to sync and add all dependencies, make sure you have the org.eclipse.equinox.simpleconfigurator dependency added to your product definition file!

The maven tycho generates a full standalone product for all platform (win, linux, osx).

Check out the example provided by yafra.org on github.com https://github.com/yafraorg/yafra/tree/master/org.yafra.rcpbuild
The pom.xml file on rcpbuild shows all other related components used for this example.

Sunday, February 2, 2014

Photo orientation handling in google appengine with python

After realising that not all photos uploaded are correctly handled in regard to orientation the search started. After some hours I got the solution. First of all this happens only on PNG pictures uploaded by phonegap camera plugin on iOS. A work around would be parsing the meta data of an image uploaded to google appengine. If you use phonegap camera plugin with encoding JPEG there is no issue (and even much faster).

It occurred with my iPhone with PNG as phonegap camera encoding type and Apple uses the Orientation meta data tag, it seems the following values give guidance on how to rotate your uploaded image before you save.

This applies only to images saved in the datastore db.Blob, NOT the blobstore ! In blobstore you have no influence during the upload and the blobstore handles the orientation correctly.

The following post supported my solution:
http://lkubaski.wordpress.com/2013/01/18/rotating-photos-from-mobile-devices-uploaded-to-google-app-engine/

This posts lists the iOS orientation values used:

1: image is Normal-> that’s the orientation value you get when the iphone home button is on the right
2: image is flipped horizontally
3: image is rotated 180° -> that’s the orientation value you get when the iphone home button is on the left
4: image is flipped vertically
5: image is rotated 90° CCW and flipped vertically
6: image is rotated 90° CW 
7: image is rotated 90° CW and flipped vertically
8: image is rotated 90° CCW 

How to rotate the image
orientation = 1 -> don’t rotate
orientation = 3 -> rotate 180° clockwise
orientation = 6 -> rotate 90° clockwise
orientation = 8 -> rotate -90° clockwise (or 90° counter clockwise if you prefer)

The sample code (python google appengine):

obj = YourDBObj()
img = images.Image(raw_file)
img.resize(140)
save = img.execute_transforms(output_encoding=images.PNG, parse_source_metadata=True)
meta_data = img.get_original_metadata()
  if meta_data != None:
      logging.info('debug: meta data nach image %s', meta_data)
      if meta_data.get("Orientation"):
          logging.info('debug: meta data Orientation found %s', meta_data["Orientation"])
          if meta_data.get("Orientation") == 6:
              logging.info('debug: rotate image by 90')
              img.rotate(90)
              save = img.execute_transforms(output_encoding=images.PNG, parse_source_metadata=True)
      else:
          logging.info('debug: no orientation')
obj.pict = db.Blob(save)
obj.put()
For blogstore objects using the image get_serving_url() you could do rotation by adding -r90 as of an undocumented feature: https://code.google.com/p/googleappengine/issues/detail?id=4200

Thursday, January 2, 2014

iPhone / Android App

My first app. What a painful experience. Intention was to write an app which will run on all major mobile devices.

Starting with Accelerator showed quickly some drawbacks and the learning experience was not pleasant.

Next was PhoneGap based on Apache Cordova. Much better and getting an app running was quite simple. I chose the ionicframework and AnuglarJS as key frameworks to work with. ionic is similar to bootstrap and AngularJS is a MVC based javascript framework. I made an app talking to a google appengine service through RESTful API. And really write once run on all major platforms!

Google Appengine

Very mature application web server engine. I made some examples using python with functionalities like excel export, pdf creation, openid authentication, RESTful service, database design (big table based). Overall an excellent approach to develop web services very fast and being prepared for mass usage if you like.

Unfortunately the authentication seams to be still very beta. It supports only OpenID but OpenID Connect would be much better as this supports oauth1/2 and OpenID.

The google cloud console is still very early but shows the direction it will go to.

Chromebook and Chromecast

My Chromebook (HP Chromebook 14) / Chromecast experience quickly summarized. For what do I need it? I needed a laptop with HDMI, USB and SD Card interfaces, plus Wlan and Bluetooth. I'm always online, I have a google account and I mainly want to surf the internet. And guess what, the google chromebook just fits this needs 100%! With chromecast you can mirror tabs onto your HDMI TV. The chromebook can manage and r/w all kind of USB disc devices (can read all filesystem formats FAT, NTFS, ext3, ...). You can attach a printer to USB and enable it with the Google Cloud Print (not all are supported but the most commons are). If you have a printer with WLAN it's even easier. You have access to all Chrome Apps and Extensions. This includes remote desktop server functions, office and many other gadgets. Some Apps or Extensions are even offline capable, meaning that you can work without any WLAN connection and sync as soon as you are online.

As with iPad's you have some shortcuts with file formats like the RealPlayer RA format. However there are workarounds on the net, just google.

Overall a very nice laptop, basic functions but easy to handle and use and focused on what you do very often, surfing on the internet. Low price makes it an interesting alternative for tablets or full blown laptops, but always with the intention of surfing on the internet in mind.