Downgrading the Xperia 2011 phones to Ginger Bread in 5 simple steps

Tags

, , , , ,

Since the announcement from Sony has come that all the Xperia 2011 line-up will not be upgraded beyond Ice Cream Sandwich, many people due to the poor performance of ICS will be willing to downgrade their Xperia 2011 phones to Ginger Bread.

Here I am going to explain the steps in detail for downgrading to Ginger Bread. Please follow all the steps carefully else you are in the danger of bricking your phone.

If you are not sure that you can do it on your own it’s better you hand your phone to Sony Service Center and ask them to downgrade it for you. Else be a man and follow the steps.

Prerequisites:

  • FlashTool by Androxyl.
  • A Ginger Bread ROM according to your phone model (Select a build number that you want).
XPERIA 4.0.2.A.0.42
4.0.2.A.0.58
4.0.2.A.0.62
Arc S 4.0.2.A.0.42 4.0.2.A.0.62 or Link 2
Arc 4.0.2.A.0.42 4.0.2.A.0.62
Neo V 4.0.2.A.0.42 4.0.2.A.0.62
Neo 4.0.2.A.0.42 4.0.2.A.0.62
Ray 4.0.2.A,0.42 4.0.2.A.0.62
Pro (*) 4.0.2.A.0.42 4.0.2.A.0.62
Play 4.0.2.A.0.42 4.0.2.A.0.62
Live with walkman 4.0.2.A.0.42   4.0.2.A.0.58 4.0.2.A.0.62
Mini 4.0.2.A.0.42 4.0.2.A.0.62
Mini Pro (*) 4.0.2.A.0.42
Active 4.0.2.A.0.42

Now after you have downloaded both the FlashTool and GB ROM the Party starts.

Step 1: Install the FlashTool (I will consider that it is installed in C:/Flashtool/ ).

Step 2: Now extract the .tft file from the GB ROM and place it in C:/Flashtool/firmwares/ (Remove any other already existing files).

Step 3: Run the Flashtool and click on the Flash icon and then select “flash mode” and click “ok”.

Step 4: Select the Firmware that you want to flash and then on the right pane make sure it appears as follows.

Step 5: Select “ok” and then follow the instructions when asked to connect the phone. It takes a while and then voila……!!!! The most stable Android version is in your phone 🙂 🙂

Designing the iPhone 5

Tags

, , , , , , , ,

The iPhone 5 released has many unique feature that allows it to stand out from the other Smart Phones out there in the market.

Design:

The new iPhone 5 has a remarkably thin and light design.The following is a quote by Apple on iPhone 5’s design.

“We could have taken the easy way out and designed something more reasonable and less remarkable. But we didn’t. If the technology didn’t exist, we invented it. If a component wasn’t small enough, we re-imagined it. If convention was standing in the way, we left it behind. The result is iPhone 5: the thinnest, lightest, fastest iPhone ever.”

To achieve this thin phone, the people had done a great job.They had to think small

1.nano-SIM – This is 44% smaller than the micro-SIM.

2.Two Chips – The voice and the data chip is built into a single chip.

3.The Lightning Connector – It is reversible and 80% smaller than the 30-pin connector.

4.Camera – The Camera has new features like Panorama and Dynamic low-light mode yet it’s 20% smaller.

5.Processor(A6 Chip) – It is 2x Faster than A5 chip yet it’s 22% smaller.

And thus the resulting iPhone to be


18% Thinner

20% Lighter

12% Less Volume

 

 

 

The Aluminum and Glass Body:

The back of iPhone 5 is made of anodized 6000 series aluminum — the same material used in Apple notebooks — with inlays along the top and bottom made of ceramic glass (on the white and silver model) or pigmented glass (on the black and slate model).

Sapphire Crystal:

Although the surface of the iSight camera is as clear as glass, it’s not made of glass. It’s actually sapphire crystal, whose hardness is second only to diamond on the scale of transparent materials. That means the surface of the lens is far less likely to scratch.

Diamond-Cut Beveled Edge:

A crystalline diamond is used to cut the chamfers of iPhone 5. This process gives the beveled edge its beautiful sheen.

Also the phone has the thinnest display ever. From the above design features we well understand that the iPhone 5 is molded carefully with mother’s love. So how would a Samsung Galaxy S III be superior to such a Super Smart Phone?

The Basic Approach to any Dynammic Programming Problem

Tags

, , ,

The Following is an Answer given by Quorian Michal Danilak when asked about DP. I was really impressed by the way he answered, so i am blogging it.

Dynamic programming is a very specific topic in programming competitions. No matter how many problems have you solved using DP, it can still surprise you. But as everything else in life, practice makes you better 😉

