Setting up ionic framework

Ionic is a framework to build hybrid mobile applications using HTML, CSS and Javascript especially AngularJS and we can use cordova for using native mobile capabilities in our app.

Setting up Ionic framework:


npm install cordova ionic -g

Creating a folder for ionic and scaffolding an app:

Move to your desired location in your computer and create a folder eg:ionic

move to that folder and

 ionic start projectnamehere sidemenu 

The sidemenu argument creates an app with sidemenu. There are several such styles for scaffolding an app.

Serving ionic app:

To serve the app

 ionic serve
Advertisements

Setting up json-server to serve json data for Angular app

The json-server is a simple server to serve json data for playing with Angular app in development. If you are learning AngularJS and want to play with json data you can use this json-server to serve static content for you!!

Installing json-server:

npm install json-server -g

 

Setting up a folder to serve:

Create a folder at any convenient place.

mkdir foldername

Move to that folder

cd foldername

Place your .json file in this folder eg: db.json To serve your content

$json-server --watch db.json

\{^_^}/ hi!

Loading db.json
Done

Resources
http://localhost:3000/dishes
http://localhost:3000/promotions
http://localhost:3000/leadership
http://localhost:3000/feedback

Home
http://localhost:3000

Type s + enter at any time to create a snapshot of the database
Watching...

Now open your favourite browser and navigate to the said links you can see your json being served!!

If you want to serve images or any other static content then you need to put those in public folder.

Macro to create excel sheets dynamically based on values of one sheet

Sub Macro2()
Dim wsNew As Worksheet
Dim wsMaster As Worksheet
Dim x As Long

Dim cell As Range
'Sheet2 will be copied as new sheet and renamed with data in Sheet1 columns A and B
Set wsMaster = ActiveWorkbook.Sheets("Sheet2")
x = 1

Do While Not IsEmpty(Sheet1.Cells(x, 1).Value)
wsMaster.Copy Before:=wsMaster

Sheet_name_to_create = Sheet1.Cells(x, 1).Value & "-" & Sheet1.Cells(x, 2).Value

Set wsNew = ActiveWorkbook.ActiveSheet
wsNew.Name = Sheet_name_to_create

x = x + 1
Loop

End Sub

This creates sheets with name of col A and B in sheet 1 and copy the sheet2

Two ways to create Android App

Approach 1:

Use native android building tools and write code in Java for App to work

If you want to use a Database write serverside logic in a way that it serves you the required data in the form of JSON. So the idea here is to build API that interacts with Database and serves you data for request you send.

Then you can process the JSON and use the data in your app.

Technology required: Java(for android app and server), XML (only for UI), android(learn about activity class, Intent Class, Fragments)

Approach 2:

Build a serverside logic that serves JSON as above in any language you want.

For app you can write the code in HTML, CSS and Javascript. There is AngularJS, Ionic Framework etc., If you want to use native libraries of android you can use Cordova which helps to access the native libraries of andoird (such as contacts etc.,)

Use AngularJS or ionic framework to build UI and get data by your server and render it as app through Phonegap

Phonegap basically converts HTML, CSS, Javascript into .apk file for you to install in android phones. You can also convert it into iPhone app, Blackberry app etc.,

Technology required: Any server side language (Java, ruby, python etc.,), Javascript frameworks (Ionic/ AngularJS) If you are interacting with native android (cordova)

Why AngularJS?

AngularJS is a javascript framework used to build SPA (Single Page Applications) which are very popular now. In a single page application you will have many different blocks where data(received from server) is to be put. You need to have a mechanism to tell this data has to go to this block etc., so for that you need routes, you need a controller to control the data (Model) to the UI (View), so it forms a MVC architecture. You can do this by BackboneJS also which depends on UnderScoreJS, but AngularJS is popular since it is framework and all underlying works are done for you.

If you want to build a customized application then you need to use BackboneJS

Start MongoDB service

  • Start cmd as Administrator
  •  Create a directory for mongodb in c:
    mkdir mongodb
  • Create two directories for log and db in mongodb folder
    cd mongodb
    mkdir log
    mkdir db
  • Create a configuration file called mongodb.cfg in mongodb folder with contents:
    systemLog:
             destination: file
             path: c:\mongodb\log\mongod.log
    storage:
             dbPath: c:\mongodb\db
  • Create an empty file and save it as mongod.log and put it in c:\mongodb\log\

Adding to Windows service

 

"C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --config "C:\mongodb\mongodb.cfg" --install

Start the service

net start MongoDB

 

Stop the service

net stop MongoDB

Understanding Web-Server

Why do you need a web-server?

All browsers understand only HTML,CSS and JS. The browser cannot interpret PHP or any other server side language. So you need some mechanism to convert PHP to HTML.

This is taken care by web-server. apache is the open source webserver used to serve PHP.

How to use a web-server?

Install the web-server then you need to configure it so as to have a directory(htdocs) to put all your code so that it can interpret and make browser understand the stuff.

Once you have configured it and start your webserver you can open it in a browser and can see the webserver serving HTML code even though you give it PHP code.