Getting GitHub latest release URL

Do you need Download Latest Version button? Try follow PHP code:

function getLatestTagUrl($repository, $default = 'master') {
    $file = @json_decode(@file_get_contents("$repository/tags", false,
        stream_context_create(['http' => ['header' => "User-Agent: Vestibulum\r\n"]])
    return sprintf("$repository/archive/", $file ? reset($file)->name : $default);

echo getLatestTagUrl('OzzyCzech/vestibulum');
// will return

How to fix “Shell Shock” bash bug on OS X

First try if your bash version it’s vulnerable. Go to terminal and run:

$ env x='() { :;}; echo vulnerable' bash -c 'echo hello'

Follow output is an example of a non-vulnerable bash version.

bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'

If you see the word vulnerable in the output of that command your bash is vulnerable and you should update. ### How to update bash with Homebrew

First check your bash version:

$ bash --version    
GNU bash, version 4.3.18(1)-release (x86_64-apple-darwin13.3.0)
Copyright (C) 2013 Free Software Foundation, Inc.

Then find your bash directory (full path can be usefull later):

$ ls -la /usr/local/bin/bash
/usr/local/bin/bash -> ../Cellar/bash/4.3.25/bin/bash

Then upgrade bash:

$ brew update
$ brew upgrade bash

If your terminal starts returning weird error like:

dyld: Library not loaded: @@HOMEBREW_PREFIX@@/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/bin/bash
  Reason: image not found

You will need upgrade also readline with follow commands:

$ brew rm -f readline
$ brew install readline
$ brew link readline --force

Tip: If you accidentally close Terminal before getting above errors and your bash just stop working at all. Go to Terminal preferences⌘+, and change bash version to older e.g./usr/local/Cellar/bash/4.3.18/bin/bash then quit Terminal ⌘+Q. Upgrade readline and change path back to /usr/local/bin/bash and restart Terminal again.

AngularJS $http not sending X-Requested-With header

Angular $http isn’t appending the header X-Requested-With = XMLHttpRequest since Angular 1.3.0.

X-Requested-With header is rarely used in practice and by using it all the time we are riggering preflight checks for crossdomain requests. See commit message

That can cause some problems on PHP side. If you need somehow differentiate XHR and common requests. For example Zend Framework and lot of others PHP frameworks use follow code:

function isXmlHttpRequest() {
 return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&

You can easily add on Angular side by following code:

myAppModule.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';

How to add all custom post type to main Wordpress archive.php

Default archive shows only post type if you need show all post types just add follow code to function.php

'pre_get_posts', function ($query) {
        if (
            $query->is_main_query() &&
            !is_admin() &&
            (is_category() || is_tag())
            && empty($query->query_vars['suppress_filters'])
        ) {
            $posts = array_diff(
                get_post_types(['public' => true]), ['page', 'attachment', 'revision', 'forum', 'reply', 'topic'] /* array of ignored types*/
                'post_type', $posts
            return $query;

How to protect your emails with PHP and Javascript

Working with or without javascript it's combine two technique for email protection ROT13 and CSS

function mail($email, $text = null) {
 return '<script type="text/javascript">document.write("' .
   '<a href="mailto:' . $email . '" rel="nofollow">' . ($text ? : $email) . '</a>'
 ) . '".replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));</script>' .
 '<noscript><span style="unicode-bidi: bidi-override; direction: rtl;">' . strrev($email) . '</span></noscript>';