2010년 9월 21일 화요일

Find out which version of ubuntu is running

cat /etc/issue

or

lsb_release -a

Find out which version of ubuntu is running

cat /etc/issue

or

lsb_release -a

2010년 9월 18일 토요일

Choosing a default jdk when there are more than 2 jdks installed. (jdk5, jdk6)

If there are more than 2 jdks installed, you need to switch to specific jdk according to the situation.
This can be achieved easily with the following commands (update-java-alternatives)

1. Check the current configuration and possibilities.
# sudo update-java-alternatives -l
2. Set the specific jdk as default.
# sudo update-java-alternatives -s XXXX
3. To check the configuration,
# java -version
or
#javac -version

Source: https://help.ubuntu.com/community/Java

Installing sun-java6-jdk on ubuntu

Canonical decided to go with openjdk instead of the proprietary sun-java6.
But lots of people still demands sun-java6.
Actually the solution is in the release note of Ubuntu 10.04 (Lucid Lynx).
(Refer to the source link below)

# sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
# sudo apt-get update
# sudo apt-get install sun-java6-jdk

Source: https://wiki.ubuntu.com/LucidLynx/ReleaseNotes#Sun%20Java%20moved%20to%20the%20Partner%20repository

2010년 9월 17일 금요일

Find and replace a string

find /home/bruno/old-friends -type f -exec sed -i 's/ugly/beautiful/g' {} \;

1. Find a string (only in alphabets)

# grep -rw "search string" ./

2. Find a string

# grep -i -l "search string" * -r 2> /dev/null

2>/dev/null : direct error outputs to /dev/null

3. Find a string(all languages can be used for search string)

# find . -exec grep -l "search string" {} \; 2>/dev/null

4. Find a string(case insensitive)

# find . -exec grep -i -l "search string" {} \; 2>/dev/null

-i: case insensitive

5. Find and replace a string

# find . -exec perl -pi -e 's/search string/replace string/g' {} \; 2>/dev/null

# find . -type f -exec sed -i 's/ugly/beautiful/g' {} \;

6. Find a file

# find / -name filename -type f

7. Find a file(case insensitive)

# find / -iname filename -type f

8. Find a directory

# find / -name filename -type d

9. Find a directory(case insensitive)

# find / -iname directoryname -type d

10. Find all files that matches to the filename

find . | xargs grep 'filename'

Source:
http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html
http://apms.tistory.com/tag/replace

Installing sun-java5-jdk on ubuntu

* The recent master branch releases of Android Open Source Project, you need to install java6. Google finally switched to jdk 6 from old jdk 5.

In order to build Android(open source) on Ubutu, you need to install sun-java5-jdk.
However, sun-java5-jdk is not available on the repositories of latest Ubuntu versions (9.10 or aboves) any longer.

Here is the way to install sun-java5-jdk on the latest versions of Ubuntu.

1- Open /etc/apt/sources.list with a text editor like gedit:

sudo gedit /etc/apt/sources.list

2- Add the following lines to the end of the file then save it and close:

## For sun-java5-jdk
deb http://ir.archive.ubuntu.com/ubuntu jaunty-updates main multiverse

3- Update the packages lists and install sun-java5-jdk:

sudo aptitude update
sudo aptitude install sun-java5-jdk

4- (Optional) Remove the lines added at the step 2 from the sources.list.

4-1. open an editor to modify sources.list
sudo gedit /etc/apt/sources.list
4-2. remove or comment out(like the below) the added lines
## For sun-java5-jdk
#deb http://ir.archive.ubuntu.com/ubuntu jaunty-updates main multiverse
4-3. Update the package lists
sudo aptitude update

Source: http://zebardast.ir/en/installing-sun-jdk-5-on-ubuntu-9-10-and-10-04/

2010년 3월 21일 일요일

[Android] Memory Analyzing

In order to get information about the memory usage on Android.
There are 2 useful command lines (you can invoke these command in adb shell).

1. adb shell procrank

2. adb shell dumpsys meminfo

For more detailed debugging for memory leakage, use eclipse MAT (Memory Analyzer)
About using MAT for an android app, have a look at the following blog.

http://kohlerm.blogspot.com/

2010년 3월 16일 화요일

[Android] Add hdpi to the build

In order to support hdpi in the device, you have to add hdpi to the makefile.

For example, in order to build a simulator that supports hdpi,

Edit generic.mk (under build/target/product).
Add the following lines at the end of the file.

PRODUCT_LOCALES := hdpi ...

You can add other configuration options like ko_KR en_US mdpi ldpi

2010년 3월 15일 월요일

[Android] Set Default Activity (Now investigating to find a way to set a default activity especially for Home)

Here is what I have found during the investigation.

Check is Preferred Activity is set (InstalledAppDetails.java)
------------------------
// Get list of preferred activities
mActivitiesButton = (Button)findViewById(R.id.clear_activities_button);
List prefActList = new ArrayList();
// Intent list cannot be null. so pass empty list
List intentList = new ArrayList();
mPm.getPreferredActivities(intentList, prefActList, packageName);
if(localLOGV) Log.i(TAG, "Have "+prefActList.size()+" number of activities in prefered list");
TextView autoLaunchView = (TextView)findViewById(R.id.auto_launch);
if(prefActList.size() <= 0) {
// Disable clear activities button
autoLaunchView.setText(R.string.auto_launch_disable_text);
mActivitiesButton.setEnabled(false);
} else {
autoLaunchView.setText(R.string.auto_launch_enable_text);
mActivitiesButton.setOnClickListener(this);
}

