Friday, August 17, 2012

JUnit 4 Tutorial , Parameterized Test

import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class SimpleMathTest {

    public static class SimpeMath {
        public static int Add(int a, int b) {
            return a + b;
        }
    }

    int a, b, expected;

    public SimpleMathTest(int a, int b, int expected) {
        super();
        this.a = a;
        this.b = b;
        this.expected = expected;
    }

    @Parameters
    public static Collection < Object[] > TestThoseSeries() {

        Object[][] data = new Object[][] {
            {
                1, 2, 3
            }, {
                2, 2, 4
            }, {
                3, 3, 6
            }, {
                4, 4, 9
            }
        };
        return Arrays.asList(data);
    }

    @Test
    public void testAdd() {
        assertSame(expected, SimpeMath.Add(a, b));
    }

}

you will see 3 passed, one failed when you run the test.

image

Change or Restore /etc/hosts file for rooted android phone

If you have rooted your android phone, you can easily change the host file , like map some host to 127.0.0.1 , this will block the access to the url.

some application like ADfree did the same thing, basically adding a lot Ad domains and all pointed to 127.0.0.1.

image

you can check the url like http://www.mvps.org/winhelp2002/hosts.txt to get the Ad host lists.
sometimes, you may need to unblock some individual host which could be false positive. you need mount the file to be writable. since by default /etc/hosts is one system which is readonly/
image

to change it to writable. do the remount
image

now your can push change to this file

image

Thursday, July 26, 2012

how to, test opengpg on windows,

first I searched and found openpgp.org, turns out it was acquired by semantic, no way to get the windows gui installer, after a while, I found pgp4win, which has the windows installer, check it here,
http://www.gpg4win.org/download.html


so download and install the stable version, once done. run the app called Kleopatra

image

Click File, create a new PGP key pair. I will chose DSA+Elgamal. by clicking the advance settings.
image
once done, you will get the confirmation window,

image

Now you created one key-pair successfully.

Wednesday, July 25, 2012

How to , Disable the Sublime Text popup for new version

maybe sublime just follow the firefox style, always prompt me to download the new version. why not go with the chrome style, put the download task in background without annoying me with the Modal dialog?

image
then it must chat with the server to get the version information, so I run a network sniffer, it did.
image

So fix is easy, just point the host to 127.0.0.1 in your host file, it will mute the annoying dialog.

127.0.0.1       www.sublimetext.com

Monday, July 9, 2012

Eclipse 4.2 , android developers tools

Just loaded one latest eclipse Classic IDE.

image

Try to install the developers tools, get an error,

cannot complete the install because one or more required items could not be found.
  Software being installed: Android Development Tools 20.0.0.v201206242043-391819 (com.android.ide.eclipse.adt.feature.group 20.0.0.v201206242043-391819)
  Missing requirement: Android Development Tools 20.0.0.v201206242043-391819(com.android.ide.eclipse.adt.feature.group 20.0.0.v201206242043-391819) requires 'org.eclipse.wst.sse.core 0.0.0' but it could not be found


basically, the error means it need the wst feature, just insall the web feature, then the installation will go through,
image

Monday, July 2, 2012

Centos ,rmr rhadoop, hadoop streaming failed with error code 1

When I download RMR and installed all dependency packages , try to run a simple mapreduce job on R, get an unknown error.

