Prevent post from being published if no category selected

You can do this easily with jQuery:

/* Checks if cat is selected when publish button is clicked */
jQuery( '#submitdiv' ).on( 'click', '#publish', function( e ) {
    var $checked = jQuery( '#category-all li input:checked' );

    //Checks if cat is selected
    if( $checked.length <= 0 ) {
        alert( "Please Select atleast one category" );
        return false;
    } else { 
        return true;
    }
} );

The above code will show an alert box if no category is selected. You can use dialog box instead if you’d like.