Sunday, September 20, 2015

Git Learning Part II Inspecting a repository

Git status command displays the status of the working directory and the staging area. This doesnt give any information regarding the committed project history. Instead it gives info only about the changes in the staging area which have been staged, which havent been and which files have been tracked by Git. 

to use status command, can just use 

git status

Running this command on one Linphone git directory, below is what is seen. 

Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

modified:   Classes/LinphoneManager.m
modified:   Resources/linphonerc~ipad
modified:   linphone-Info.plist
modified:   linphone.xcodeproj/project.pbxproj
modified:   submodules/belle-sip (modified content)
modified:   submodules/linphone (modified content)

no changes added to commit (use "git add" and/or "git commit -a")

Ignoring Files : There can be two types of files those can be ignored. Those could be the ones just added or could be the ones that doesnt need to be committed to the git. The git status command will print both these types if the latter is not added to the ignore list. To add to the ignore list, these file paths can be specified in a .gitignore file. Below is a sample in which the Classes/LinphoneManager.m is excluded from appearing in the git status output. 

build-*
*.locuser
.DS_Store
liblinphone-sdk
liblinphone-iphone-sdk*.zip
xcuserdata/
Classes/LinphoneIOSVersion.h
Pods/
build
test-reportl
Classes/LinphoneManager.m

The Git log command displays the committed snapshots. this lets to list the project history, filter and search for the specific changes. Like mentioned earlier, git log command only works on the committed changes not in the working directory unlike the git status command. 

Some of the git log commands are like below

git log 
git log -n
git log —-onleline 
git log —stat => Displays which files are in each commit
git log -p => Displays patch of each commit 

git log —-author=“authorpattern>”
git log —-grep=“grep pattern>”
git log since> Shows only occurrence between a committ ID, branch name HEAD or any commit reference
git log file => Displays only commits that occur in a specific file. 
git log —-graph —-decorate —-oneline => Displays a text based graph to the left of the commit. —decorate adds the names of branches or tags of the commits that are shown. 

When listing the commit details it will be something like below 

commit 89a4eef409b30ab4007dbb704be2dfb3791e445b
Author: Steve keexo
   
In this the ID is the SHA-1 checksum of commits contents. this serves as unique ID and integrity of the content. 

References:



Tuesday, September 15, 2015

IPv6 address format

IPv4 and IPv6 uses different formats: 

Address space: 128 in IPv6 and 32 in IPv4
Representation : String representation in IPv6 while it is integer representation in IPv4
Length: Including field separators it is 39 in IPv6, while it is 15 in IPv4 
Notation: Hexadecimal notation in IPv6, while it is decimal in IPv4

Below given are some bullet points on the benefits of IPv6 over IPv4

- larger address space
- simplified header format 
- automatic configuration
- more efficient routing 
- improved quality of service and security 
- compliance with regulatory requirements
- widespread use in global markets 

Below given few examples of IPv6 addresses: 

FE80:0000:0000:0000:0202:B3FF:FE1E:8329 => 128 bit address in eight 16bit in the format global:subnet:interface
FE80::0202:B3FF:FE1E:8329 => example of a collapsed address where two consecutive colons represent 16bit blocks that contain zeros. 
[2001:db8:0:1]:80 => with a port number. brackets can be omitted if the port number is not present 
http://[2001:db8:0:1]:80 => URL containing IPv6 address. 

references:

Friday, September 11, 2015

Exploring Java PNS

The source and the libraries required were downloaded form the link from the reference section. this is a library which allows us to send APNS messages from java library. 
JavaPNS require 1.5 runtime or later. 

there are few dependancies with this, and they are 

bcprov-jdk15-146.jar => Bouncy Castle library used for Secure connection with the Apple server
log4j-1.2.17.jar => Apache Logging framework 

The above are to be in the class path for this to work along with the Java PNS library jar file which is JavaPNS_2.2.jar

The Java PNS package downloaded also had a test application which is NotificationTest.java 

ran this with the respective arguments and it sent the push message to the app successfully. 


References:

Wednesday, September 9, 2015

MKMapView and MKMapCamera Few notes


MKMapView provides embedded map interface. When initializing Mapview, we should provide a regionn. A region is defined by a center and a horizontal and vertical distance referred to as span. The span defines how much of the map at a given point should be visible and is also how you set the zoom level. Specifying a small span results in the user seeing a more narrow geographical area and corresponds to a higher zoom level. 

