Todo List App using Sencha – Part 2

In the 1st Part we generate, build and run sencha touch project using terminal/command prompt. In this part we’ll start create controller and model using terminal/command prompt.

To create controller with Sencha CMD it is enough to execute the following command:

sencha generate controller Task
Sencha Controller

Sencha Controller

It generates for us controllers/Main.js file. It is generic and has minimum content:

Ext.define('RevivalxSenchaTodolist.controller.Task', {
    extend: 'Ext.app.Controller',
    
    config: {
        refs: {
            
        },
        control: {
            
        }
    },
    
    //called when the Application is launched, remove if not needed
    launch: function(app) {
        
    }
});

To instantiate controller automatically we have to add it into controllers configuration section (app.js) in application next way:

controllers: [ 'Task' ]

Then we generate a Task model using this command:

com.revivalx.sencha.todolist MNurdin$ sencha generate model Task tasId:int,name:string,description:string,dateCreated:string,dateUpdated:string
Sencha Model

Sencha Model

And in model folder, we should see file Task.js:

Ext.define('RevivalxSenchaTodolist.model.Task', {
    extend: 'Ext.data.Model',
    
    config: {
        fields: [
            { name: 'tasId', type: 'int' },
            { name: 'name', type: 'string' },
            { name: 'description', type: 'string' },
            { name: 'dateCreated', type: 'string' },
            { name: 'dateUpdated', type: 'string' }

        ]
    }
});

To work with this model in our application we should add RevivalxSenchaTodolist.model.Task to requires section, usually we do it in controllers or stores.

Continue..

Todo List App using Sencha – Part 1

In this tutorial, I will show you how to create a simple todo list app using Sencha.

Sencha provides HTML5-based app development tools and services for building universal apps that run on any device.

Sencha Touch, a high-performance HTML5 mobile application framework, is the cornerstone of the Sencha HTML5 platform. Built for enabling world-class user experiences, Sencha Touch is the only framework that enables developers to build powerful apps that work on iOS, Android, BlackBerry, Windows Phone, and more.

Sencha

Sencha

Setting up your development environment

Download and unzip Sencha Touch, http://www.sencha.com/products/touch/download. You can unzip the software to any directory. Sencha Touch 2.3.1 requires Sencha Cmd 4.0.1, 4.0.2, or later. Download and install Sencha CMD, http://www.sencha.com/products/sencha-cmd/download . To check that you have correctly installed Sencha Cmd, type the sencha command, for example:

Sencha

Sencha

Create a sencha project using command below in your terminal/cmd:

sencha -sdk /Applications/touch-2.4.1 generate app RevivalxSenchaTodolist /Applications/MAMP/htdocs/com.revivalx.sencha.todolist
Sencha generate project

Sencha generate project

Sencha Touch already has a good integration with PhoneGap and with Sencha CMD, we can easily add Cordova infrastructure to our project.

sencha cordova init com.revivalx.sencha.todolist RevivalxSenchaTodolist
Sencha init cordova

Sencha init cordova

Open app.json file in text editor, find section builds in it and uncomment row with platforms list. So your builds section will be something like this:

"builds": {
        "web": {"default": true},
        "native": {
            "packager": "cordova",
            "cordova" : {
                "config": {
                    // Uncomment the line below and add the platforms you wish to build for
                    "platforms": "ios android",

                    "id": "com.revivalx.sencha.todolist",
                    "name": "RevivalxSenchaTodolist"
                }
            }
        }
    },

Here you can see that by default build for web is turned on and as a packager Sencha Touch uses Cordova. Also in the config section you can see id and name properties, which we got from our cordova init command.

Now we can run our application in iOS and Android emulators simply by executing next command:

sencha app build -run native
iOS and android simulator

iOS and android simulator

Next we will learn how to create controller using CMD.

Using UIGestureRecognizer with Swift

If you need to detect gestures in your app, such as taps, pinches, pans, or rotations, it’s extremely easy with Swift and the built-in UIGestureRecognizer classes.

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var lblTxt: UILabel!

override func viewDidLoad() {
        super.viewDidLoad()

        let recognizer = UITapGestureRecognizer(target: self, action:Selector("handleTap:"))
        recognizer.numberOfTapsRequired = 1;
        lblTxt.addGestureRecognizer(recognizer)
        lblTxt.userInteractionEnabled = true;
}

func handleTap(recognizer: UITapGestureRecognizer){
        println("tapped!")
        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
        let secondViewController = storyBoard.instantiateViewControllerWithIdentifier("secondView") as SecondViewController
        self.presentViewController(secondViewController, animated:true, completion:nil)
    }

How To Install Zimbra Collaboration Suite 8.6.0 On CentOS 7

