Thursday, December 29, 2011

Bonus on How To: Building Android Application - Part 3


After going through the Part 1 and Part 2 of “How To: Building Android Application”, we will go explore more on the android sample and some tips to improve the performance of the emulator.

Playing with Android Sample Application


In this tutorial, we will setup the Android sample application which will help you play with most of the android components.

Step1: click on File->New->Other and then select Android->Android Sample Project

click Next and Finish.

in case you see “ This target has no samples. Please select another target.” message, you should click Windows->Android SDK Manager and select the sample and other versions (if needed) and Install the packages. This step will take a while. After that is done, retry Step 1.

useful emulator Shortcuts:


Alt+Enter maximizes the emulator. Nice for demos.

Ctrl+F11 changes the orientation of the emulator.

F8 turns network on / off.

F6 to turn on / off the trackball

Performance Considerations


Try to use a smaller resolution for your emulator as for example HVGA. The emulator gets slower the more pixels its needs to render as it is using software rendering.
While creating device (e.g. myDevice), set the flag "Enabled" for Snapshots. This will save the state of the emulator and let it start much faster.

Sunday, December 18, 2011

Transactional Memory in GCC

Transactional memory is intended to make programming with threads simpler, in particular synchronizing access to data shared between several threads using transactions. As with databases, a transaction is a unit of work that either completes in its entirety or has no effect at all (i.e., transactions execute atomically). Further, transactions are isolated from each other such that each transaction sees a consistent view of memory.

 

Two operations conflict if one of them modifies a memory location and the other one
accesses or modifies the same memory location. The execution of a program contains a data race if it
contains two conflicting operations in different threads, at least one of which is not an atomic operation,
and neither happens before the other. Any such data race results in undefined behavior. A program is race free if none of its executions contain a data race. In a race-free program each read from a memory location
sees the value written by the last write ordered before it by the “happens-before” relationship.

 

Outermost transactions (that is, transactions that are not dynamically nested within other
transactions) appear to execute sequentially in some total global order that contributes to the
“synchronizes with” relationship. Conceptually, every outermost transaction is associated with
StartTransaction and EndTransaction operations, which mark the beginning and end of the
transaction.2 A StartTransaction operation is sequenced before all other operations of its
transaction. All operations of a transaction are sequenced before its EndTransaction operation.

 

A shared memory access can form a data race even if it is performed in a transaction
statement. In the following example, a write by thread T2 forms a data race with both read and
write to x by Thread T1 because it is not ordered with the operations of Thread T1 by the
“happens-before” relationship. To avoid a data race in this example, a programmer should
enclose the write to x in Thread T2 in a transaction statement.

Thread T1

__transaction {
t = x;
x = t+1;
}

Thread T2

x = 1;

Atomic transactions:
A transaction statement without an attribute or annotated with the atomic attribute defines an
atomic transaction. We call such a statement an atomic transaction statement:

__transaction compound-statement
__transaction [[ atomic ]]compound-statement

Safety attributes on functions and function pointers:

To ensure that atomic transactions can be executed atomically, certain statements must not be
executed within atomic transactions; we call such statements unsafe.

In order to specify whether a function is safe, the function declaration may specify transaction_safe or transaction_unsafe attribute.

Memory model;
The memory model rules for transactions (Section 2.1) are sufficient to guarantee that in race
free programs, atomic transactions appear to execute as single indivisible operations. Atomic
transactions cannot contain other forms of synchronization (such as operations on locks or C++0x
atomic operations).

In the following example, both a and b will be read and the difference will be written to c, all atomically and isolated from other transactions:

__transaction_atomic { c = a - b; }
Therefore, another thread can use the following code to concurrently update b without ever causing c to hold a negative value (and without having to use other synchronization constructs such as locks or C++11 atomics): __transaction_atomic { if (a > b) b++; }

 

refer: C++-transactional-constructs-1.0.pdf

 

Saturday, December 17, 2011

How To: Building Android Application with easy steps–Part 2

This is in the continuation of my previous post “How To: Building Android Application with easy steps–Part 1”. In this tutorial, we will go over creating the sample application using the environment we have already setup.

Here is the details of the application we will build:
Number Counting: providing the buttons to increment/decrement the number present in the text box

 

Step 1: create Android project


Select File → New → Other → Android → Android Project and create the Android project named

