Saturday, September 26, 2015

Git Learning Part I - Setting up a repository

Git init command creates a new Git repository. It can be used to convert and existing unversioned project to a Git repository or initialize a new empty repository. 

Executing git init creates a .git subdirectory in the project root, which contains all of the necessary metadata for the repo. Aside from the git subdirectory, an existing project remain unaltered (unlike SVN, git doesnt require a .git in every sub directory) 

The init command variants are 

git init => create git repository at the current path 
git init Initializes the git with an empty directory 
git init —-bare create a shared repository. Repositories initialized with —-bare flag end with .git. For e.g. the bare version of a repository called my-project should be stored in a directory called my-project.git 

Bare flag creates a repository that doesnt have working directory. This makes impossible to edit files and commit in that repository. Central repositories should be always created as a bare repositories because pushing branches to a non-bare repository has the potential to overwrite the changes. We can think of bare as a way to mark a repository as a storage facility as opposed to development environment. This means that virtually for all work flows, the central repository is bare, and developers local repositories are non-bare. 

Below is the most common use case: 

ssh
cd path/repo
git init —-bare my-project.git 

Developers can then clone the repository to create a local copy in their development machine. 

git clone command copies an existing Git repository. This is similar to svn checkout, except that the “working copy“ is full fledged git repository. it has its own history manage its own files and is a complete isolated environment from the original repository.

git config command lets us configure Git installation (or and individual repository) from the command line. This command can define everything from user info to preferences to the behavior of a repository. Some of the configuration options are 

got config —-global user.name
git config —-global user.email
git config —-system core.editor

references:

How Chromecast works


Chromecast gets things to the TV screen from a remote device in part by using something called DIAL (Discovery and Launch Protocol). DIAL was jointly developed by Netflix and Youtube, which is owned by Google. DIAL was actually launched in Google TV, and now it is available in other devices and apps. 

One of the Chromecast’s components, the DIAL Service Discovery Protocol, uses Simple Service Discovery Protocol (SSDP) version 1.1, which is developed by UPnP (Universal Plug and Play), to allow a DIAL client device to locate a DIAL server device running on same network. The other component is the DIAL REST which is used to query, launch or stop applications using HTTP requests from the client device to the server device. 

In case of Chromecast, the phone is the DIAL client and the chromecast device itself is the server. 

Google Created Google Cast Screen sharing technology to work on top of DIAL, adding lot more functionality than DIAL could offer alone. There is a Google Cast SDK which enable developers to add related functionality to third party apps that can be used to launch media from the client to the chromecast. 


Chromecast is actually running a pared-down version of Chrome browser, and the applications running on device are web applications that receive above mentioned HTTP requests and act accordingly. 

References:
http://electronics.howstuffworks.com/chromecast4.htm

Android App in full screen

The Aim was to make a single activity full screen. for this, on the specific activity, done the below programmatically. 

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_clock);

09-26 11:57:38.370  14828-14828/livingmobile.com.eyeome E/AndroidRuntime FATAL EXCEPTION: main
Process: livingmobile.com.eyeome, PID: 14828
java.lang.RuntimeException: Unable to start activity ComponentInfo{livingmobile.com.eyeome/livingmobile.com.eyeome.ClockActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:302)

Some of the options mentioned were to call the requestFeature before the super.onCreate method. 
This intact worked. 

Other options mentioned where to set the theme as 

android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"

android:name="livingmobile.com.eyeome.ClockActivity"
android:label="@string/title_activity_clock"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

However, if the total application theme is 

Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at livingmobile.com.eyeome.ClockActivity.onCreate(ClockActivity.java:34)


We can specify the app theme to be AppCombat as specified in one of the below links.

References:

Friday, September 25, 2015

Android Centering Text views to the center of the Activity

Using relative layout, it can be kind of achieved using the layout parameter keys such as

