Quick video showing you how to setup Node.js with ExpressJs and NPM in Ubuntu in just a few minutes.
Saturday, 21 May 2016
Hwo to install NodeJS In Ubuntu
Quick video showing you how to setup Node.js with ExpressJs and NPM in Ubuntu in just a few minutes.
Tuesday, 1 December 2015
Ajax file upload with progress Bar
$("form#imageuploadform").on("submit", function (e) { var formData = new FormData($(this)[0]);
var timestamp = $("form#imageuploadform input#timestamp").val(); $.ajax({ url: shr_ajax.ajaxurl,
type: 'POST',
enctype: 'multipart/form-data',
data: formData,
dataType: "json",
xhr: function () { var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { myXhr.upload.addEventListener('progress', progress, false);
} return myXhr;
},
cache: false,
contentType: false,
processData: false,
success: function (data) {
if (data.id == timestamp && data.success === true) { alert(data.message);
$("#import_user_csv").removeAttr("disabled");
$("#import_user_data_form").css("opacity", "1");
}
if (data.id == timestamp && data.success === false) { alert(data.message);
}
$('form#imageuploadform')[0].reset();
},
error: function (data) { console.log(data);
$('form#imageuploadform')[0].reset();
} });
e.preventDefault(); });
function progress(e) { if (e.lengthComputable) { var max = e.total; var current = e.loaded; var Percentage = (current * 100) / max;
var percent_upload = Math.round(Percentage);
console.log(percent_upload);
jQuery("#percent_upload").css("width", percent_upload + "%");
jQuery("#percent_upload").text(percent_upload + "%");
if (Percentage >= 100) { //alert("Uploading finish.");
}
} }
Sunday, 28 June 2015
Media Queries for Standard Resolutions
/* mobile*/
@media (max-width: 320px) { }
/*Smartphones*/
@media (max-width: 480px) { }
/* Smartphones to Tablets */
@media (min-width: 481px) and (max-width: 767px) { }
/* Tablets */
@media (min-width: 768px) and (max-width: 959px) { }
/* Desktop */
@media (min-width: 960px) and (max-width: 1199px) { }
/* Desktop */
@media (min-width: 1200px) { }
@media (max-width: 320px) { }
/*Smartphones*/
@media (max-width: 480px) { }
/* Smartphones to Tablets */
@media (min-width: 481px) and (max-width: 767px) { }
/* Tablets */
@media (min-width: 768px) and (max-width: 959px) { }
/* Desktop */
@media (min-width: 960px) and (max-width: 1199px) { }
/* Desktop */
@media (min-width: 1200px) { }
Saturday, 2 May 2015
How do i remove a pre exising customizer setting in wordpress theme
add_action( 'customize_register', 'ruth_sherman_theme_customize_register' );
function ruth_sherman_theme_customize_register( $wp_customize ) {
$wp_customize->remove_control('header_image');
$wp_customize->remove_panel('widgets');
$wp_customize->remove_section('colors');
$wp_customize->remove_section('background_image');
$wp_customize->remove_section('static_front_page');
}
function ruth_sherman_theme_customize_register( $wp_customize ) {
$wp_customize->remove_control('header_image');
$wp_customize->remove_panel('widgets');
$wp_customize->remove_section('colors');
$wp_customize->remove_section('background_image');
$wp_customize->remove_section('static_front_page');
}
Monday, 9 February 2015
jquery parallax background image
$(document).ready(function(jQuery) {
$('.my_testimonial').each(function($) {
// assigning the object
var bgobj = jQuery(".my_testimonial");
jQuery(window).scroll(function($){
var sco_top = jQuery(window).scrollTop();
var yPos = -(sco_top / 1.7);
// Put together our final background position
var coords = '50% ' + yPos + 'px';
console.log(coords);
// Move the background
jQuery(".my_testimonial").css("backgroundPosition", coords);
});
});
});
$('.my_testimonial').each(function($) {
// assigning the object
var bgobj = jQuery(".my_testimonial");
jQuery(window).scroll(function($){
var sco_top = jQuery(window).scrollTop();
var yPos = -(sco_top / 1.7);
// Put together our final background position
var coords = '50% ' + yPos + 'px';
console.log(coords);
// Move the background
jQuery(".my_testimonial").css("backgroundPosition", coords);
});
});
});
Get post between dates in wordpress
$args = array(
'posts_per_page' => -1,
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'cat' => 59,
'date_query' => array(
array(
'after' => array(
'year' => 2015,
'month' => 02,
'day' => 06,
'hour' => 10,
'minute' => 28,
'second' => 55,
),
'before' => array(
'year' => 2015,
'month' => 02,
'day' => 09,
'hour' => 15,
'minute' => 24,
'second' => 01,
),
),
),
);
$query_result = new WP_Query($args);
User can access only own media in wordpress
add_filter( 'ajax_query_attachments_args', 'show_users_own_attachments', 1, 1 );
function show_users_own_attachments($query){
$id = get_current_user_id();
if( !current_user_can('manage_options') )
$query['author'] = $id;
return $query;
}
Subscribe to:
Posts (Atom)