Zimbra Collaboration Suite (ZCS) is a groupware product created by Zimbra, Inc. It is widely used in the world. Users can share folders, contacts, schedules and other things, using a very rich web interface. Currently the latest version of Collaboration Suite is Zimbra 8.6.0. It brings new features, improvements in Mail server and it provides a better web client experience. In this tutorial, I will explain how to install Zimbra 8.6.0 on RHEL 7 or CentOS 7.

If you don’t have Digital Ocean account yet, you need to sign up first. Sign Up Digital Ocean. Then you need to deploy your droplet. http://blog.revivalx.com/2014/10/15/deploy-droplet-in-digital-ocean/

Login your VPS via SSH using Terminal (Mac) or Putty (Windows). First, we need to ensure that CentOS 7 is up to date. Therefore, we’ll run the following command:

yum update –y
yum update

yum update

yum update

yum update

Next, we need to install some pre-requisites. Since there are 12 different applications required to install Zimbra, we can handle the installation in one single command:

yum install -y gmp libidn wget nano make nc sudo sysstat libtool-ltdl glibc perl ntp libaio unzip perl-core

Next, we’ll need to install check if postfix is running – if it is, disable it. Since we cannot have two different mail transfer agents running, postfix must go.

service postfix status

If postfix is running, we’ll need to disable it:

service postfix stop && chkconfig postfix off

Setup DigitalOcean DNS for your domain, head over to the DNS tab in the DO control panel. Once there, add your domain.

DNS - Add a Domain

DNS – Add a Domain

Point to mail.aceakl.my (your Droplet FQDN) with a high priority (lowest number).

DNS - Add a Domain

DNS – Add a Domain

Once you’ve added your domain, add the following records to your DNS settings. In this example, the IP address 128.199.72.229 is used for my DigitalOcean Droplet. However, yours will be different, so set this value to your Droplet IP.

DNS - Add a Domain

DNS – Add a Domain

Final result.

DNS - Add a Domain

DNS – Add a Domain

Go to Zimbra official website to get a download link for the latest version of Zimbra.

Zimbra download page

Zimbra download page

And then fetch the file from the Zimbra website. You can use wget to achieve this. Obviously, you’ll need to place the URL you copied earlier into this command rather than using the link here.

wget https://files.zimbra.com/downloads/8.6.0_GA/zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz
wget Zimbra for Centos 7

wget Zimbra for Centos 7

Now we’ll need to edit the hosts file in CentOS to contain the IP address of the Droplet, the FQDN, and name of the server. We can do this by typing:

nano /etc/hosts

Once opened, the hosts file should look similar to the following:

nano /etc/hosts

nano /etc/hosts

Remove IPV6 and this line.

127.0.0.1 Aceakl Aceakl

# The following lines are desirable for IPv6 capable hosts
::1 Aceakl Aceakl
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

You’ll need to edit the file to contain another row with your Droplet’s IP address, FQDN and name. The line should look like the following:

127.0.0.1 localhost.localdomain Aceakl localhost
127.0.0.1 localhost4.localdomain4 localhost4
128.199.72.229 mail.aceakl.my mail

You’ll need to ensure that you replace the above with the actual data values for your Droplet. You should also make sure that you use a tabbed space between each value. This means that you’ll have a host file looking something similar to:

nano /etc/hosts

nano /etc/hosts

Once done, press CTRL+O and then Enter to save. Then press CTRL+X to return.

The next stage is to unpack the tgz file we downloaded earlier. To do this, we can execute the following command:

tar zxvf zcs-*.tgz

Next, change directory into the folder that the files were extracted into:

cd zcs-*

Finally, we can run the installer.

./install.sh --platform-override

Once the installer starts, you’ll need to accept the license agreements by pressing Y at each license prompt.

Accept the license agreements

Accept the license agreements

When you reach the ‘select packages to install’ section, simply press enter at each of the options which will select the default value.

Installing Zimbra packages

Installing Zimbra packages

Type No and Enter.

DNS ERROR resolving localhost.localdomain

DNS ERROR resolving localhost.localdomain

Type Yes and set your domain name.

DNS ERROR resolving MX for localhost.localdomain

DNS ERROR resolving MX for localhost.localdomain

