Challenges that each developer faces every day

Friday, 1 November 2013

Content type for the audio files aac - extension m4a

The correct content type for audio that is AAC encoded is:
audio/mp4

If you have access to webserver's conf/mime.types file add this line

audio/mpeg     mpga mp2 mp3 m4a

 Digg  Del.icio.us  Reddit  SlashDot

Monday, 24 June 2013

New Marketplace for WordPress Themes & Plugins (coming soon)

I started working on a WordPress theme and plugins marketplace.

The goal for the marketplace (http://market.orbisius.com/) is to provide better opportunities for designers, developers, and affiliates.

When developers/designers sell their products on our marketplace the commission rates will range between 70%-85% per sale and the products don't have to be exclusively sold on our marketplace.

For more info go to: http://market.orbisius.com/

Make sure you join the email list

 Digg  Del.icio.us  Reddit  SlashDot

Wednesday, 27 June 2012

Android: AndroidRuntime android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Have you seen this ugly error where is is totally not supposed to be there?

Error: AndroidRuntime android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

I was working on an app about local restaurants in Niagara and had an about window.

Solution:

error
...
private static Context context;
....

MainActivity.context = getApplicationContext(); // this was causing some nasty errors.

correct
MainActivity.context = this;


Related
http://www.mkyong.com/android/android-alert-dialog-example/
http://stackoverflow.com/questions/1561803/android-progressdialog-show-crashes-with-getapplicationcontext

 Digg  Del.icio.us  Reddit  SlashDot

Wednesday, 20 June 2012

curl: (3) [globbing] error: bad range specification after pos NN

This is an error when you try to call a URL containing {} or [] at NN position.

curl: (3) [globbing] error: bad range specification after pos NNN

how I used it

/usr/bin/curl -s http://somesite.ca/api?filter[date]=last_12_hours

solution: by using --globoff

/usr/bin/curl -s --globoff http://somesite.ca/api?filter[date]=last_12_hours

Credit:
https://bbs.archlinux.org/viewtopic.php?id=74675

 Digg  Del.icio.us  Reddit  SlashDot

Monday, 14 May 2012

quiet git log: How to get shorter version (one line) of git logs

Do you want to see shorter log messages from git ?


example
5441641 fixed support.php : wasn't validating
25af6d5 updated background
a3v0a49 enabled the backup

solution
git log --pretty=oneline --abbrev-commit

if you want to logs to be between certain date you can do this
git log --since=2012-04-20 --until=2012-04-30 --pretty=oneline --abbrev-commit


Credit:
Gauthier - http://stackoverflow.com/questions/4479225/how-to-output-git-log-with-the-first-line-only


Keyword: git, git-log, git log --quiet

 Digg  Del.icio.us  Reddit  SlashDot

Wednesday, 25 April 2012

$("#qfileupload").fileupload is not a function, $("#qfileupload").qtips is not a function

Have you seen this annoying JavaScript error message ?

$("#some_id").someplugin is not a function

I bet you have!

in most cases the plugin is not loaded but when everything is loaded fine then you should check if jquery is loaded more than once.

It turned out that if there are multiple copies of jquery loaded this causes the jquery extensions not to work.

Just lost a few hours troubleshooting this.


 Digg  Del.icio.us  Reddit  SlashDot

Thursday, 1 March 2012

How to detect old browsers in PHP and show a obsolete browser notice



put this in a file called common.
Class App_Util {
    function is_old_browser() {
        $old = 0;

        if (!empty($_SERVER['HTTP_USER_AGENT'])) {
            // IE <= 7
            // User Agent: Opera/9.80 (Windows NT 6.1; U; en) Presto/2.10.229 Version/11.61
            if (preg_match('#msie\s+(\d+)\.(\d+)#si', $_SERVER['HTTP_USER_AGENT'], $matches)) {
                if ($matches[1] <= 7) {
                    $old = 1;
                }
            }
            // Firefox <= 7
            // User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
            elseif (preg_match('#Firefox/(\d+)\.(\d+)[\.\d]+#si', $_SERVER['HTTP_USER_AGENT'], $matches)) {
                if ($matches[1] <= 7) {
                    $old = 1;
                }
            }
            // Safari < 5
            // User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7
            elseif (preg_match('#Version/(\d+)[\.\d]+ Safari/[\.\d]+#si', $_SERVER['HTTP_USER_AGENT'], $matches)) {
                if ($matches[1] < 5) {
                    $old = 1;
                }
            }
            // opera < 11
            // User Agent: Opera/9.80 (Windows NT 6.1; U; en) Presto/2.10.229 Version/11.61
            elseif (preg_match('#Opera/[\.\d]+.*?Version/(\d+)[\.\d]+#si', $_SERVER['HTTP_USER_AGENT'], $matches)) {
                if ($matches[1] < 11) {
                    $old = 1;
                }
            }
        }

        return $old;
    }
}

How to perform the check
file: block_old_browser.php

<?php if (App_Util::is_old_browser()) : ?>
    <div class="app_old_browser_notice">
        <h2>Old Browser</h2>
        <p>Please consider upgrading your browser. Doing so will improve experience with the site. <br/>
        Please click one of them below.</p>
        <ul>
            <li><a href="http://www.mozilla.org/en-US/firefox/fx/" target="_blank">Mozilla Firefox</a></li>
            <li><a href="https://www.google.com/chrome" target="_blank">Google Chrome</a></li>
            <li><a href="http://www.apple.com/safari/" target="_blank">Safari</a></li>
            <li><a href="http://www.opera.com/download/" target="_blank">Opera</a></li>
            <li><a href="http://www.microsoft.com/windows/ie/" target="_blank">Internet Explorer (Windows)</a></li>
        </ul>
    </div>
<?php endif; ?>

Include the file above in all the files that you need to the noticed displayed.
<?php include('block_old_browser.php'); ?>

css styles
<style>
.app_old_browser_notice {
    background-color:#ff0000;
    color: white;
    margin:20px;
    padding:10px;
}

.app_old_browser_notice a {
    color: white;
}
</style>

 Digg  Del.icio.us  Reddit  SlashDot