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
##Ubuntu Cleanup: How to Remove All Unused Linux Kernel Headers, Images and Modules | |
#First check uname -a to check your current version. | |
#List Unused Linux Kernel Headers, Images and Modules | |
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | |
sudo apt-get -y purge some-kernel-package | |
#List Unused Linux Kernel Headers, Images and Modules & Remove | |
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge |
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
##From PHP 5.6 => PHP 7.1 | |
Default PHP 5.6 is set on your system and you need to switch to PHP 7.1. Run the following commands to switch for Apache and command line. | |
#Apache:- | |
$ sudo a2dismod php5.6 | |
$ sudo a2enmod php7.1 | |
$ sudo service apache2 restart |
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
// Add Custom method for Email validation | |
jQuery.validator.addMethod("stEmail", function(value, element) { | |
return this.optional( element ) || /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( value ); | |
}, 'Please enter a valid email address.'); |
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
// Validate DOB 18 years or not | |
jQuery.validator.addMethod( "stValidDOB", function(value, element) { | |
var dob = value.split("-"); | |
var year = dob[0]; | |
var month = dob[1]; | |
var day = dob[2]; | |
var age = 18; | |
var mydate = new Date(); |
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
<?php | |
// WP Add Remove Body Classes | |
// Add | |
add_filter( 'body_class','mh_body_classes' ); | |
function my_body_classes( $classes ) { | |
$classes[] = 'class-name'; | |
$classes[] = 'class-name-two'; |
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
// Third party links will be opened in a new tab/window | |
$("a").filter(function () { | |
return this.hostname && this.hostname.replace('www.', '') !== location.hostname.replace('www.', ''); | |
}).attr('target', '_blank'); |
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
Afghanistan | |
Aland Islands | |
Albania | |
Algeria | |
American Samoa | |
Andorra | |
Angola | |
Anguilla | |
Antarctica | |
Antigua and Barbuda |
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
AD : Andorra | |
AE : United Arab Emirates | |
AF : Afghanistan | |
AG : Antigua and Barbuda | |
AI : Anguilla | |
AL : Albania | |
AM : Armenia | |
AN : Netherlands Antilles | |
AO : Angola | |
AQ : Antarctica |
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
$sfurl = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8'; | |
$sffields = array( | |
'oid' => 'someoid', | |
'lead_source' => 'my website', | |
'last_name' => urlencode($_POST['name']), | |
'company' => urlencode($_POST['organization']), | |
'email' => urlencode($_POST['email']), | |
'phone' => urlencode($_POST['phone']), | |
); | |
foreach($sffields as $key=>$value) { $fieldstring .= $key.'='.$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
// Format string to SSN (Social Security Number) in the format of XXX-XX-XXXX | |
function string_to_ssn( $ssn = "111223333" ) { | |
return substr($ssn, 0, 3).'-'.substr($ssn, 3, 2).'-'.substr($ssn,5); | |
} | |
// Format string to SSN by preg_replace | |
function string_to_ssn_2( $ssn = "111223333" ) { | |
$ssn = preg_replace('/[^\d]/', '', $ssn); | |
$ssn = preg_replace('/^(\d{3})(\d{2})(\d{4})$/', '$1-$2-$3', $ssn); |