How to Auto indent code in Atom editor

Auto indent it’s hidden function is hidden in menu Ediror > Lines > Auto Indent but shortcut missing :-(

Press cmd + shift + p then type keymap and hit enter Open Your Keymap.

Open Your Keymap

and add follow code there

  'cmd-alt-l': 'editor:auto-indent'

Now your Atom edit can Auto Indent with cmd + alt + l

Twitter Bootstrap Feedback Button

Follow code add orange Feedback button similar to the UserEcho button allow users send you feedback from any page. It’s based on Twitter Boostrap modal window.

Twitter Bootstrap compatible social login buttons

Login with Facebook, Twitter, Github, LinkedIn, StackOverflow or Google Plus buttons compatible with Twitter Bootstrap.

How to switch Homebrew formulas to older version

Sometimes you just won’t be able install latest version of any program and need some older (e.g. PHP 5.6.1 won’t work and you need install at least 5.6.0 and getting your work done). As you know all brew formulas are GIT repos, you can swith to older version easly:

$ cd /usr/local/Library/Taps/homebrew/homebrew-php/Formula
$ git log --pretty="%h - %s" -10
71b2069 - Update to PHP 5.5.18
b8aeb54 - Use homebrew's openssl for IMAP
f0d721a - php56: improve phpdbg logic
0dc3f1c - Update to PHP 5.6.1
908fedd - Update to Blitz 0.8.12
4801697 - Updates formula for WP CLI  to version 0.17.0
00560f3 - Upgrade php*-swoole to 1.7.5
8cbd369 - Updated PHP_CodeSniffer
a81eba6 - update pecl_http to 2.1.2
6a88856 - Add HEAD url for composer

Then just switch

$ git checkout 908fedd

And then run brew install php56 and older version PHP will be installed. Procedure can be used for any formulas.

Hardcore Simple Events Dispatcher for PHP

Events is simple pure functional event dispatching library for PHP 5.5+ and have nice and clear interface with function on(), one(), off(), trigger(), filter(), ensure(), listeners(), events() - that’s all!

With sphido/events can:

Trigger event

on('event', function () {
  echo "wow it's works yeah!";

trigger('event'); // print wow it's works yeah!

Hardcore simple events for PHP with filter, prioritizing, removing handlers and stop propagation. It’s even simpler then my previous version

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;

Simple pie chart progress bar in canvas element

Basic code was taken from Simple PIE Chart