"http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#000000"
android:id="@+id/rel1">

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10"
android:textSize="65dp"
android:textStyle="bold"
android:id="@+id/textView"
android:textColor="#ffffff"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
android:textSize="65dp"
android:textStyle="bold"
android:id="@+id/textView1"
android:layout_toRightOf="@+id/textView"
android:textColor="#ffffff"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20"
android:textSize="65dp"
android:textStyle="bold"
android:id="@+id/textView3"
android:layout_toRightOf="@+id/textView1"
android:textColor="#ffffff"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="am"
android:textSize="45dp"
android:textStyle="bold"
android:id="@+id/textView4"
android:layout_toRightOf="@+id/textView3"
android:layout_alignBaseline="@+id/textView"
android:textColor="#ffffff"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Saturday, Sep 29"
android:textSize="35dp"
android:textStyle="bold"
android:id="@+id/textView5"
android:layout_below="@+id/textView"
android:textColor="#ffffff"/>



references
http://www.tutorialspoint.com/android/android_relative_layout.htm

Thursday, September 24, 2015

Java PNS Multi threading - sending to multiple devices

Apparently, sending to multiple devices is quite easy in and the code is like below. 

When tried this, below two observations i had

1. With the threading, code that is compiled in MAC when moved to Windows, it appears that the message is not sent properly. Probably we need to compile on Windows Java compiler itself? 
2. It appeared that if no multi threading, the whole program holds and continue after only the message is sent.
3. Without multi threading if application is trying to create a new thread and send the message, 

public void send (List devices, Object keystore, String password, boolean production) {
    
    /* Prepare a simple payload to push */
    PushNotificationPayload payload = PushNotificationPayload.alert("Hello World!");
    
    
    /* Decide how many threads you want to create and use */
    int threads = 30;
    
    
    /* Start threads, wait for them, and get a list of all pushed notifications */
    List notifications = Push.payload(payload, keystore, password, production, threads, devices);
    
    
}



References:
https://code.google.com/p/javapns/wiki/PushNotificationAdvanced

Sunday, September 20, 2015

Essentials of Swift - Learning Part I

Basic Types: Swift uses let to make constants and var to make the variables. 

var myvariable = 42
let myconstant = 42

Every constants and variable has type in Swift. However, it is inferred and no need to be specified explicitly. 

If the initial value doesnt provide enough information (or if there is no initial value), specify the type by writing it after the variable, separated by semi colon. 

let explicitDouble : Double = 70

Values are never implicitly converted to another type. IF we need to convert a value to a different type, explicitly make an instance of desired type. Here, we are converting an int to String 

let label = “Width is”
let widthLabel = label + String (width)

We have an () & \ string interpolation way like below 

let apples = 3
let orange = 2
let apple summary = “i have \(apples) apples”
let fruitSummary = “i have \(apples+orange) fruits”

We can work with Optionals if the value may be missing. An optional value either contains a value or a nil to indicate the value may be missing. We need to write ? after the type of the value to indicate that it is optional. 

let optionalInt : Int? = 0

To get the underlying value form the optional, we just need to unwrap it. the ! is called forced unwrap operator. 

let actualInt: Int = optionalInt!

let myString = “7”
let myString2 = “one”

var possibleInt = Int(myString)
var possibleInt2 = Int(myString2)

print(possibleInt) 
print(possibleInt2)

the above will output as 7 and nil. 

Below is how we can declare an array 

var ratingList = {“poor”, “average”, “good”}
If we want to create an empty array, use the initialize syntax. 
let emptyArray = [String]()

References:

DNS64/NAT64 Transitional workflow

As more clients are using IPv6, the operator must support both IPv4 and IPv6. Ideally providers want to drop support for the IPv4 network. However, doing so prevents clients from accessing IPv4 servers, which represents a significant portion of the internet. To solve this problem, most major network providers are implementing a DNS64/NAT64 transitional workflow. 

In this typical flow, the client sends DNS queries to a DNS64 server, which requests IPv6 addresses from the DNS server. When an IPv6 address is found, it is passed back to the client immediately. However, when an IPv6 address is not found, the DNS64 server requests and IPv4 address. DNS64 server then synthesizes an IPv6 address by prefixing IPv4 address, and passes back to the client. In this regard the client always receives and IPv6 ready address. 

Below is the sequence diagram showing the overall procedure 



When the client sends a request to server, any IPv6 packets destined for synthesized addresses are automatically routed by the network through a NAT64 gateway. The gateway performs IPv4 to IPv6 translation for the response from the server. 

References: