Some investigation about MIME type on Android(To be continued)

1. Gmail  (Platform: Nexus 7) When open an plain text document without any file extension, Gmail will send an intent as below:

ACTION: android.intent.action.VIEW DATA: content://gmail-ls/davidyoung8906@gmail.com/messages/2234/attachments/0.1/BEST/false TYPE: application/octet-stream

FLAGS: FLAG_GRANT_READ_URI_PERMISSION FLAG_ACTIVITY_FORWARD_RESULT FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET FLAG_ACTIVITY_PREVIOUS_IS_TOP

2 ACTIVITIES MATCH THIS INTENT: c:geo (cgeo.geocaching – cgeo.geocaching.cgeocaches) 快播 (com.qvod.player – com.qvod.player.activity.PlayerActivityNew)

Obviously, the

A good practice of retrieving attachment:

REGISTERING YOUR ANDROID APP FOR FILE TYPES AND EMAIL ATTACHMENTS

Android 常用 mimeType 表

Inter-App Communication – Document Support in iOS Application

As we can see from this post, IOs share a lot of similarity with Android apps in inter application communication. Such communication information resides in Info.plist of iOS application. As described in the post, the iOS inter app communication techniques falls into two categories:

  • Custom URL prefixes, e.g. someapp://something/somethingelse?somestuff=whatever
  • Custom file type handlers by file extension (e.g. *.txt) or by MIME type (e.g. text/plain).

Android combine both of the attribute in its <data> tag.

 

getMimeTypeFromExtension
getFileExtensionsFromUrl()
http://twigstechtips.blogspot.com/2011/09/android-get-file-mime-type-from.html

http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND

Analyzing Millions of GitHub Commits

https://www.youtube.com/watch?feature=player_embedded&v=U_LNo_cSc70

It’s a very interesting talk, what’s more interesting is the tool developed by the presenter.

You can find the slides here: http://www.igvita.com/slides/2012/bigquery-github-strata.pdf

The tool: http://www.githubarchive.org/ Github page: https://github.com/igrigorik/githubarchive.org/tree/master/bigquery

I actually tried a query to search the top 100 Android repository by push

Here’s my query on https://bigquery.cloud.google.com/: ”

SELECT repository_name, count(repository_name) as pushes, repository_description, repository_url
FROM [githubarchive:github.timeline]
WHERE type=”PushEvent”
AND repository_language=”Java”
AND PARSE_UTC_USEC(created_at) >= PARSE_UTC_USEC(‘2012-04-01 00:00:00’)
AND repository_description CONTAINS “Android”
GROUP BY repository_name, repository_description, repository_url
ORDER BY pushes DESC
LIMIT 100

Here is the result

From the result I immediately spotted that several projects in cyanogenmod repository is on the List. From that I know that cyanogenmod(http://www.cyanogenmod.org/) is aftermarket firmware.

query1

Refactoring: Improving the design of existing code(To be continued)

Chapter1

When you find you have to add a feature to a program, and the program’s code is not
structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature.

Before you start refactoring, check that you have a solid suite of tests. These tests
must be self-checking.

Smaller pieces of code tend to make things more manageable.

first step is to find a logical clump of code and use Extract Method;

Refactoring changes the programs in small steps. If you make a mistake, it is easy to
find the bug.

 

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

In most cases a method should be on the object whose data it uses, thus the method should be moved. To do this I use Move Method. With this you first copy the code over, adjust it to fit in its new home, and compile. The next step is to find every reference to the old method and adjust the reference to use the new method. The next thing is to remove the old method. The compiler should tell me whether I missed anything. I then test to see if I’ve broken anything

Replace Temp with Query

I like to get rid of temporary variables such as this as much as possible. Temps are often a problem in that they cause a lot of parameters to be passed around when they don’t have to be. If the calculation will be performed multiple times, do the optimization in the calculation class.

The other concern with this refactoring lies in performance. Don’t worry about this while refactoring. When you optimize you will have to worry about it, but you will then be in a much better position to do something about it, and you will have more options to optimize effectively

It is a bad idea to do a switch based on an attribute of another object. If you must use a switch statement, it should be on your own data, not on someone else’s.

Should you trust your experiment result?

Quote

A talk by Amer Diwan

The scope of experiment   << Scope of claim               lead to unsound experiment

Sound experiment should be:

The Scope of claim <= The scope of experiment     means    experiment is sound as respect to the claim

From unsound to sound Two option(1. Reduce claim; 2. Extend experiment), but reducing claim will make research boring;

 

Four fatal sins cause unsound experiment.

1.Ignorance(Ignore components necessary for claim)

Example: Ignore the diversity or difference of subjects/benchmarks;

Systematically biased the experiment result (for the ignored components).

And it’s not obvious. Example:Ignoring Linux environment variable; Ignoring heap size(Evaluate garbage collector);Ignoring profiler bias(biased sampling method);

2. inappropriateness(Using components irrelevant for claim)

It’s not obvious;

Inappropriate statistics(Choosing best 30 runs to evaluate versus confidence interval method; fooled by the lucky outliers);

Inappropriate data analysis(two distribution’s mean value is the same but such methodology ignore the long-tail latency);(mean time of layered system is meaningless because most of the hits is much faster(cache hit) or much slower(cache miss) than the mean time) Lesson learned:Check the shape of data before deciding using which analysis to it

Inappropriate metric (extra nops instructions make instruction/cycle much higher, but nops instruction does noting.)Should pick up metric that is ends-based. (Use average point-to-set to evaluate pointer analysis, but people might prefer the one with 2/3 accurate result and 1/3 bad result than the one with all mediocre result). Metrics should be inconsistent with “Better”.

3. Inconsistency

Experiment compares A to B in different context.

(compare two systems using different benchmark suite)

Inconsistent workload (Evaluate Gmail optimization over two same amount of time, but the workload in two time period is not the same;)

Inconsistent metric (issued instruction versus retired instruction to evaluate performance)

4. Irreproducibility

Others cannot reproduce your result.

Write down everything may have bias your result 

Very hard to capture and characterize everything may affect your result.

Always look your gift horse in the mouse. Use back of envelope evaluation

 

Suggestion: Both novel algorithm and sound experiment should stand for itself.