getPreferredActivities() will return not-zero number for the packageName.
If 'preActList" > 0, it is preferred activity set.


Clear the Preferred (or Default) Activity (InstalledAppDetails.java)
-------------------------------
} else if(v == mActivitiesButton) {
mPm.clearPackagePreferredActivities(packageName);
mActivitiesButton.setEnabled(false);


Set the Preferred Activity
-------------------------------
ResolveInfo ri = mAdapter.resolveInfoForPosition(which);
Intent intent = mAdapter.intentForPosition(which);

if ((mAlwaysCheck != null) && mAlwaysCheck.isChecked()) {
// Build a reasonable intent filter, based on what matched.
IntentFilter filter = new IntentFilter();

if (intent.getAction() != null) {
filter.addAction(intent.getAction());
}
Set categories = intent.getCategories();
if (categories != null) {
for (String cat : categories) {
filter.addCategory(cat);
}
}
filter.addCategory(Intent.CATEGORY_DEFAULT);

int cat = ri.match&IntentFilter.MATCH_CATEGORY_MASK;
Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
String mimeType = intent.resolveType(this);
if (mimeType != null) {
try {
filter.addDataType(mimeType);
} catch (IntentFilter.MalformedMimeTypeException e) {
Log.w("ResolverActivity", e);
filter = null;
}
}
} else if (data != null && data.getScheme() != null) {
filter.addDataScheme(data.getScheme());

// Look through the resolved filter to determine which part
// of it matched the original Intent.
Iterator aIt = ri.filter.authoritiesIterator();
if (aIt != null) {
while (aIt.hasNext()) {
IntentFilter.AuthorityEntry a = aIt.next();
if (a.match(data) >= 0) {
int port = a.getPort();
filter.addDataAuthority(a.getHost(),
port >= 0 ? Integer.toString(port) : null);
break;
}
}
}
Iterator pIt = ri.filter.pathsIterator();
if (pIt != null) {
String path = data.getPath();
while (path != null && pIt.hasNext()) {
PatternMatcher p = pIt.next();
if (p.match(path)) {
filter.addDataPath(p.getPath(), p.getType());
break;
}
}
}
}

if (filter != null) {
final int N = mAdapter.mList.size();
ComponentName[] set = new ComponentName[N];
int bestMatch = 0;
for (int i=0; i ResolveInfo r = mAdapter.mList.get(i).ri;
set[i] = new ComponentName(r.activityInfo.packageName,
r.activityInfo.name);
if (r.match > bestMatch) bestMatch = r.match;
}
getPackageManager().addPreferredActivity(filter, bestMatch, set,
intent.getComponent());
}
}


There is no way to set a preferred Home on the first boot up of the device.
I am considering 2 methods to do that.
1) Modify startHomeActivity() API in ActivityManagerService.java
2) Add a persistent Service and set preferred home on boot up. (This could be possible. Because all persistent services start before Home activity)

2010년 2월 21일 일요일

[VMWare] Installing Mac OSX on Windows 7

I was planning to develop an iPhone application on my PC.
Unfortunately, the SDK for iPhone is available only on Mac OSX.
So, I have tried to find a way to install Mac OSX on VMWare.
The following link contains the detail.

Please look at the following link for the help.

http://www.redmondpie.com/how-to-install-os-x-snow-leopard-in-vmware-windows-7-9140301/

2010년 2월 18일 목요일

[Dell XPS 1645] Order Status

I order Dell XPS 1645 through Dell Korea online at 2010/02/03.
As of today (2/18), it is still before in-production.
I called Dell yesterday and learned that they are having a problem with getting enough RGBLED panel. I was told that I would receive the laptop around early March.
It is taking a month.
Since I had seen lots of issue(power throtting, sound issue, crash, difficult rgb led setting) about this laptop, I started doubt that it was a good choice.
Anyway, I will wait and see if it would be worth.

[2010/03/03]
It is finally in my hands. It took exactly a month.

[2010/03/07]
Checking the notebook. I found out that one particle of dust is stuck between the glass and the lcd in the left bottom corner. No defect pixels. Am I lucky?
I am inclined to keep this notebook.

But one glitch. I applied icc profile that is recommended by many people over notebookforum. Today after boot up, the display doesn't show up. So I had to go into safe mode and turn off the color profile. Do I need to use the profile? Actually I am not that sensitive to colors. The default profile also looks good to me.

Tomorrow I will ask a 130W power adapter replacement. I heard that Dell will cut in factory for 130W power adapter.

[Dell XPS 1645] Using RivaTuner on Windows 7 64 Bit

This is a post in a notebook forum.
It helps you set up a RivaTuner on Windows 7 64 Bit.

Please follow the link for the details.

For people having problems with Riva Tuner and Windows 7 64Bit