com.hashfold.android.numbercounting

image

click Next and select the Android SDK version on which your application will be build and compiled.

image

note: selecting the Android 2.1 is the best options as 90% of Android devices till date are based on this version.

Click next and make sure the information filled is matching with below:

image

and then click Finish

note: numbercountingActivity is the name of the activity which will get started when the application starts

here is the final project view after above steps:

image

 

image

 

Step 2: writing application code


so far we have completed creating the project space. Now its time to do some coding and creating the GUI components.

2.1 AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hashfold.android.numbercounting"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name="com.hashfold.android.numbercountingActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

2.2 strings.xml


<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="details">number counting application</string>
<string name="hello">Hello! number counting!</string>
<string name="app_name">NumberCounting</string>
<color name="bgcolor">#000000</color>
</resources>

2.3 main.xml layout – the GUI component


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/bgcolor">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:text="+" android:id="@+id/Plus"></Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:id="@+id/Minus" android:text="-"></Button>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:id="@+id/Value" android:text="value"></TextView>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:text="Ok" android:id="@+id/Ok"></Button>
</LinearLayout>

</LinearLayout>

2.4 numbercountingActivity.java


package com.hashfold.android;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.hashfold.android.numbercounting.R;

public class numbercountingActivity extends Activity implements OnClickListener
{
Button Plus, Minus, Ok;
TextView Value;
int score = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Plus = (Button) findViewById(R.id.Plus);
Minus = (Button) findViewById(R.id.Minus);
Ok = (Button) findViewById(R.id.Ok);
Value = (TextView) findViewById(R.id.Value);

Plus.setOnClickListener(this);
Minus.setOnClickListener(this);
Ok.setOnClickListener(this);

}

public void onClick(View v)
{
boolean showText = false;

switch(v.getId())
{
case R.id.Plus: score++; showText = true; break;
case R.id.Minus: score--; showText = true; break;
case R.id.Ok: showText = true; break;
}
if(showText)
Value.setText(String.valueOf(score));
}
}

The R.java is the resource file which is auto generated based on strings.xml and other related resource changes.

Step 3: running the application


setup the run configuration: click on Run->Run configurations

image

and then click on ‘New launch configuration’ and then fill in the information needed as below:

image

image

now click on Apply button and then Run button to run the application.

It will take a while in starting up the Android device emulator with the device select in above step “myDevice”.

Once the device is started, it will look like below:

image

now click on the plus “+” button and see how the application performs

image

If you wish you could start device in full screen mode by pressing Alt+Enter.

image

This helps in having full view of the application.

Having a different orientation view (click Ctrl+F11)

image

turn off the internet (click F8)

image

toggle the internet (click F8)

image

Monday, December 12, 2011

How To: Building Android Application with easy steps–Part 1

What is Android?





Android is a software stack for mobile devices that includes an operating system, middleware and key applications. The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.

Below are the steps to prepare the Android environment before really getting into the development:



Step 1. Download Eclipse


1.1 click Eclipse Classic


1.2 save the .zip file and extract it to your preferred location


image

Step 2. Installing Android SDK


2.1 start eclipse by clicking on the eclipse application extracted as shown in the above image.


2.2 now click on Help->Install New Software… option which will launch the below window:


image

2.3 now put https://dl-ssl.google.com/android/eclipse/ under “Work with” option and click on Add button.


2.4 type name ‘android’ in the new popup window and click OK


image

2.5 select All components and click Next


image

2.6 Click next in the next screen and then select “I Accept the terms…” and click Finish


image

the new window will popup to start downloading of the SDK ad shown below:

image

2.7 click OK on any warning message window


image

2.8 restart the eclipse


image

2.9. eclipse restart done and a new window shown to select where to install the SDK


image
select the location and click Finish

2.10 have patience, the installation step will take a while to download Android SDK as well as Google APIs.


Eclipse will now look like this…

image

2.11 make sure things are installed correctly.


click on Window->Preferences->Android

the details should show what you have just downloaded

image

Step 3. creating Android device


Android emulator runs on a specific device type. There are lots of android devices available on market.
The AVD Manager (AVD – android virtual device) have almost all of them configured. What you need to do is to create one of them in AVD Manager for your testing purposes. You can always create different device types and test the application before publishing to the android market.

Click on Windows->AVD Manager

image

Now click on New and fill the device information and click Create Device

