Phonegap and QR decoding on iOS

November 22nd, 2012

 

The last month i am working on a project that should be deployed in various mobile platforms. Unfortunately, my programming knowledge is limited to android-java and the ancient windows mobile platform. However, the specific project demands the development of one application for 3 different mobile platforms (android, ios and windows phone). Instead of coding the application for each of these mobile platforms, i chose to code it once by using phonegap and HTML5-javascript.

I was searching for a decent phonegap QR javascript plugin and finally i found this one. I decided to give it a try but despite the thorough explanations of the readme file i couldn’t make it run. After some research i’ve on stackoverflow i ended up with the following corrections:

var BarcodeScanner = function(){};

BarcodeScanner.prototype.isBarcodeScannerAvailable = function(response){
    cordova.exec(response, null, "BarcodeScannerPlugin", "isBarcodeScannerAvailable", []);
};

BarcodeScanner.prototype.isBarcodeScannerSetup = function(response){
    cordova.exec(response, null, "BarcodeScannerPlugin", "isBarcodeScannerSetup", []);
};

//-------------------------------------------------------------------
BarcodeScanner.Encode = {
TEXT_TYPE:     "TEXT_TYPE",
EMAIL_TYPE:    "EMAIL_TYPE",
PHONE_TYPE:    "PHONE_TYPE",
SMS_TYPE:      "SMS_TYPE",
CONTACT_TYPE:  "CONTACT_TYPE",
LOCATION_TYPE: "LOCATION_TYPE"
}

//-------------------------------------------------------------------
BarcodeScanner.prototype.scan = function(success, fail, options) {
    function successWrapper(result) {
        result.cancelled = (result.cancelled == 1)
        success.call(null, result)
    }

    if (!fail) { fail = function() {}}

    if (typeof fail != "function")  {
        console.log("BarcodeScanner.scan failure: failure parameter not a function")
        return
    }

    if (typeof success != "function") {
        fail("success callback parameter must be a function")
        return
    }

    if ( null == options )
        options = []

        return PhoneGap.exec(successWrapper, fail, "com.cordova.barcodeScanner", "scan", options)
        }

//-------------------------------------------------------------------
BarcodeScanner.prototype.encode = function(type, data, success, fail, options) {
    if (!fail) { fail = function() {}}

    if (typeof fail != "function")  {
        console.log("BarcodeScanner.scan failure: failure parameter not a function")
        return
    }

    if (typeof success != "function") {
        fail("success callback parameter must be a function")
        return
    }

    return PhoneGap.exec(success, fail, "com.cordova.barcodeScanner", "encode", [{type: type, data: data, options: options}])
}

cordova.addConstructor(function() {

                       /* shim to work in 1.5 and 1.6  */
                       if (!window.Cordova) {
                       window.Cordova = cordova;
                       };

                       if(!window.plugins) window.plugins = {};
                       window.plugins.barcodeScanner = new BarcodeScanner();
                       });

It is important to be mentioned that i used phonegap 1.9 and xcode 4.5.2 for the development of the QR decoder. Finally i used the plugin presented in the iOS plugin directory of phonegap-plugins and not the one contained in the iPhone folder.

Posted in Uncategorized | Comments (0)

Symfony2-Part1

June 18th, 2012

Here we are going to talk about bundles which are a core element of symfony2 framework. Bundle is a module that contains a unique package of code. This can be php code and the corresponding javascript code. Talking with examples, it is a chunk of code that implements a specific functionality. e.g a forum, a login system, a template system or a slideshow. By using symfony2 you agree with the fact that your program is going to be modularised into such code chunks that have certain functionality. This is a great property which improves the organisation of your program, gives you the right to share bundles so that other programmers can use them or support the extensibility of your application.

Enough with the theory, let’s move to the practical side of this tutorial. In symfony2, every new application starts with a bundle creation. This bundle should be registered in app/AppKernel.php file and it should have its own folder as well. To ease our life, this lovely framework has a built-in console tool that does the hard work for us. By executing the following command (you should execute this command while you are in the Symfony folder) all the previous actions are automatically executed. So here is the command:

php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml

Each bundle, normally, represents a specific page of our application. Each page consists of 3 basic components: Route, Controller, Template.
The route component clarifies the url of the page. e.g /app/hello so that anytime a user enters a url, our app knows what page the current user requests. A controller is called everytime a user requests  a specific url. For example a user enters the url www.foo.com/app/hello in his browser. The symfony2 checks the existence of the certain url and afterwards connects it with a specific controller. In essence, the controller contains the code that is going to be executed while the user enters a specific url. Finally the last component (template) contains the visual representation of this page!

Let’s start by building the Routing:

