Wednesday, August 27, 2014

Need cool art for website or presentation?

Absolutely amazing online service with hundreds templates of different hardware devices (phone, tablets, laptops, etc.) where you can upload own picture of the screen to get the perfect art for website, presentation or brand-book.

This picture is created using Place.To:

P.S. Why I didn't do such service few years ago? :)

Monday, May 05, 2014

Bad Key Hash for Facebook Apps

When you are creating application for Facebook on Android platform, Developer Website requires the Key Hash for every development device.

This secret stroke is automatically generated by Eclipse or other dev studio in "debug.keystore" storage.

You can obtain Key Hash via command line:

keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64

or sample code:

    protected void onCreate(Bundle savedInstanceState) {

        // Temporary code to print out the key hash
        try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "com.Your.Application.Package.Name", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        } catch (NameNotFoundException e) {
        } catch (NoSuchAlgorithmException e) {

You have to add all you developer and release key hashes into Web panel of your Facebook Application. Everything looks simply enough.

But, if your hash key contains / (slash) or + (plus) symbol Facebook integration will not work! You'll get error message, something like that: "Key hash Fj2DQ/kUxqHuaTq1jy9iTejN2Uk= does not match any stored key hashes".

I've spent few hours to understand the problem and find a workaround :( Here is an easiest way:

  1. Delete "debug.keystore" file in your "[%USERNAME%]/.android" folder.
  2. Rebuild project to get new "debug.keystore" file with new key hash.
  3. If new hash contains any symbol (= at the end is OK :)) repeat again

Hope this tip helps other developers! Sometimes, development for Android and Facebook is a pain...

Thursday, March 20, 2014

How to detect Internet Explorer 10 and higher?

For a long time detecting of Internet Explorer browser was easy using Conditional Comments, something like:

<!--[if IE]>
 <script type="text/javascript">
  var isIE = true;

Starting version 10, Internet Explorer doesn't support conditional comments feature :(

Here is the JavaScript code to detect IE of any version since 5 till 11:

var isIE = (function(){
    var undef,rv = -1; // Return value assumes failure.
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf('MSIE ');
    var trident = ua.indexOf('Trident/');

    if (msie > 0) {
        // IE 10 or older => return version number
        rv = parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
    } else if (trident > 0) {
        // IE 11 (or newer) => return version number
        var rvNum = ua.indexOf('rv:');
        rv = parseInt(ua.substring(rvNum + 3, ua.indexOf('.', rvNum)), 10);

    return ((rv > -1) ? rv : undef);

Hope Internet Explorer 12 and higher will work the same way :)