Other answers in this thread mention some nice introductory texts that will help you understand what DP is and how it works. In the following few paragraphs I will try to show you how to come up with solutions for DP problems.

Note: the process of creating a DP solution, I describe below, is directly applicable for all the Div1-250 problems and many of Div1-500 problems on TopCoder which can be solved with DP. Harder problems usually requires some alternation in the process which you will be able to do, after some practice.

Note 2: the source code samples below are written in C++. If you don’t know the language or are unsure of something, please ask me in comments.

Iteration vs. recursion

After you read some introductory texts on dynamic programming (which I highly recommend), pretty much all the source code examples in them use bottom-up technique with iteration (i.e. using for-cycles). For example calculating the length of the longest common subsequence of two strings A and B of length N, would look like this:

int dp[N+1][N+1];
for (int i = 0; i <= N; ++i)
dp[0][i] = dp[i][0] = 0;
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= N; ++j) {
dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
if (A[i-1] == B[j-1])
dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
}

int answer = dp[N][N];

There are couple of reasons why it is coded in this way:

  1. iteration is much faster than recursion
  2. one can easily see time and space complexity of the algorithm
  3. source code is short and clean

Looking at such source code, one can understand how and why it works, but it is much harder to understand how to come up with it.

The biggest breakthrough in my learning of dynamic programming was, when I started to think about the problems in the top-down fashion, instead of bottom-up.

On the first look it doesn’t look as such a revolutionary insight, but these two approaches directly translates in two different source codes. One uses iteration (bottom-up fashion) and the other one uses recursion (top-down fashion). The latter one is also called the memoization technique. The two solutions are more or less equivalent and you can always transform one into the other.

In the following paragraphs I will show you how to come up with a memoization solution for a problem.

Motivation problem

Imagine you have a collection of N wines placed next to each other on a shelf. For simplicity, let’s number the wines from left to right as they are standing on the shelf with integers from 1 to N, respectively. The price of the i-th wine is pi (prices of different wines can be different).

Because the wines get better every year, supposing today is the year 1, on year ythe price of the i-th wine will be y*pi, i.e. y-times more than the current year.

You want to sell all the wines you have, but you want to sell exactly one wine per year, starting on this year. One more constraint – on each year you are allowed to sell only either the leftmost or the rightmost wine on the shelf and you are not allowed to reorder the wines on the shelf (i.e. they must stay in the same order as they are in the beginning).

You want to find out, what is the maximum profit you can get, if you sell the wines in optimal order.

So for example, if the prices of the wines are (in the order as they are placed on the shelf, from left to right): p1=1, p2=4, p3=2, p4=3
The optimal solution would be to sell the wines in the order p1, p4, p3, p2 for a total profit 1*1 + 3*2 + 2*3 + 4*4 = 29

Wrong solution

After playing with the problem for a while, you’ll probably get the feeling, that in the optimal solution you want to sell the expensive wines as late as possible. You can probably come up with the following greedy strategy:

Every year, sell the cheaper of the two (leftmost and rightmost) available wines.

Although the strategy doesn’t mention what to do when the two wines cost the same, this strategy kinda feels right. But unfortunately, it isn’t, as the following example demonstrates. If the prices of the wines are: p1=2, p2=3, p3=5, p4=1,p5=4

The greedy strategy would sell them in the order p1, p2, p5, p4, p3 for a total profit 2*1 + 3*2 + 4*3 + 1*4 + 5*5 = 49

But we can do better if we sell the wines in the order p1, p5, p4, p2, p3 for a total profit 2*1 + 4*2 + 1*3 + 3*4 + 5*5 = 50

This counter-example should convince you, that the problem is not so easy as it can look on a first sight and I will tell you, that it can be solved using DP.

Write a backtrack

When coming up with the memoization solution for a problem, I always start with a backtrack solution that finds the correct answer. Backtrack solution enumerates all the valid answers for the problem and chooses the best one. For most of the problems it is easy to come up with such solution.

Here are some restrictions I put on a backtrack solution:

  • it should be a function, calculating the answer using recursion
  • it should return the answer with return statement, i.e. not store it somewhere
  • all the non-local variables that the function uses should be used as read-only, i.e. the function can modify only local variables and its arguments.

So for the problem with wines, the backtrack solution will look like this:

int p[N]; // read-only array of wine prices

// year represents the current year (starts with 1)
// [be, en] represents the interval of the unsold wines on the shelf
int profit(int year, int be, int en) {
// there are no more wines on the shelf
if (be > en)
return 0;

// try to sell the leftmost or the rightmost wine, recursively calculate the
// answer and return the better one
return max(
profit(year+1, be+1, en) + year * p[be],
profit(year+1, be, en-1) + year * p[en]);
}