image

image

At this moment, the eclipse is setup with the Android SDK and it is ready to be used.

Add-On: how to download and install


different version of the Android SDK?


So far we know that SDK version is used in creating the virtual device (using AVD Manager mentioned in Step 3 above). If there is a requirement to test the application on different device, then you need to make sure you have that version of the SDK available in your system. In order to download the new version, do below:

1. click Windows->Android SDK Manager
2. select required packages and then click “Install *** packages…”
3. in the next window, click on “Accept all” and click Install button
it will take a while to download and setup new SDK

In our next tutorial, we will go through the steps and create a sample application from scratch.

put your comments in case you have any questions for me to answer about these steps.

 

reference: http://developer.android.com/index.html

Saturday, December 10, 2011

Getting a job in software development

 

There are lots of question-answer websites where people discuss their problems and try to find the possible solutions using the crowd (well known as crowdsourcing). Some of these sites are quora.com, chacha.com, stackoverflow.com, stackexchange.com and experts-exchange.com. Searching these sites for a specific topic, will bring you a lots of links which may not be relevant to your topic or questions you are looking for. Sometimes you may need to prepare the good list of articles related to a given topic using the best answered/discussed materials on these sites.

StackOverflow.com has done a really great job to prepare and present them in a good format. One of them is about Scala. You may check it out at: http://stackoverflow.com/tags/scala/info

 

While browsing through the HN, I encountered a post by WalterGR who have done a similar job for helping others.

This is a re-post of a reddit post for my users which was collected by WalterGR user.  While the job hunt, Walter had collected the reddit posts which he thought may be useful for others.

 

 

references:

http://hashfold.com/techfold/scala-the-programming-language-2/

http://www.reddit.com/r/cscareerquestions/comments/n5spv/getting_a_job_in_software_development_a_reddit/

 

 

 

Monday, November 7, 2011

How to turn your laptop into Hotspot WiFi

Today I came across a site connectify.me. At first I was surprised on how they have programmed the creation of personal hotspot capability which latest Windows OS provide.

Here is how it looks when the laptop acts as hotspot wifi…

connectify demo

The way Windows supports natively. Sometimes this process could be cumbersome for newbies.

hotspot wifi using windows Vista feature

Here comes the Connectify.me which just automates the process…

 

hotspot wifi using Connectify on windows

 

hope this is a useful information for some of my readers.

Sunday, November 6, 2011

Test Driven Development using EasyMock

 

Test driven development (TDD) is a critical component of software development. If a component is not well tested, its said to be broken. Suppose you are writing the temperature conversion component and you would like to make sure it works on all scenarios before handing it over to QA team. What and how do we do making sure at least from development perspective things are not broken and developers have pretty good confidence on what they are delivering. Here are the things developers prefer to do in order to avoid the issues which come late in the product life cycle (PDLC):

* test component locally and manually
* test with load of the data and making sure tests pass with the data set
* write junit which gets tested when the code is build

The first two steps are developer driven which is hard to replay every time there is a new release of upgrade of the software. The last option (junit) is basically used to automate what developer has tested manually.

You could find a lots of junit tutorials on line on how to write the junit test cases. Junits help you test your code however sometimes there are some components hidden deep inside the code hierarchy which becomes hard to simulate. Then how do we fake those hidden components/methods/APIs to behave on a given inputs and provide expected results?

The answer is mock-objects. How mock-objects replay/proxy the hidden objects and behave as per your requirements? There's deep, dark magic here, coming from a combination of Java 5 generics and dynamic proxies introduced way back in Java 1.3. Fortunately, you don't need to understand how it works in order to use it.

mock-object?: Mocking allows you to test a class or method in isolation. In other words: “A mock object is a dummy interface or class in which you define the dummy output of a certain method call.”

How EasyMock works?

* create a mock object

it is used to create the mock object of the class interface we are trying to create poxy and simulate.

MyInterface mock = createMock ( MyInterface.class );


* record behavior of the mock object

training the mock by making expected method calls on it.

expect( mock.doStuff( "argument" )).andReturn( "returnValue" );


* replay the behavior

it tells EasyMock framework to stop recording the behavior and gets ready to return data as per expectation when it gets called.

replay( mock );


* executing the user code which we need to test (this codebase calls the method which is mocked)

AssertEquals(5, test.perform()); //assume perform() method calls doStuff() method.


