Skip to content

Instantly share code, notes, and snippets.

View dhavalwd's full-sized avatar
🎯
Focusing

Dhaval Vyas dhavalwd

🎯
Focusing
View GitHub Profile
@dhavalwd
dhavalwd / ConvertMS.js
Created May 27, 2020 20:14 — forked from flangofas/ConvertMS.js
JS: Convert Milliseconds to days? minutes? seconds? or all!
function convertMiliseconds(miliseconds, format) {
var days, hours, minutes, seconds, total_hours, total_minutes, total_seconds;
total_seconds = parseInt(Math.floor(miliseconds / 1000));
total_minutes = parseInt(Math.floor(total_seconds / 60));
total_hours = parseInt(Math.floor(total_minutes / 60));
days = parseInt(Math.floor(total_hours / 24));
seconds = parseInt(total_seconds % 60);
minutes = parseInt(total_minutes % 60);
@dhavalwd
dhavalwd / .htaccess
Created August 15, 2019 19:54 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@dhavalwd
dhavalwd / git-tag-delete-local-and-remote.sh
Created December 10, 2018 14:09 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@dhavalwd
dhavalwd / textWidth.js
Created October 24, 2017 12:01
textWidth function - calculate text width
// Copied from here: https://stackoverflow.com/a/2771544/1909380
// jQuery function to calculate text width
$.fn.textWidth = function(){
var html_org = $(this).html();
var html_calc = '<span>' + html_org + '</span>';
$(this).html(html_calc);
var width = $(this).find('span:first').width();
$(this).html(html_org);
return width;
@dhavalwd
dhavalwd / flexbox.scss
Created September 29, 2017 14:21 — forked from richardtorres314/flexbox.scss
CSS Flexbox - Sass Mixins
// --------------------------------------------------
// Flexbox SASS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
@mixin flexbox() {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
// Alerts
@include alert-variant($background, $border, $text-color);
// Background Variant
@include bg-variant($parent, $color);
// Border Radius
@include border-top-radius($radius);
@include border-right-radius($radius);
@include border-bottom-radius($radius);
@dhavalwd
dhavalwd / scrollto.js
Last active August 29, 2017 17:45
Easy Scroll to functions. Scroll within Body or scroll within parent element.
// For more information on this use below link.
// https://stackoverflow.com/questions/2346011/how-do-i-scroll-to-an-element-within-an-overflowed-div
// With Animation
jQuery.fn.scrollTo = function(elem, speed) {
$(this).animate({
scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top
}, speed == undefined ? 1000 : speed);
return this;
@dhavalwd
dhavalwd / multiFilter.js
Created August 25, 2017 16:03 — forked from jherax/filterArray.js
Filters an array of objects with multiple criteria.
/**
* Filters an array of objects with multiple criteria.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria as the property names
* @return {Array}
*/
function multiFilter(array, filters) {
const filterKeys = Object.keys(filters);
// filters all elements passing the criteria