We can get the answer by calling:

int answer = profit(1, 0, N-1); // N is the total number of wines

This solution simply tries all the possible valid orders of selling the wines. If there are N wines in the beginning, it will try 2^N possibilities (each year we have 2 choices). So even though now we get the correct answer, the time complexity of the algorithm grows exponentially.

The correctly written backtrack function should always represent an answer to a well-stated question. In our case profit function represents an answer to a question: “What is the best profit we can get from selling the wines with prices stored in the array p, when the current year is year and the interval of unsold wines spans through [be, en], inclusive?”
You should always try to create such a question for your backtrack function to see if you got it right and understand exactly what it does.

Minimize the state space of function arguments

In this step I want you to think about, which of the arguments you pass to the function are redundant. Either we can construct them from the other arguments or we don’t need them at all. If there are any such arguments, don’t pass them to the function. Just calculate them inside the function.

In the above function profit, the argument year is redundant. It is equivalent to the number of wines we have already sold plus one, which is equivalent to the total number of wines from the beginning minus the number of wines we have not sold plus one. If we create a read-only global variable N, representing the total number of wines in the beginning, we can rewrite our function as follows:

int N; // read-only number of wines in the beginning
int p[N]; // read-only array of wine prices

int profit(int be, int en) {
if (be > en)
return 0;

// (en-be+1) is the number of unsold wines
int year = N - (en-be+1) + 1; // as in the description above
return max(
profit(be+1, en) + year * p[be],
profit(be, en-1) + year * p[en]);
}

I also want you to think about the range of possible values the function arguments can get from a valid input. In our case, each of the arguments be and en can contain values from 0 to N-1. In valid inputs we also expect be <= en+1. Using big-O notation we can say, there are O(N^2) different arguments our function can be called with.

Now cache it!

We are now 99% done. To transform the backtrack function with time complexity O(2^N) into the memoization solution with time complexity O(N^2) we will use a little trick which doesn’t require almost any thinking.

As noted above, there are only O(N^2) different arguments our function can be called with. In other words, there are only O(N^2) different things we can actually compute. So where does O(2^N) time complexity comes from and what does it compute?!

The answer is – the exponential time complexity comes from the repeated recursion and because of that, it computes the same values again and again. If you run the above code for an arbitrary array of N=20 wines and calculate how many times was the function called for arguments be=10 and en=10 you will get a number 92378. That’s a huge waste of time to compute the same answer that many times. What we can do to improve this is to cache the values once we have computed them and every time the function asks for an already cached value, we don’t need to run the whole recursion again. See the code below:

int N; // read-only number of wines in the beginning
int p[N]; // read-only array of wine prices
int cache[N][N]; // all values initialized to -1 (or anything you choose)

int profit(int be, int en) {
if (be > en)
return 0;

// these two lines save the day
if (cache[be][en] != -1)
return cache[be][en];

int year = N - (en-be+1) + 1;
// when calculating the new answer, don't forget to cache it
return cache[be][en] = max(
profit(be+1, en) + year * p[be],
profit(be, en-1) + year * p[en]);
}

And that’s it! With that little trick it runs O(N^2) time, because there are O(N^2)different arguments our function can be called with and for each of them, the function runs only once with O(1) time complexity.

Note: when the values are cached, you can treat every recursive call inside the function as it would run in O(1) time complexity.

Summary

To sum it up, if you identify that a problem can be solved using DP, try to create a backtrack function that calculates the correct answer. Try to avoid the redundant arguments, minimize the range of possible values of function arguments and also try to optimize the time complexity of one function call (remember, you can treat recursive calls as they would run in O(1) time). Finally cache the values and don’t calculate the same things twice.

The final time complexity of the solution is:
range_of_possible_values_the_function_can_be_called_with x
time_complexity_of_one_function_call.

Google Places API and JSON parsing in Android

Tags

, , ,

Firstly about the Places API.

Google Places API:

Four basic Place requests are available from the API:

  • Place Searches return a list of nearby Places based on a user’s location or search string.
  • Place Details requests return more detailed information about a specific Place, including user reviews.
  • Place Actions allow you to supplement the data in Google’s Places Database with data from your application. Place Actions allow you to schedule Events, weight Place rankings by check-in data, or add and remove Places.
  • Places Autocomplete can be used to provide autocomplete functionality for text-based geographic searches, by returning Places as you type.

Note: The Result can be got as a JSON file or XML file depending on your needs.here I will be getting the result as a JSON.

You can refer more about Places API here.

Step by Step procedure for using the Places API:

Step 1:

Create a new Android Project and add the android.permission.INTERNET to the manifest.

Step 2:

Now we have to send a HTTP Get request to the Google servers and receive a JSON file.

