Free 20GB Cloud Storage for everybody

July 13, 2013 2 comments

I’ve been using Copy Cloud Storage for a while, and it seems working pretty well as I expected.

However, the storage is likely to be kinda short, well, you know, cloud file storage is quite popular nowadays; and 15GB free is not enough definitely. You need to pay for more spaces.

Fortunately, Copy is running on an event for 5GB storage for each invited registration, that means you and your referred buddy will get both 5GB as bonus in your accounts. Isn’t that great?

If you are new, feel free to create account under my referral to get extra 5GB at first, and then you can invite your friends to join the cloud storage network for more spaces: https://copy.com?r=yVP8U0

Have fun with cloud ^^~

A Note when Using Jsoup: User-Agent

January 29, 2013 1 comment

Several days ago, I’ve tried to run Jsoup on mobile testing for data parsing. My goal is to parse all questions posted on stackoverflow.com.

However, the result doesn’t fit me well.

First run on simple Android code:

public class MainScreen extends Activity
{
    ArrayList<String> mData =  new ArrayList<String>();
    ListView mListView;
    ArrayAdapter<String> mAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mListView = (ListView) findViewById(R.id.listView);

        processData();

        mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, mData);
        mListView.setAdapter(mAdapter);
    }

    private void processData() {
        String URL = "http://stackoverflow.com/questions/tagged/android";
        try {
            Document doc = Jsoup.connect(URL).get();
            Elements questions = doc.select(".summary h3 a");
            for(Element question: questions) {
                mData.add(question.text());
            }

            if(mData.size() == 0) {
                mData.add("Empty result");
            }

        } catch (Exception ex) {
            ex.printStackTrace();
            mData.clear();
            mData.add("Exception: " + ex.toString());
        }
    }
}

The result is empty. Well, thought of something else, so my next try is to print HTML from “doc” object, it outputs parts of full expected HTML results. So I parse with this selector: “div.nav li a”. The results show up but not for “.summary h3 a”.

After two days, working with Johnathan Hedley on GitHub, finally, found the problem is that: the mobile browser user-agent differs from the desktop browser; therefore, the HTML responses differ.

Make a note to mobile developers that use Jsoup:

+ always set a desktop user-agent

+ set a timeout

That’s good practice to avoid unexpectation.

This is the update working line:

Document doc = Jsoup.connect(URL).userAgent("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; de-de) AppleWebKit/523.10.3 (KHTML, like Gecko) Version/3.0.4 Safari/523.10").get(
);

This issue was discussed here in GitHub: https://github.com/jhy/jsoup/issues/287

 

Cheers,
Pete Houston

Categories: Tricks & Tips Tags: , , , , ,

Geek Hero Comic

January 27, 2013 1 comment

Welcome to Geek Hero Comic,

Even though the series is under break, and no-one knows when it will come back again, but still, Geek Hero Comic is one of the best comic series about computer geeks.

If you’re already familiar or don’t know about it, just read it once, you will fall in love with it and keep reading every single interesting chapter.

[ Geek Hero Comic ]

version: 1.1

support Android version: 1.6+

Download: Play Store

[ Changelog ]

27/Jan/2013

[version 1.1]

.improve image quality when read in fullscreen mode
.add detailed information for characters

25/Jan/2013

[version 1.0]
.first release
.set GeekHero picture to wallaper
.read story from the very first episode to the last
.view image in fullscreen
.share episode to other apps, like Twitter, Facebook,…
.smooth image view
.add characters’ info

[ Features ]

information on series’ characters

. set wallpapers of some nice GeekHero pictures.

. read and load all chapters at the same time

. support reading in fullscreen mode

. start reading from last read chapter.

. smooth image viewer

[ Screenshots ]

screenshot_03screenshot_04screenshot_05

 

 

 

 

 

 

 

 

 

 

Cheers,

Pete Houston