This time I would like to share few Laravel quick tips, which I use and it help me to make some things faster and cleaner code.

In Routes, you can create a group within a group. Also, assign a certain middleware only to some of them.

Route::group(['prefix' => 'user', 'as' => 'user.'], function() {
 Route::get('login', '[email protected]');
 Route::get('register', '[email protected]');
 Route::group(['middleware' => 'auth'], function() {
   Route::get('edit', '[email protected]');
 });
});
Continue reading

AWS provides great services and can be easily configured to handle big traffic spikes. However, sometimes some nuance occurs when a big amount of data need to process. For example, I was using SQS in my Laravel project. We are letting the Credential Provider retrieve the credentials to access SQS service via the IAM role attached to the EC2 instance. This works great but due to the volume of traffic we get this exception thousands of times a day:

Continue reading

Some times need to add custom classes in wordpress tinymce editor. This is simple solution to do this:

add_filter('tiny_mce_before_init', 'oi_tinymce');
function oi_tinymce($settings) {
	$new_styles = array(
		array(
			'title' => 'None',
			'value'	=> ''
		),
		array(
			'title'	=> 'Table',
			'value'	=> 'table',
		),
	);
	$settings['table_class_list'] = json_encode( $new_styles );
	return $settings;
}

Here’s a function that can get the mime type of a remote file. It will also follow any redirects that are in place.

function get_url_mime_type($url)
{

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_exec($ch);
return curl_getinfo($ch, CURLINFO_CONTENT_TYPE);

}

Below I’ll give you some examples on how you can extend the functionality of the TinyMCE.

Adding Font Size & Font Family Selects

By default the Custom Fonts and font sizes are not added into the TinyMCE editor. The function below will add both of these dropdowns to the far left of the editor in the second row. Simply change where it says ‘mce_buttons_2′ if you want it in a different row (ex: use ‘mce_buttons_3′ for the 3rd row).

if ( ! function_exists( 'wp_mce_buttons' ) ) {
	function wp_mce_buttons( $buttons ) {
		array_unshift( $buttons, 'fontselect' ); // Add Font Select
		array_unshift( $buttons, 'fontsizeselect' ); // Add Font Size Select
		return $buttons;
	}
}
add_filter( 'mce_buttons_2', 'wp_mce_buttons' );

Continue reading