* verify the behavior

method checks to see if the mock actually received all the calls you expect. The method is used to make sure that all of the behavior expected from the collaborators is valid.

verify(mock);


Its so easy as that. to get more details on downloading the jar files for easymock, check easymock.org site. Here is the snippet of the pom.xml file which is used to introduce dependency on easymock library so that the code once build could utilize the framework.

 

<dependency>

<groupId>org.easymock</groupId>

<artifactId>easymockclassextension</artifactId>

<version>2.4</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.easymock</groupId>

<artifactId>easymock</artifactId>

<version>2.4</version>

<scope>test</scope>

</dependency>

 

 

Have a closer look at above pom artifacts and you will notice that we have included ‘easymockclassextensio’ library. What it is used for? It is used in some advanced testing scenarios e.g.

Sometimes you may need to mock only some methods of a class and keep the normal behavior of others. This usually happens when you want to test a method that calls some others in the same class. So you want to keep the normal behavior of the tested method and mock the others.

ToMock mock = createMock(ToMock.class, new Method[] { ToMock.class.getMethod("mockedMethod", null) } );

Additional use cases:


To Throw An Exception




expect(mock.method()).andThrow(expectedException);




Expecting A Method With void Return Type




mock.clear();





ExpectLastCall();




Need to mention no. Of calls




expectLastCall().times(3);




Types of EasyMock:



Normal — createMock(): All of the expected methods must be called with the specified arguments regardless of the order. Calls to unexpected methods cause the test to fail.



Strict — createStrictMock(): All expected methods must be called with the expected arguments, in a specified order. Calls to unexpected methods cause the test to fail.



Nice — createNiceMock(): All expected methods must be called with the specified arguments in any order. Calls to unexpected methods do not cause the test to fail.





How to do repeated calls to methods?



By default mock expects minimum 1 call.



* times(int min, int max) : to expect between min and max calls,



* AtLeastOnce() : to expect at least one call, and



* AnyTimes() : to expected an unrestricted number of calls.



 



References:



EasyMock: http://www.easymock.org


easymockclassextension: http://easymock.org/EasyMock2_0_ClassExtension_Documentation.html


Introduction to TDD: http://www.agiledata.org/essays/tdd.html

Monday, October 31, 2011

Writing Queue Data Structure In C++

on the same line of our previous post, here is how to write Queue in c++:

[cpp]
<pre>
#include <iostream.h>

struct node
{
int data;
node *link;
};

class queue
{
private:
node *front, *rear;

public:

queue()
{
front = rear = NULL;
}

void addq(int item)
{
node *temp;

temp = new node;

if(temp == NULL)
cout << endl << "Queue is full";

temp->data = item;
temp->link = NULL;

if(front == NULL)
{
rear = front = temp;
return;
}

rear->link = temp;
rear = rear->link;
}

int delq()
{
if(front == NULL)
{
cout << endl << "Queue is empty";
return;
}

node *temp;
int item;

item = front->data;
temp = front;
front = front->link;
delete temp;
return item;
}

~queue()
{
if(front == NULL)
return;
node *temp;
while(front != NULL)
{
temp = front;
front = front->link;
delete temp;
}
}
};</pre>
[/cpp]

Friday, October 28, 2011

Writing Stack Data Structure in C++

on the same line of our previous post, here is how to write Stack in c++:

[cpp]
//stack program
#include <iostream.h>

struct node
{
int data;
node *link;
};

class stack
{
private:
node *top;

public:

stack()
{
top = NULL;
}

void push(int item)
{
node *temp;

temp = new node;
if(temp == NULL)
cout << endl << "Stack is full";

temp->data = item;
temp->link = top;
top = temp;
}

int pop()
{
if(top == NULL)
{
cout << endl << "Stack is empty";
return NULL;
}

node *temp;
int item;

temp = top;
item = temp->data;
top = top->link;
delete temp;
return item;
}

~stack()
{
if(top == NULL)
return;

node *temp;

while(top != NULL)
{
temp = top;
top = top->link;
delete temp;
}

}
};//end class stack

void main()
{
stack a;

s.push(4);
s.push(26);
s.push(12);
s.push(7);
s.push(19);
s.push(90);

int i = s.pop();
cout << endl << "Item popped = " << i;

i = s.pop();
cout << endl << "Item popped = " << i;

i = s.pop();
cout << endl << "Item popped = " << i;
}
[/cpp]

