This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
download(): void { | |
const printContent = document.querySelector('.card-body'); | |
if (printContent) { | |
// Replace below line with library function, whichever you're using. | |
domToPng(printContent, { quality: 1, scale: 2 }) // Scale set to 2 for better quality in PDF | |
.then((canvas) => { | |
const imgData = canvas; | |
const pdf = new jsPDF('p', 'mm', 'letter'); // Portrait, mm, Letter size | |
const imgWidth = 86; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
Redirect "/" "https://your_website.com" | |
</VirtualHost> | |
<VirtualHost *:443> | |
ServerAdmin [email protected] | |
ServerName your_website.com | |
ServerAlias www.your_website.com | |
DocumentRoot /var/www/your_website.com | |
ErrorLog ${APACHE_LOG_DIR}/website_error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 example | |
function Subject () { | |
this.observers = []; // Array of observer functions | |
} | |
Subject.prototype = { | |
subscribe: function (fn) { | |
this.observers.push(fn) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To delete all merged branches except master and dev | |
git branch --merged | grep -v '\*\|master\|dev' | xargs -n 1 git branch -d | |
// To delete all branches except master and dev: | |
git branch | grep -v '\*\|master\|dev' | xargs -n 1 git branch -D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Phone Number format 000-000-0000 | |
export const formattedPhoneRegex = /^[0-9]\d{2}-\d{3}-\d{4}$/i; | |
export const emailRegex = /^[a-z0-9`!#\$%&\*\+\/=\?\^\'\-_]+((\.)+[a-z0-9`!#\$%&\*\+\/=\?\^\'\-_]+)*@([a-z0-9]+([\-][a-z0-9])*)+([\.]([a-z0-9]+([\-][a-z0-9])*)+)+$/i; | |
// No Special Chars | |
export const noSpecialCharRegex = /^[a-zA-Z0-9]+$/i; | |
// Auto format the phone number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2020-02-24T12:47:51.099Z","extensionVersion":"v3.4.3"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var observer = new MutationObserver(function (mutations) { | |
mutations.forEach(function (mutation) { | |
if (!mutation.addedNodes) return | |
for (var i = 0; i < mutation.addedNodes.length; i++) { | |
var item = Array.prototype.slice.call(mutation.addedNodes).find(function (i) { return i.id == "selector" }); | |
if (item) { | |
// Do your stuff here | |
observer.disconnect(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var httpRequest, root; | |
root = 'https://jsonplaceholder.typicode.com'; // URL for JSON data | |
document.querySelector('.ajaxButton').addEventListener('click', makeRequest); | |
function makeRequest() { | |
httpRequest = new XMLHttpRequest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Smooth Scroll | |
jQuery(function() { | |
jQuery('a[href*="#"]:not([href="#"])').click(function() { | |
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { | |
var target = jQuery(this.hash); | |
target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']'); | |
if (target.length) { | |
jQuery('html, body').animate({ | |
scrollTop: target.offset().top | |
}, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var position, direction, previous; | |
$(window).scroll(function(){ | |
if( $(this).scrollTop() >= position ){ | |
direction = 'down'; | |
if(direction != previous){ | |
$('.menu-toggle').addClass('hide'); | |
previous = direction; | |
} | |
} else { |
NewerOlder