An annotation object is any object that conforms to MKAnnotation protocol. The presentation of annotation objects on the map is using MKAnnotationView. Because annotation view are needed only when they are on the screen. Annotation views with a reuse identifier can be detached and queued internally by the map view when they move offscreen. This feature improves memory use by keeping only a small number of annotation views in memory at once and by recycling recycling the views you do have. 

For adding overlays to the Map, we need to have overlay object which conforms to the MKOverLay protocol. An overlay object is a data object that contains the points needed to specify the shape and size of the overlay and its location on the map. Overlays can represents shapes such as Circles, rectangles, multi-segment lines and simple or complex polygons. Developer can also define custom overlays. the presentation of Overlay is done by the MKOverlayRenderer class. 

When configuring the map, the overlay objects can be added at any time. The map view uses data in each overlay object to determine when corresponding overlay view needs to appear on screen. When an overlay moves on screen, the map view asks its delegate to create a corresponding overlay renderer. 

MKMapCamera object describes a virtual camera that we can use to define the appearance of the map. A camera object creates a virtual viewpoint above the map surface and affects how the map renders its tiles and other content. We can use camera object to specify the location of the camera on the map, the compass heading that corresponds to camera’s viewing direction, the pitch of the camera relative to the map perpendicular and camera’s altitude above the map. These factors let the map to appear like 3D. 

Map can be centered with the MKMapCamera’s centerCoordinate property. 

References:

Tuesday, September 8, 2015

Google Cloud Messaging on iOS

Google provides a sample app that details the procedure

Step 1:

sudo gem install cocoapods 

This installs the cocoapods

After this run the below command to get the Google project 

pod try Google 

This basically checks out all the sample apps in cocoapods under Google. 

Step 2: 

Next Step was to get the configuration file 

For this step, had to enter the bundle ID that has the APNS feature and also has the p12 certificate
Now, the console asked the p12 certificate and after uploading the certificate, go the GCM server key and the sender ID

Then had to enable which services to be enabled. Selected the Google Cloud Messaging and moved on. Below few screenshots details the process involved





finally, this gave the GoogleServices-Info.plist file. 

This file was added to all the targets and ran the app on the device. This successfully registered the APNS and there is a Google token also associated with it. 

Now run the Server Demo app and give the registration token and the server API key and the message should appear on the app. 

References:

Sunday, September 6, 2015

Google Cloud Messaging - Learning Part 1


This enables to send the message to the devices from the server and receive message from the users device on the same connection. The GCM handles all aspects of queuing of message and delivery to client applications running on target devices, and its completely  free. 

Below are the main features of this 

1. Versatile messaging targets : Distribute message to the client app in any of three ways - to single devices, to group of devices, or to devices subscribed to topics. 
2. Downstream messaging : For purposes such as alerting users, chat messaging or kicking off background processing before user opening the app, GCM provides a battery efficient connection between server and devices 
3. Upstream messaging : Send ACKs, chats, and other messages from devices back to the servers over GCM’s reliable and battery efficient connection channel. 

Sending a message using GCM-HTTP connection server protocol: 

https://gcm-http.googleapis.com/gcm/send 
Content-Type:application/json
Authorization:key=AISS….. 
{
“to” : “/topics/foo-bar”,
“data” : 
{
“message” : “This is a GCM topic message”,
}

}

To Handle a downstream message on an Android device, below is the code 

@override 
public void onMessageReceived (String from, Bundle data)
{
String message = data.getString(“message”);
}

References:

Thursday, September 3, 2015

MKMapView - Custom View for Annotation

First step is to have MKMapView delegate set and override the viewForAnnotation method 
Next is to create annotation 

thePlane = [[MKPointAnnotation alloc] init];
    thePlane.coordinate = startPoint;
    thePlane.title = @"Agent";
    [self.mapView addAnnotation:thePlane];


- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    static NSString *SFAnnotationIdentifier = @"AnnotationIdentifier";
    MKPinAnnotationView *pinView =
    (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:SFAnnotationIdentifier];
    if (!pinView)
    {
        MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
                                                                         reuseIdentifier:SFAnnotationIdentifier];
        UIImage *flagImage = [UIImage imageNamed:@"car.png"];
        annotationView.centerOffset = CGPointMake(0, -16);
        // You may need to resize the image here.
        annotationView.image = flagImage;
        return annotationView;
    }
    else
    {
        pinView.annotation = annotation;
    }
    return pinView;

}

references:
https://gist.github.com/siqin/3175036