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 isMobile = { | |
Android: function() { | |
return navigator.userAgent.match(/Android/i); | |
}, | |
BlackBerry: function() { | |
return navigator.userAgent.match(/BlackBerry/i); | |
}, | |
iOS: function() { | |
return navigator.userAgent.match(/iPhone|iPad|iPod/i); | |
}, |
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
wget -r -l 20 ftp://username:password@www.example.org/htdocs/* |
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
<?php | |
// Code with trick | |
$subject = "I Love You ❤"; | |
$updated_subject = "=?UTF-8?B?" . base64_encode($subject) . "?="; | |
mail("email@receiver.com",$updated_subject,"This email subject should not contain JUNK characters."); |
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
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"MM-dd-yyy"]; | |
// To use a specific start date | |
// NSDate *startDate = [formatter dateFromString:@"02-16-2013"]; | |
// Start with todays date | |
NSDate *startDate = [NSDate date]; | |
// End date |
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
############################################ | |
## 503 Maintenance mode | |
RewriteCond %{REQUEST_URI} !^/maintenance/ | |
RewriteCond %{REMOTE_HOST} !^YOUR\.IP\.ADDRESS\.HERE$ | |
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1$ | |
RewriteRule .* index.php [R=503,L] | |
ErrorDocument 503 /maintenance/maintenance.html |
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 paypalFees($sub_total, $round_fee) { | |
// Set Fee Rate Variables | |
$fee_percent = '3.4'; // Paypal's percentage rate per transaction (3.4% in UK) | |
$fee_cash = '0.20'; // Paypal's set cash amount per transaction (£0.20 in UK) | |
// Calculate Fees | |
$paypal_fee = ((($sub_total / 100) * $fee_percent) + $fee_cash); | |
if ($round_fee == true) { |
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 downloadFile($file){ | |
$file_name = $file; | |
$mime = 'application/force-download'; | |
header('Pragma: public'); // required | |
header('Expires: 0'); // no cache | |
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
header('Cache-Control: private',false); | |
header('Content-Type: '.$mime); | |
header('Content-Disposition: attachment; filename="'.basename($file_name).'"'); | |
header('Content-Transfer-Encoding: binary'); |
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 distance($lat1, $lon1, $lat2, $lon2, $unit) { | |
$theta = $lon1 - $lon2; | |
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); | |
$dist = acos($dist); | |
$dist = rad2deg($dist); | |
$miles = $dist * 60 * 1.1515; | |
$unit = strtoupper($unit); | |
if ($unit == "K") { |
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
<?php | |
function highlight($astring, $aword) { | |
if (!is_array ($aword) || !is_string ($astring) || empty ($aword) ) { | |
return false; | |
} | |
$aword = implode ('|', $aword); | |
return preg_replace ('@\b('.$aword.')\b@si', '<strong style="background-color:red">$1</strong>', $astring); | |
} |
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 crawlerDetect($user_agent) | |
{ | |
$crawlers_agents = 'Google|msnbot|Rambler|Yahoo|AbachoBOT|accoona|AcioRobot|ASPSeek|CocoCrawler|Dumbot|FAST-WebCrawler|GeonaBot|Gigabot|Lycos|MSRBOT|Scooter|AltaVista|IDBot|eStyle|Scrubby'; | |
return strpos($crawlers_agents , $USER_AGENT) === false)?0:1; | |
} |