This file contains hidden or 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
| // Validation wrappe init & rules | |
| $("#form").validate({ | |
| errorClass: 'invalid', | |
| validClass: 'valid', | |
| errorPlacement: function(error, element) { | |
| error.insertAfter($(element)); | |
| // error.insertAfter($(element).siblings('label')); | |
| }, | |
| rules: { | |
| 'name': { |
This file contains hidden or 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
| <script type="text/javascript"> | |
| $(document).ready(function() { | |
| var masks = { | |
| 'int': /[\d]/, | |
| 'float': /[\d\.]/, | |
| 'money': /[\d\.\s,]/, | |
| 'num': /[\d\-\.]/, | |
| 'hex': /[0-9a-f]/i, | |
| 'email': /[a-z0-9_\.\-@]/i, |
This file contains hidden or 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 randIdGen() { | |
| var text = ""; | |
| var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
| for( var i=0; i < 5; i++ ) | |
| text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
| return '#' + text; | |
| } |
This file contains hidden or 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
| [ | |
| { | |
| "name":"United Arab Emirates", | |
| "dial_code":"+971", | |
| "code":"AE" | |
| }, | |
| { | |
| "name":"Afghanistan", | |
| "dial_code":"+93", | |
| "code":"AF" |
This file contains hidden or 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 setURLParam(key, value) { | |
| var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "i"); | |
| var newSearch = location.search; | |
| // Is the key-value pair present in the existing search? | |
| if (re.test(newSearch)) { | |
| // Update a value | |
| newSearch = newSearch.replace(re, '$1' + key + "=" + value + '$2$3'); | |
| } else { | |
| // Add the key and its value |
This file contains hidden or 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 express = require("express"); | |
| var app = express.createServer(); | |
| var port = 9090; | |
| app.all(/.*/, function(req, res, next) { | |
| var host = req.header("host"); | |
| if (host.match(/^www\..*/i)) { | |
| next(); | |
| } else { | |
| res.redirect(301, "http://www." + host); |
This file contains hidden or 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
| // Adding current user to www-data | |
| sudo adduser $USER www-data | |
| //change ownership to user:www-data and | |
| sudo chown $USER:www-data -R /var/www/html | |
| sudo chmod u=rwX,g=srX,o=rX -R /var/www/html | |
| // change file permissions of existing files and folders to 755/644 | |
| sudo find /var/www/html -type d -exec chmod g=rwxs "{}" \; |
This file contains hidden or 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
| <input type="text" | |
| pattern="[a-zA-Z0-9_]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?!([a-zA-Z0-9]*\.[a-zA-Z0-9]*\.[a-zA-Z0-9]*\.))(?:[A-Za-z0-9](?:[a-zA-Z0-9-]*[A-Za-z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?" | |
| required> |
This file contains hidden or 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
| <IfModule mod_expires.c> | |
| ExpiresActive On | |
| ExpiresByType image/jpg "access 1 year" | |
| ExpiresByType image/jpeg "access 1 year" | |
| ExpiresByType image/gif "access 1 year" | |
| ExpiresByType image/png "access 1 year" | |
| ExpiresByType text/css "access 1 month" | |
| ExpiresByType text/html "access 1 month" | |
| ExpiresByType application/pdf "access 1 month" | |
| ExpiresByType text/x-javascript "access 1 month" |
This file contains hidden or 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
| // initialize validate plugin on the form | |
| $('#contact-form').validate({ | |
| errorPlacement: function (error, element) { | |
| var lastError = $(element).data('lastError'), | |
| newError = $(error).text(); | |
| $(element).data('lastError', newError); | |
| if(newError !== '' && newError !== lastError){ |