How to detect Retina display in CSS

@media only screen and (-webkit-min-device-pixel-ratio: 2),(min-resolution: 192dpi) {
  /* it's retina yeah! */
}

Toggle Hidden Files in Finder

Run Automator and create new Application. Add task Run Shell script and paste follow code:

STATUS=`defaults read com.apple.finder AppleShowAllFiles`
if [ $STATUS == YES ];
then
    defaults write com.apple.finder AppleShowAllFiles NO
else
    defaults write com.apple.finder AppleShowAllFiles YES
fi
killall Finder

Save application. From now can Tooggle

List all mounted drives on mac

It's simple: df -h

Wodpress constants for human-readable intervals

Constants for expressing human-readable intervals in new #Wordpress are very useful:

define( 'MINUTE_IN_SECONDS', 60 );
define( 'HOUR_IN_SECONDS',   60 * MINUTE_IN_SECONDS );
define( 'DAY_IN_SECONDS',    24 * HOUR_IN_SECONDS   );
define( 'WEEK_IN_SECONDS',    7 * DAY_IN_SECONDS    );
define( 'YEAR_IN_SECONDS',  365 * DAY_IN_SECONDS    );

Example:

wp_cache_add($key, $data, 'default, 5 * DAY_IN_SECONDS);

Make WordPress globals more accessible

Wordpress using a lot globals variables. These variables are used throughout WordPress code for various reasons. Great example is database connection object wpdb. Here is common example how to use wpdb in some function:

function something() {
  global $wpdb;
  /** @var wpdb $wpdb */
  $wpdb->query('SQL...');
}

It's highly uncomfortable and long! Therefore, I have prepared a simple object which make all global variables much more accesible from anywhere: https://gist.github.com/OzzyCzech/4737518 (PHP 5.3+ only)

function something() {
  Globals::wpdb()->query('SQL...');
}