Posts

Showing posts from August, 2013

[Safari] Cookies for iFrame domain not set

Image
The Problem Apple's Safari web browser is configured to block third-party cookies by default, unless the user has had prior interactions with the third-party domain:
http://webpolicy.org/2012/02/17/safari-trackers/


The Solution The idea is simple, just make sure the user visits the iframe domain (in this example, B.com) at least once.

One way is to run a popup that visits B.com (and set the P3P header), then close the popup.

On the parent window:
var win = window.open('http://B.com/startsession.php', '_blank', 'height=200,width=150');
setTimeout(function() {
win.close(); // close it after 1 second :)
}, 1000);
Then in the startsession.php, just set the header will do
<?php
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
session_start();
Done.


References:
http://webpolicy.org/2012/02/17/safari-trackers/
http://anantgarg.com/2010/02/18/cross-domain-cookies-in-safari/
http://anantgarg.com/2012/02/18/busting-the-cookies-and-privacy-…

Android ChatHead Tutorial - (1) Setup ChatHead

Image
Step 1: Setup an Android Project
Android ChatHead requires "SYSTEM_ALERT_WINDOW" permission which is available since API level 1, so minimum API 7 is fine.

Just next, next next... and create a blank activity :)



Step 2: Add ChatHead Service
If you want to know more details about ChatHead service. Read this article by Pierre-Yves Ricau.
Create a ChatHead Class that extends Service.
/java/com/gbinghan/androidchathead/ChatHeadService.java

Create ChatHead layout file.
/res/layout/service_chat_head.xml

Add ChatHeadService to AndroidManifest.xml

<service android:name="com.gbinghan.androidchathead.ChatHeadService" ></service>
Add SYSTEM_ALERT_WINDOW to AndroidManifest.xml
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Your AndroidManifest.xml should look like this.


Step 3: Add a button to launch the service :)
Add OnClickListener in Activity file java/com/gbinghan/androidchathead/MainActivity.java.
findViewById(R.id.button…

[Google Maps v3] Get Rectangle area with computeArea

Been searching for ways to calculate rectangle area with google.maps.geometry.spherical.computeArea(), but hard to find.

Here's the snippet of the code I found on stackoverflow.



Hope this helps those who are looking for the ways to use computeArea() without resolving to ugly/complex self-created methods. :)