For this Purpose we will be importing the following classes.


import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;

Step 3:

First we have to have the URL to which the request is being sent.


String requesturl="https://maps.googleapis.com/maps/api/place/search/json?radius=500&sensor=false&key=<your API key>&location=-33.8670522,151.1957362";

Create a HttpClient from which the request must be sent.


DefaultHttpClient client=new DefaultHttpClient();

Then we must construct the Http Request which is of GET method.


HttpGet req=new HttpGet(requesturl);

Then we must send the request to get a response.


HttpResponse res=client.execute(req);

Step 4:

After receiving the response we must extract the Entity from the HttpResponse. Then the JSONObject must be constructed from it. Since the JSONObject Constructor accepts only String we must convert the Contents of the HttpResponse into a String.

HttpEntity jsonentity=res.getEntity();
InputStream in=jsonentity.getContent();
JSONObject jsonobj=new JSONObject(convertStreamToString(in));

The procedure for converting Stream to String.

private String convertStreamToString(InputStream in) {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(in));
		StringBuilder jsonstr=new StringBuilder();
		String line;
		try {
			while((line=br.readLine())!=null)
			{
				String t=line+"\n";
				jsonstr.append(t);
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return jsonstr.toString();
	}

Step 5:

Now is the time for Parsing.

The JSON returned is like this.

{
   "html_attributions" : [],
   "results" : [
      {
         "geometry" : {
            "location" : {
               "lat" : -33.86682180,
               "lng" : 151.19542210
            }
         },
         "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
         "id" : "96760d4544ecdaaf2e87565915638238ca960f20",
         "name" : "Pirrama Rd",
         "reference" : "CoQBcgAAAIWIC2AA6D0V4r5BAzZ_-hdqlmDQO0FBGRNU4SGWhIv5a1yycXYi9d4w7K6-JeaQU_ZWrbXW19RPgF6VN_5iO05BeDof1DNzeBpsoSvIvFwrjkzZMPelEPVijJDxdu7f1Dr3BgPEvnxwUJ5eWO64rL9UGKMlicOdB5GMrc4cJ-3REhAVrcb67mrvPduZh4R80gPAGhQH0w5Yjv0k32AdYsbJb2_ycX2Kug",
         "types" : [ "route" ],
         "vicinity" : "Pyrmont"
      }
   ]
}

So the Parser must be written to parse the JSON of above format.

JSONArray resarray=jsonobj.getJSONArray("results");

if(resarray.length()==0){
	//No Results
}
else{
        int len=resarray.length();
	for(int j=0;j<len;j++)
	{
		Toast.makeText(getApplicationContext(), resarray.getJSONObject(j).getString("name") , Toast.LENGTH_LONG).show();
	}
}

A Toast message is shown to the User about the returned place names.

Lets Bring Back Brand CEG

Welcome ppl, This is my first blog post.
Thanks for scrolling down to see the length of the blog post and deciding to read it.If u have done this u virtually give me 1 like for the post.

Scene 1:

Me and my friend Prakash after boarding a MTC bus from Guindy to CEG.

Prakash decides to promote the name “College of Engineering, Guindy”.

Prakash to Conductor:“Anna, CEG 2 ticket.”

Conductor(little confused):“Enga pa?”

Prakash(after getting ‘bun’):“Anna University na.”

So people pls while buying tickets ask em as “CEG” or “College of Engineering, Guindy“(This may sound something funny but worth doing it).

Scene 2:

One day a few tweet birds(@cegprakash,@vysakh0,@josesai,@sathishkalanithi,@thesabarinath) tries to make #BringBackBrandCEG to trend in Twitter.We added the hash tag in every tweet so that when a CEGian sees it he/she will repeat the same in his/her tweets.

But finally got the same ‘bun’.

Scene 3:

Mr.Vysakh Seenivasan started a Facebook group named “College of Engineering, Guindy” on January 15,2012 but it has just 105 members.

Another group named “College of Engineering Guindy 2009-2013” was started by some poor guy/girl on July 10,2010 but till date it has only 2 members.

This is another ‘bun’

Scene 4:

Mr.Hariharan Spartanz posted the following Photo.

BringBackBrandCEG

Then I noticed that many people including me were having “Anna University” as place of study in Facebook.

I got another great ‘bun’.

So if u do have so just click on the College of Engineering, Guindy and make it as ur study place.

Scene 5:

We have a stamp in the name of our College.

CEG Stamp

For more info refer here.Even though we have had a Postal Stamp in the name of our College now many people don’t know it.They simply refer our college as “Anna University”.

This Institution has a lot of History.

But still no one knows College of Engineering, Guindy.

So lets join hands in bringing back the brand of the 200 year old College.Share this post with all our College mates.