This error is presented by Zimbra because it’s looking for an MX record for the domain ‘subdomain.example.com’. Instead, we want it to search for an MX record for ‘example.com’. This means that we should press Y`, and change the domain name to just ‘example.com’. If you get a port conflict error, you may need to exit the installer and resolve the issue before continuing. You’ll soon reach the configuration page, similar to that below. First we should choose option 3 to allow us to enter the zimbra-store section.

Zimbra main menu

Zimbra main menu

Address unconfigured (**) items (? – help)   7

Next, choose 4. This will allow us to configure the admin username and password.

Select, or 'r' for previous menu [r]  3
Create admin user: [admin@aceakl.my] admin@aceakl.my
Password for admin@aceakl.my (min 6 characters): [MBUKGBcH] password

Next, choose r to return to the previous menu.

Select, or 'r' for previous menu [r]  r

Then, choose 1 to go to the common configuration section.

*** CONFIGURATION COMPLETE - press 'a' to apply
Select from menu, or press 'a' to apply config (? - help)   1
Zimbra common configuration

Zimbra common configuration

Zimbra main menu

Zimbra main menu

After this, choose 6 to edit the time zone.

Select, or 'r' for previous menu [r]  6
Zimbra common configuration

Zimbra common configuration

Here, you should choose the number relative to the time zone you’re in. For example, you could type 50 to get the Kuala Lumpur time zone.

Enter the number for the local timezone: [39]  50
Zimbra timezone

Zimbra timezone

Then choose ‘r’ to return and ‘a’ to apply the configuration. You should also choose the log the installation to a file, in case any errors arise.

Select, or 'r' for previous menu [r] r
*** CONFIGURATION COMPLETE - press 'a' to apply

Select from menu, or press 'a' to apply config (? - help) a
Save configuration data to a file? [Yes]  yes
Save config in file: [/opt/zimbra/config.7622] /root/zimbra-installation.txt
Saving config in /root/zimbra-installation.txt...done.
The system will be modified - continue? [No] yes
Zimbra configuration complete

Zimbra configuration complete

The system will then continue the installation. Setup of Zimbra should take about 20 minutes, depending on the Droplet size you selected.

Finally, you’ll be given the option of notifying Zimbra of the installation, which allows them to track the uptake of their products. You can either type ‘yes’ or ‘no’ here, either way, this is the final step of the installation. You can make sure that the installation was successful from the final confirmation message:

Configuration complete – press return to exit
Finishing Zimbra installation zimlets

Finishing Zimbra installation zimlets

It is recommended that you reboot your Droplet.

Accessing The Zimbra Admin Control Panel
The control panel can be easily accessed by visiting the following URL:

https://mail.aceakl.my:7071/zimbraAdmin

Core Data in Swift Tutorial – Part 1

In this tutorial you will develop to do list app using Core Data.

Core Data is the de facto standard way to persist and manage data in both iPhone and Mac applications, and with Swift it’s a bit easier. So it’s only natural that we should take some time to learn about it when building apps. Eager to see what we’ll have created by the end of this tutorial? Take a look at the video, we’ll be creating this table view, populating it with data, adding the ability to delete records, add records, and sort/search records all backed by Core Data. This data is persistent and lasts even through a complete shut down of your phone.

Reference: http://jamesonquave.com/blog/core-data-in-swift-tutorial-part-1/

Getting Started.

Open your Xcode6 and select Create a new Xcode project. Select Single View Application and click Next.

Single View Application

Single View Application

For product name, use RevivalxCoreData and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and make sure only iPhone is selected in Devices. Make sure CoreData ticked. Click Next. Select workspace and click Create.

Xcode6 New Project

Xcode6 New Project

Remove existing View Controller in Main.storyboard. Add new UITableViewController.

UITableViewController

UITableViewController

UITableViewController

UITableViewController

Next, embed the Table View Controller in a navigation controller. From Xcode’s Editor menu, select Embed In…\ Navigation Controller.

Navigation Controller

Navigation Controller

Then, drag a Bar Button Item and place it on the view controller’s newly added navigation bar. Finally, double-click the bar button item to change its text to Add. Your canvas should now look like the following screenshot:

Bar Button Item

Bar Button Item

Bar Button Item

Bar Button Item

Add new UIVewController and Ctrl-drag from the Bar Button Item Add onto ViewController to create Storyboard segue.

View Controller

View Controller

View Controller

View Controller

Add the following property to TableViewController.swift

var myList: Array <AnyObject> = []

Replace the implementation of viewDidLoad with the following:

override func viewDidLoad() {
  super.viewDidLoad()
  title = "\"The Task\""
}

Below viewDidLoad, implement the following data source methods.

override func tableView(tableView: UITableView,
        numberOfRowsInSection section: Int) -> Int {
            return myList.count
    }
    
override func tableView(tableView: UITableView,
        cellForRowAtIndexPath
        indexPath: NSIndexPath) -> UITableViewCell {
            
            let cell = tableView.dequeueReusableCellWithIdentifier("TaskCell", forIndexPath: indexPath) as UITableViewCell 
            cell.textLabel!.text = myList[indexPath.row]
            
            return cell
    }

Will continue part 2..