Wednesday, October 26, 2011

Writing Tree data structure in C++

I was browsing through the Facebook and encountered ProudEngineers page. The implementation provided there is awesome.
After going through it, I couldn't resist to mention on this blog so that our readers like you could also benefit from it.
Here is the code:
[cpp]
#include <iostream.h>

#define TRUE 1
#define FALSE 0

class tree
{

private:

struct node
{
node *l;
int data;
node *r;
}*p;

public:

tree();
void search(int n, int &found, node * &parent);
void insert(int n);
void traverse();
void in(node *q);
void pre(node *q);
void post(node *q);
int operator == (tree t);
int compare(node *pp, node *qq);
void operator = (tree t);
node * copy (node * q);
};

tree::tree()
{
p = NULL;
}

void tree::search(int n, int &found, node * &parent)
{
node *q;
found = FALSE;
parent = NULL;

if(p == NULL)
return;

q = p;
while(q != NULL)
{
if(q->data == n)
{
found = TRUE;
return;
}

if(q->data > n)
{
parent = q;
q = q->l;
}
else
{
parent = q;
q = q->r;
}

}
}

void tree::insert(int n)
{
int found;
node *t,*parent;

search(n, found, parent);

if(found == TRUE)
cout << endl << "such a node already exists";
else
{
t = new node;
t->data = n;
t->l = NULL;
t->r = NULL;

if(parent == NULL)
p = t;
else
parent->data > n?parent->l = t:parent->r = t;
}
}

void tree::traverse()
{
int choice;

cout << endl << "1. Inorder"
<< endl << "2. Preorder"
<< endl << "3. Postorder"
<< endl << "Your choice ";
cin >> choice;

switch(choice)
{
case 1:
in(p);
break;

case 2:
pre(p);
break;

case 3:
post(p);
break;
}

}

void tree::in(node *q)
{
if(q != NULL)
{
in(q->l);
cout << "\t" << q->data;
in(q->r);
}
}

void tree::pre(node *q)
{
if(q != NULL)
{
cout << "\t" << q->data;
pre(q->l);
pre(q->r);
}
}

void tree::post(node *q)
{
if(q != NULL)
{
post(q->l);
post(q->r);
cout << "\t" << q->data;
}
}

int tree::operator == (tree t)
{
int flag;

flag = compare(p, t.p);
return flag;
}

int tree::compare(node *pp, node *qq)
{
static int flag;

if((pp == NULL) && (qq == NULL))
flag = TRUE;
else
{
if((pp != NULL) && (qq != NULL))
{
if(pp->data != qq->data)
flag = FALSE;
else
{
compare(pp->l,qq->l);
compare(pp->r,qq->r);
}
}
}

return (flag);
}

void tree::operator = (tree t)
{
p = copy(t.p);
}

tree::node * tree:: copy(node *q)
{
node *t;

if(q != NULL)
{
t = new node;
t->data = q->data;
t->l = copy(q->l);
t->r = copy(q->r);
return (t);
}
else
return (NULL);
}

void main()
{
tree tt, ss;
int i, num;

for(i=0; i <= 6; i++)
{
cout << endl << "Enter data for the node to be inserted : ";
cin >> num;
tt.insert(num);
}

tt.traverse();
ss = tt;
ss.traverse();

if(ss == tt)
cout << endl << "Trees are equal";
else
cout << endl << "Trees are unequal";
}
[/cpp]

Monday, October 24, 2011

Apple iOS5 features

iOS 5 Software Update

This update contains over 200 new features, including the following:

Notifications
    ◦    Swipe from the top of any screen to view notifications in one place with Notification Center
    ◦    New notifications appear briefly at the top of the screen
    ◦    View notifications from lock screen
    ◦    Slide the notification app icon to the right on the lock screen to go directly to the app

 iMessage
    ◦    Send and receive unlimited text, photo, and video messages with other iOS 5 users
    ◦    Track messages with delivery and read receipts
    ◦    Group messaging and secure encryption
    ◦    Works over cellular network and Wi-Fi*


 Newsstand
    ◦    Automatically organizes magazine and newspaper subscriptions on Home Screen
    ◦    Displays the cover of the latest issue
    ◦    Background downloads of new issues
    •    Reminders for managing to do lists
    ◦    Syncs with iCloud, iCal and Outlook
    ◦    Location-based reminders when you leave or arrive at a location for iPhone 4S and iPhone 4


