Java Android Pause / Resume Thread

This example from stackoverflow. Thank You Wroclai


class YourRunnable implements Runnable {
    private Object mPauseLock;
    private boolean mPaused;
    private boolean mFinished;

    public YourRunnable() {
        mPauseLock = new Object();
        mPaused = false;
        mFinished = false;
    }

    public void run() {
        while (!mFinished) {
            // Do stuff.

            synchronized (mPauseLock) {
                while (mPaused) {
                    try {
                        mPauseLock.wait();
                    } catch (InterruptedException e) {
                    }
                }
            }
        }
    }

    /**
     * Call this on pause.
     */
    public void onPause() {
        synchronized (mPauseLock) {
            mPaused = true;
        }
    }

    /**
     * Call this on resume.
     */
    public void onResume() {
        synchronized (mPauseLock) {
            mPaused = false;
            mPauseLock.notifyAll();
        }
    }

}

How to fix Ubuntu 14.014 ctrl+space do not work

After i updated my ubuntu from 12.04 to 14.04. i founded problem ctrl+space key shortcut for code assist not work in Eclipse and Netbeans again. This is the solution to fix it.

1. Open Terminal run this command

ibus-setup

2. On next input method, delete ctrl+space



3. After deleted, Ctrl + Space will working fine!!!! Happy!!!

PHP-FPM vs HHVM

this is result i tested concurence between php-fpm (tcp) vs hhvm (tcp)

My http server is Nginx. i tested 1000 requests and 50 concurrence.


First i tested php-fpm the time taken for test is 8.272 seconds.

php-fpm result

i tested hhvm the time taken for test is  2.831 seconds

hhvm result
the code that i tested is my project based on cakephp framework.

conclusion hhvm is very very fast but hhvm is not support unix socket now. :-(

Raspberry Pi Wifi Auto Reconnect

1. Go to /etc/ifplugd/action.d/ and rename the ifupdown file to ifupdown.original
2. Then do: cp /etc/wpa_supplicant/ifupdown.sh ./ifupdown
3. Finally: sudo reboot

thank you http://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi

Easy Linux Email Server With iRedmail

i find the solution to install email server but it's difficult and complicate. i found the iRedmail it's free and full-featured mail server solution. it's very easy to install. :-)

http://www.iredmail.org/

this is a how to install video.
http://www.youtube.com/watch?v=TqAdt2l1aDc


Facebook Special Token


On the 16 Jan 2014. I found the Token from Facebook Official Application and Facebook Messenger Application. That Token can access emails & phones of your friends without ask them depends on their privacy setting and this token also can  get email & phones from not friends user if their has set public on privacy setting (You can't see email on the user who is not friend). ahh this token can query your friends of friends. it wonderful. i love this token.

That sure i reported this issue to Facebook security team, this is once of the answer

As https://www.facebook.com/help/359369650815737 notes, the privacy
setting of an email address controls who is able to see the information
outside of the context of Timeline. Shown on Timeline or Hidden from
Timeline are known as visibility settings and only control what information
is highlighted on your timeline. Can you demonstrate the ability to use
this token to access email addresses which you shouldn't be able to based
on privacy settings?


The tokens issued to the official applications have special permissions in order to allow them to function as efficiently as possible. Again, the application should not be able to return any information that it is not possible to access normally. Can you demonstrate a case where you are seeing the friend list for a friend where you could not otherwise see it? 


 Ok, Let's see how this work.

1. You must have Mobile device and installed Facebook Application, in this case i use my Android.

2. We will capture the special token from this software mitmproxy (http://mitmproxy.org/). This software that fake the certificate and make you can read https. Please see this blog for how mitmproxy work and use (http://blog.philippheckel.com/2013/07/01/how-to-use-mitmproxy-to-read-and-modify-https-traffic-of-your-phone/ )

3. After you learned the blog above you will got the special token when you open the facebook application and logged in


From Facebook Android Application

From Facebook Messenger Application

4. You can check the token here (wow the expire is never)



5. After i got the special token i use facebook fql to get data (https://developers.facebook.com/tools/explorer)

i will show you for some example

this is the query to get your friends email & phone number
https://developers.facebook.com/tools/explorer/?fql=SELECT%20uid%2C%20name%2C%20email%2C%20phones%20FROM%20user%20WHERE%20uid%20IN%20(SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%3Dme())

phones is not for regular facebook app token


After use the special token,  got email and phone number


this query can get your friends of friends depends on your friend privacy setting

SELECT uid, name, email, phones FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=FACEBOOK_ID)







mitmproxy : sniff https traffic

http://mitmproxy.org

http://blog.philippheckel.com/2013/07/01/how-to-use-mitmproxy-to-read-and-modify-https-traffic-of-your-phone/