b=mapreduce(input=a,map=function(k,v) keyval(v,v^2))
packageJobJar: [/tmp/Rtmp8skozB/rmr-local-env, /tmp/Rtmp8skozB/rmr-global-env, /tmp/Rtmp8skozB/rhstr.map14f121ad6582, /var/lib/hadoop-0.20/cache/root/hadoop-unjar8292210935392046645/] [] /tmp/streamjob4219155535407733796.jar tmpDir=null
12/06/27 11:31:45 INFO mapred.FileInputFormat: Total input paths to process : 1
12/06/27 11:31:46 INFO streaming.StreamJob: getLocalDirs(): [/var/lib/hadoop-0.20/cache/root/mapred/local]
12/06/27 11:31:46 INFO streaming.StreamJob: Running job: job_201206271130_0001
12/06/27 11:31:46 INFO streaming.StreamJob: To kill this job, run:
12/06/27 11:31:46 INFO streaming.StreamJob: /usr/lib/hadoop/bin/hadoop job -Dmapred.job.tracker=localhost:8021 -kill job_201206271130_0001
12/06/27 11:31:46 INFO streaming.StreamJob: Tracking URL: http://localhost.localdomain:50030/jobdetails.jsp?jobid=job_201206271130_0001
12/06/27 11:31:47 INFO streaming.StreamJob: map 0% reduce 0%
12/06/27 11:32:07 INFO streaming.StreamJob: map 100% reduce 100%
12/06/27 11:32:07 INFO streaming.StreamJob: To kill this job, run:
12/06/27 11:32:07 INFO streaming.StreamJob: /usr/lib/hadoop/bin/hadoop job -Dmapred.job.tracker=localhost:8021 -kill job_201206271130_0001
12/06/27 11:32:07 INFO streaming.StreamJob: Tracking URL: http://localhost.localdomain:50030/jobdetails.jsp?jobid=job_201206271130_0001
12/06/27 11:32:07 ERROR streaming.StreamJob: Job not successful. Error: NA
12/06/27 11:32:07 INFO streaming.StreamJob: killJob...
Streaming Command Failed!
Error in mr(map = map, reduce = reduce, reduce.on.data.frame = reduce.on.data.frame, :
hadoop streaming failed with error code 1

I checked that 3 environments requried are all set ,
image
the error is very general, then I checked the jobtracker/tasktracker log.

Caused by: java.lang.RuntimeException: configuration exception
at org.apache.hadoop.streaming.PipeMapRed.configure(PipeMapRed.java:230)
at org.apache.hadoop.streaming.PipeMapper.configure(PipeMapper.java:66)
... 22 more
Caused by: java.io.IOException: Cannot run program "Rscript": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at org.apache.hadoop.streaming.PipeMapRed.configure(PipeMapRed.java:214)
... 23 more
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 24 more

it looks like I try run the Rscript, but failed, so for my first impression, it could be a permission issue.

then I run as the mapreduce user, try to locate the Rscript. all are ok, the permission are ok.
image
everyone has the execute access, so could it be a path issue? so I just give a try, make a link under /usr/bin/Rscript. then, all works. super!

image

image

Wednesday, June 27, 2012

Google io 2012, Android 4.1 new features

Project Butter
.  Voice typing, offline support. (no data connection required.)
.  Accessibility support
.  Android Bean (NFC)
    send video/photo between phones.
.  Notifications.
   Actionable notification, display call button for missed call.
   Gmail new message, auto expand. swap to remove it.
   Like button on the notification bar without openning the app
   two finger gesture to expand the phones on pulse.
 . Search
    Google Now, New UI. knowldege graph
    Knowledge graph, like Siri for apple.
    Google Now, traffic, public transit. places around you,tell you what's the best food in the given restaurant. Flights information, like delay information. sports score in real time.

PDK

Google Play.
Apps,Movie, Books, Music.
600K apps, 20 B app installs.
Apk Expansion files,
improved analytics
ready to review
android training.

new features,
App Encryption. (encrypted with device-spcified key)
helpfurl for paid application. you cant export apk directly and use it on the fly.

Smart App update.

C2DM->Google cloud messaging.
    free for all developers, no quota limitations.
 Magazine.

Nexus 7
7 inch tablet. by Asus. loaded with 4.1
 view magzine, switch reading modes.
watching tv.
new recommandation engine.
what's the song playing widiget.
chrome, standard browser.
offline maps



 
Locations of visitors to this page