Built-in support for Twitter
    ◦    Sign-in once in Settings and tweet directly from Camera, Photos, Maps, Safari and YouTube
    ◦    Add location to any tweet
    ◦    View twitter profile pictures and usernames in Contacts
 

Camera improvements for devices with cameras
    ◦    Double click the home button when device is asleep to bring up a camera shortcut on iPhone 4S, iPhone 4, iPhone 3GS and iPod touch (4th generation)
    ◦    Volume Up button to take a picture
    ◦    Optional grid lines to line up shots
    ◦    Pinch to zoom in the preview screen
    ◦    Swipe to camera roll from preview screen
    ◦    Tap and hold to lock focus and exposure, iPad 2 and iPod touch (4th generation) only support exposure lock

Photo improvements for devices with cameras
    ◦    Crop and rotate
    ◦    Red eye removal
    ◦    One tap enhance
    ◦    Organize photos into albums

Mail improvements
    ◦    Format text using bold, italic, or underlined fonts
    ◦    Indentation control
    ◦    Drag to rearrange names in address fields
    ◦    Flag messages
    ◦    Mass mark messages as flagged, read or unread
    ◦    Customize mail alert sounds
    ◦    S/MIME

Calendar improvements
    ◦    Year view on iPad and new Week view for iPhone and iPod touch
    ◦    Tap to create an event
    ◦    View and add event attachments

Game Center improvements
    ◦    Use personal photos for your Game Center account
    ◦    Compare your overall achievement scores with your friends
    ◦    Find new Game Center friends with friend recommendations and friends of friends
    ◦    Discover new games with custom game recommendations

AirPlay Mirroring for iPad 2 and iPhone 4S

Multitasking Gestures for iPad
    ◦    Use four or five fingers to pinch to the Home Screen
    ◦    Swipe up to reveal the multitasking bar
    ◦    Swipe left or right to switch between apps

On-device setup, activation and configuration with Setup Assistant

Software updates available over the air without tethering

iCloud support
    ◦    iTunes in the Cloud
    ◦    Photo Stream
    ◦    Documents in the Cloud
    ◦    Apps and Books automatic download and purchase history
    ◦    Backup
    ◦    Contacts, Calendar, and Mail
    ◦    Find My iPhone

Redesigned Music app for iPad

Hourly weather forecast

Real-time stock quotes

Wireless sync to iTunes

Keyboard improvements
    ◦    Split keyboard for iPad
    ◦    Improved autocorrection accuracy
    ◦    Improved Chinese and Japanese input
    ◦    New Emoji keyboard
    ◦    Personal dictionary for autocorrection
    ◦    Optionally create keyboard short cuts for frequently used words

Accessibility improvements
    ◦    Option to light LED flash on incoming calls and alerts for iPhone 4S and iPhone 4
    ◦    Custom vibration patterns for incoming calls on iPhone
    ◦    New interface for using iOS with mobility-impairment input devices
    ◦    Option to speak a selection of text
    ◦    Custom element labeling for VoiceOver

Exchange ActiveSync improvements
    ◦    Wirelessly sync tasks
    ◦    Mark messages as flagged, read or unread
    ◦    Improved offline support
    ◦    Save a new contact from a GAL service

More than 1,500 new developer APIs

Bug fixes

Products compatible with this software update:
    •    iPhone 4S
    •    iPhone 4
    •    iPhone 3GS
    •    iPad 2
    •    iPad
    •    iPod touch (4th generation)
    •    iPod touch (3rd generation)

* Normal carrier data rates may apply. Messages will be sent as SMS when iMessage is unavailable, carrier messaging fees apply.

 

via Apple iTunes.

Thursday, October 20, 2011

comparison of Java Map vs HashMap vs HashTable vs HashSet

Hashes in Java are robust. They all seems to be similar however there are some differences we should pay close attention to them before selecting one to use in the design. Below is the list of these Hashes with specific features on how they different from each other:

Map

. it is an interface

. An object that maps keys to values

. A map cannot contain duplicate keys; each key can map to at most one value.

. This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.

.example

[java]
Map<String, Integer> m = new HashMap<String, Integer>();
[/java]

HashMap