The default place where routing information exist is in the app/config/routing.yml file. if you check this field, surprisingly you’ll find that symfony2 has added information about the bundle you just created. Basically, the information you just saw says to Symfony to load routing information from the Resources/config/routing.yml file that lives inside the AcmeHelloBundle where is located at src/Acme/HelloBundle folder. Summarising the routing information are retrieved from the src/Acme/HelloBundle/Resources/config/routing.yml file. Move to this file and observe that there are two properties: pattern and defaults. The first one contains the url of this bundle and the second one links this url to a controller.

Let’s continue by building the Controller:

From the previous step, we saw in the file src\Acme\HelloBundle\Resources\config\routing.yml that our contoller was this –> AcmeHelloBundle:Hello:index. This controller links the url to a function called indexAction and is contained in the class Acme\HelloBundle\Controller\Hello. We firstly create this class and the corresponding contoller

namespace Acme\HelloBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
class HelloController
{
  public function indexAction($name)
  {
    return new Response('[html][body]Hello '.$name.'![/body][/html]');
  }
}

DON’T FORGET TO REPLACE [ with < and [ with > .

As you may see, inserting html tags into your code is not neat at all so that’s why why use the robust template features that symfony2 provides.

More specifically instead of writing the above code we could use

namespace Acme\HelloBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
class HelloController extends Controller
{
  public function indexAction($name)
  {
    return $this->render('AcmeHelloBundle:Hello:index.html.twig', array('name'=>$name));
  }
}

Note here that our class is extended from Controller class.

Our controller renders the AcmeHelloBundle:Hello:index.html.twig template that uses the following convention –> BundleName:ControllerName:TemplateName.

This is the logical name of the template which is mapped to the following physical location –> /BundleName/Resources/views/ControllerName/TemplateName.

Posted in Coding | Comments (0)

Symfony2

June 18th, 2012

Being unemployed means that you have plenty of time to play around with many technologies! I should admit that because i do not have a specific project to do, it makes me more keen to learn new frameworks or different programming languages than using those that i already know to start new projects. It was only when i was discussing a project idea with a friend of mine when we determined to start programming this idea directly. He knows very well symfony2 which is an MVC php framework and as a result we ended up by agreeing that i should learn the same framework so that we could collaborate. This post is the beginning of a series of posts in which i’ll describe step by step the symfony2 framework! Stay tuned and send me your opinion!

Posted in Coding | Comments (0)

Bristol – The beauty of South West

June 9th, 2012

I found this video of Bristol really amazing and i would like to share it with you!

Bristol is the cultural capital of South West and the city i live since the October of 2012. I really believe that there are a lot of secrets hidden in this city! Amazing nightlife and plenty of places to relax! After my final exams, I hope to find some time to explore the city more because i would like to!

Enjoy the video,

Real Scenes: Bristol from Resident Advisor on Vimeo.

 

Posted in Travelling | Comments (0)

Terminal .bash_profile

May 21st, 2012

Trying to make my OS X terminal easier to use i inserted some aliases in order to connect to University’s remote ssh servers.

Unfortunately, i realised that each time i was restarting the terminal window, the aliases that was already set had gone. This is because all the aliases should be executed each time the bash starts.

After a little research i did on web i found that bash can be initialised in a specific mode by changing a configuration file that exists in you pc with a standard configuration. If this file does not exist you can create it and give to it the name “.bash_profile”. This file will be read each time the terminal starts and so all the aliases you’ve got there are going to be executed. You should put this configuration file to your home folder.

Posted in Uncategorized | Comments (0)

Λίστα MySQL εντολών

December 26th, 2011

Υπάρχουν πολλά εργαλεία εκεί έξω για τη διαχείριση των βάσεων δεδομένων σας. Η αλήθεια είναι πως όλα αυτά είναι πολύ χρήσιμα αλλά δεν μπορούν να αντικαταστήσουν την γραμμή εντολών.
Παρακάτω παρουσιάζονται οι πιο δημοφιλείς command line εντολές της MySQL.

Σύνδεση στη MySQL ως διαχειριστής:
mysql -u root

Δημιουργία νέου χρήστη με username user και κωδικό password:
mysql> CREATE USER ‘user’@'localhost’ IDENTIFIED BY ‘password’

Εμφάνιση λίστας με όλες τις βάσεις δεδομένων που υπάρχουν στο server:
mysql> show databases;

Δημιουργία Βάσης με το όνομα database:
mysql> CREATE DATABASE database;

Επιλογή της βάσης με όνομα database:
mysql> use database;

Διαγραφή της βάσης με όνομα database
mysql> drop database;

Posted in Uncategorized | Comments (0)

Εγκατάσταση Python Mysql adapter

August 10th, 2011

Εδώ και αρκετό καιρό ακούω πόσο γαμάτη και γρήγορη είναι η python και το django για web development. Ευτυχώς που είναι καλοκαίρι και υπάρχει λίγος χρόνος για διάβασμα οπότε μπορώ να ρίξω και μια ματιά σε άλλες τεχνολογίες πέρα του .NET Framework. Μετά από λίγες μέρες διάβασμα ήθελα να διαπιστώσω τις ικανότητες της python σε συνδυασμό με μια βάση δεδομένων και έτσι χωρίς πολύ σκέψη επέλεξα να χρησιμοποιήσω τη mysql. Το θέμα είναι ότι αντιμετώπισα κάποιες δυσκολίες στην εγκατάσταση/ρύθμιση του python mysql adapter ο οποίος είναι απαραίτητος αν θέλετε να χρησιμοποιήσετε μια βάση δεδομένων με το django. Προκειμένου λοιπόν να βοηθήσω και κάποιους άλλους που θα έχουν το ίδιο πρόβλημα, περιγράφω παρακάτω τα βήματα που ακολούθησα και κατάφερα να δουλεύουν όλα άψογα.

Στο σύστημα μου χρησιμοποίησα σε λειτουργικό OS X 10.5.6 τα εξής :

Python 2.5.1
mySQL  5.5.15
mySQL Python adapter 1.2.3

Βήμα 1
Κατεβάστε τον mysql adapter από τον παραπάνω σύνδεσμο και τοποθετήστε τον στο home folder του OS X.

Βήμα 2
Ανοίξτε ένα terminal window και για να ξεσυμπιέσετε το αρχείο πληκτρολογήστε την εντολή:
>> tar xfz MySQL-python-1.2.1.tar.gz

Βήμα 3
Mπείτε στο φάκελο οπού περιέχει τον python adapter με την εντολή:
>> cd MySQL-python-1.2.3

Βήμα 4
Κάντε edit το αρχείο setup_posix.py και τη γραμμή 26, δηλαδή το
mysql_config.path = “mysql_config”
το αντικαθιστάτε με το εξής
mysql_config.path = “mysql_config_path”

ΠΡΟΣΟΧΗ:
Το mysql_config path διαφέρει ανάλογα με το που έχετε εγκαταστήσει τη βάση σας.
Σε εμένα πχ η εντολή μοιάζει ως εξής
mysql_config.path = “/usr/local/mysql/bin/mysql_config”

Στη συνέχεια αποθηκεύστε τις αλλαγές.

Βήμα 5
Δημιουργήστε συμβολικά links με τις εξής εντολές:
>> sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
>> sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

Βήμα 6
Τέλος, κάνουμε build και install τον python adapter:
>> python setup.py build
>> sudo python setup.py install

Βήμα 7
Τελικά για να δούμε αν όλα πήγαν κατ’ ευχή δοκιμάζουμε στον intepreter της python να κάνουμε import τον MySQLdb adapter οπότε:
>> python
>>> import MySQLdb

Αν δεν σας βγάλει κανένα λάθος τότε όλα είναι έτοιμα για χρήση της mySQL.

Θα χαρώ να σας βοηθήσω σε οποιαδήποτε απορία!

Posted in Coding | Comments (0)

The first Summer AppCamp

June 25th, 2011

Το appCamp αποτελεί ένα τρόπο προώθησης και υποστήριξης νέων ανθρώπων/επιχειρηματιών που ασχολούνται με την κατασκευή εφαρμογών σε mobile περιβάλλοντα ανάπτυξης. Πιο συγκεκριμένα, στόχος του event είναι η υλοποίηση έξυπνων ιδεών, από ομάδες 2-5 ατόμων, τις οποίες μπορούν να εκμεταλλευτούν εμπορικά. Κατά τη  διάρκεια της ανάπτυξης, μέντορες θα υπάρχουν στους χώρους εργασίας οι οποίοι θα συμβουλεύουν τις ομάδες.

Το πρόγραμμα του camp θα είναι το εξής:

6 Ιουνίου

Έναρξη Εγγραφών

27 Ιουνίου

Τέλος Εγγραφών

30 Ιουνίου

Οργάνωση Ομάδων

4 Ιουλίου

Έναρξη του πρώτου summer AppCamp

8-10 Ιουλίου

Ανάπτυξη Εφαρμογών

19 Ιουλίου

Παρουσίαση Εφαρμογών

Θα τρέχουν Παράλληλα 3 campuses σε Αθήνα, Θεσσαλονίκη και Πάτρα.

Η δική μου προσωπική άποψη είναι πως ένα τέτοιο event δεν πρέπει να χαθεί, και αυτό επειδή οι επίδοξοι προγραμματιστές θα έχουν τη δυνατότητα να συναναστραφούν με διακεκριμένους επαγγελματίες του χώρου από τους οποίους μπορούν να αποκομίσουν πολύτιμες γνώσεις και εμπειρίες.

Γι’ αυτό το λόγο λοιπόν, όποιος έχει σκεφτεί μια πραγματικά έξυπνη ιδέα και θέλει να την δει να υλοποιείται μέσα σε 15(περίπου) ημέρες έχει ακόμη δύο μέρες καιρό για να εγγραφεί στο πρώτο καλοκαιρινό AppCamp!

Tags: , ,
Posted in Events | Comments (0)

jQuery Plugins!

June 19th, 2011

Η Javascript είναι ο εφιάλτης όλων των web developers για έναν ανεξήγητο (περίπου) λόγο. Το κακό είναι πως δεν μπορούμε χωρίς αυτή! Παρ’ όλα αυτά υπάρχουν αμέτρητες libraries οι οποίες απλοποιούν τη χρήση της javascript.

Μια από αυτές είναι και η jQuery Library. Η τραγική ειρωνία είναι πως μέσα από μια τόσο μισητή scripting language μπορούν να βγούνε πολύ όμορφα αποτελέσματα. Πλέον δεν υπάρχει λόγος να ενσωματώσει flash script για visualizations κτλπ κάνοντας μια σελίδα βαριά και ασήκωτη.

Ο λόγος που γράφω αυτό το post βέβαια, δεν είναι για να εκθειάσω τα πλεονεκτήματα της jQuery αλλά για να δώσω παραπομπές για κάποια plugins της βιβλιοθήκης αυτής τα οποία μου φάνηκαν πολύ χρήσιμα αλλά και αισθητικά όμορφα!

Οπότε έχουμε και λέμε:

-Θέλετε μια library για tooltips; Η qTip κάνει σίγουρα για αυτό το οποίο θέλετε:

qTip

-Θέλετε μια library για visualizations; H visualize library της Filament Group είναι ό,τι ζητάτε:

Visualize

-Είστε απλά ένας web developer χωρίς γνώσεις σε ui design, μην αγχώνεστε αφού υπάρχουν έτοιμα πανέμορφα jquery user interfaces:

jQuery UI

-Εάν ψάχνετε ένα γρήγορο και αποδοτικό τρόπο για client-side form validation, τότε δείτε το παρακάτω:

jQuery Validation plugin

Tags: , , , ,
Posted in Coding | Comments (0)

Πληροφορική και Επιχειρείν

June 18th, 2011

Σίγουρα ζούμε σε ένα κόσμο όπου η ροή πληροφοριών είναι ακατάπαυστη! Ο κόσμος μας είναι γεμάτος προβλήματα τα οποία, συνδυάζοντας την έξυπνη σκέψη με τις πληροφορίες που υπάρχουν γύρω μας, μπορούν να επιλυθούν με τη δημιουργία συναρπαστικών τεχνολογικών προϊόντων!

Ο λόγος γίνεται για το πως μπορεί να συνδυαστεί η πληροφορική με την επιχειρηματικότητα! Πέρα από το κλασσικό “Εταιρία χωρίς υπολογιστή δεν γίνεται“, μπορούμε να σταθούμε στην πληροφορική σαν το κύριο αντικείμενο στο οποίο μπορεί να βασιστεί μια startup!

Πρώτα από όλα χρειαζόμαστε μια πρωτότυπη ιδέα και ένα παγκόσμιο κοινό! Η ιδέα μας, αρχικά πρέπει να είναι απλή, ξεκάθαρη και ΑΜΕΣΑ υλοποιήσιμη. Το τελευταίο είναι πολύ σημαντικό καθώς στο κόσμο του Διαδικτύου υπάρχουν τόσοι πολλοί άνθρωποι οι οποίοι είναι έτοιμοι να υλοποιήσουν την ιδέα σας πολύ πιο γρήγορα απ’ ότι εσείς και ως αποτέλεσμα χάνετε το πλεονέκτημα και έχετε βγει απ’το παιχνίδι χωρίς καν να έχετε ξεκινήσει! Άλλωστε η ΠΡΩΤΟΤΥΠΙΑ και η ΚΑΙΝΟΤΟΜΙΑ είναι δυο από τα κυριότερα συστατικά για να βγείτε πετυχημένος μέσα από την επιχειρηματική σας δραστηριότητα!

Read the rest of this entry »

Posted in Entrepreunership | Comments (0)

  • Twitter
  • Facebook
  • LinkedIn