. not an interface

. it is unsynchronized. So come up with better performance

. Permits nulls

. allows null values as key and value

. does not guarantee that the order of the map will remain constant over time.

.example

[java]
HashMap<Integer,String> productMap = new HashMap<Integer,String>();

productMap.put(1, "Keys");

productMap.put(2, null);
[/java]

HashTable

. doesn’t allows null values as key and value. You will get NullPointerException if you add null value.

. is synchronized. So it comes with its cost. Only one thread can access in one time

.example:

[java]
Hashtable<Integer,String>; cityTable = new Hashtable<Integer,String>();

cityTable.put(1, "New York");

cityTable.put(2, "San Franscisco");

cityTable.put(3, null); /* NullPointerEcxeption at runtime*/

System.out.println(cityTable.get(1));

System.out.println(cityTable.get(2));

System.out.println(cityTable.get(3));
[/java]

HashSet

. does not allow duplicate values.

.  It provides add method rather put method.

. it can be used where you want to maintain a unique list.

. example

[java]
HashSet<String> stateSet = new HashSet<String>();

stateSet.add ("CA");

stateSet.add ("WI");

stateSet.add ("NY");

if (stateSet.contains("PB")) /* if CA, it will not add but shows following message*/

System.out.println("Already found");

else

stateSet.add("PB");
[/java]

put your comments/feedback in the comment box.

Monday, October 17, 2011

Youtube Insult Generator

Insult Generator is a basically a "search engine for insults." Type in a search term, and it'll give you insults you can use against a person who doesn't like that term.

for example, enter the term "usa" and you will get below results:
You aren't american #
You have no heart :(
You need to diaf
You don't have an ocean...
You cant surf!
You are jealous

Each insult includes a link to its source YouTube video.

How does this search engine work?
1. It uses the YouTube API to search for the top 50 most relevant videos for your search term.
2. For each of those videos, it grabs the latest 50 comments.
3. Then it looks through all that for comments starting with a number followed by a word such as "people," "youtubers" or "nincompoops." (View source for the full list, a regular expression that would make Alex Gaynor proud.)
4. Finally, it just replaces the number and the word "people" with "You."

Insult Generator does work for 50% of times however when it works, it does pull amazing results.

click here to try it out!

!!!Insult!!!

*** don't abuse. use it wisely ***

Sunday, October 16, 2011

Scala - the programming language

What is Scala?

Scala is a general purpose programming language principally targeting the Java Virtual Machine. Designed to express common programming patterns in a concise, elegant, and type-safe way,
it fuses both imperative and functional programming styles.
It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive.
Its key features are: statically typed; advanced type-system with type inference; function types; pattern-matching; implicit parameters and conversions; operator overloading; full interop with Java

Where to download it from? http://www.scala-lang.org/

Scala on Cloud: Heroku the popular cloud service provider is supporting the Scala.

Key Features:

  • Statically typed
  • Advanced type-system with type inference and declaration-site variance
  • Function types (including anonymous) which support closures
  • Pattern-matching
  • Implicit parameters and conversions which support the typeclass and pimp my library patterns
  • Mixin composition
  • Full interop with Java

Scala Video Tutorials:

Understanding Scala and It’s Importance:

Your First Application in Scala using Eclipse:

:

Scala Tutorial Part 1


Scala Tutorial Part 2

 

Scala Tutorial Part 3

Scala Tutorial from Stackoverflow:

  1. Introduction to Scala
  2. Variables/values
  3. Methods
  4. Literals, statements and blocks
  5. Loops/recursion
  6. Data structures / Collections
  7. For-comprehension
  8. Enumeration
  9. Pattern-matching
  10. Classes, objects and types
  11. Packages, imports and visibility identifiers
  12. Inheritance
  13. Extractors
  14. Case classes
  15. Parameterized types
  16. Traits
  17. Self references
  18. Error handling
  19. Type handling
  20. Annotations
  21. Functions/Function literals
  22. Type safety
  23. Implicits
  24. Pimp-my-library pattern
  25. Actors
  26. Use Java from Scala and vice versa
  27. XML literals
    • Explanation
  28. Scala Swing
  29. Type Programming
  30. Functional Scala

Further learning

  1. Learning Resources
  2. Operator precedence
  3. Scala blogs to follow
  4. Scala style

Scala Slides and Videos: