Skip to content

Instantly share code, notes, and snippets.

View johnabela's full-sized avatar
🏠
Working from home

John Abela johnabela

🏠
Working from home
View GitHub Profile
@johnabela
johnabela / htaccess domain.tld{dash}usersname
Created February 25, 2017 01:57
htaccess to allow domain.tld/usersname
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(register|contact|signin|policies) [NC]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /profile.php?id=$1 [L,QSA]
@johnabela
johnabela / [PHP] Are All Characters Identical?
Last active February 22, 2017 18:33
[PHP] Are All Characters Identical?
$word = 'dddddd';
if (empty(str_replace(mb_substr(trim($word),-1),'',trim($word)))) {
die('all the characters are identical');
}
$Today = gregoriantojd(date('n'),date('j'),date('Y'));
$Month = jdmonthname($Today,4);
$Date = jdtojewish($Today);
list($notused, $Day, $Year) = explode('/',$Date);
echo "$Month $Day, $Year";
$start = new DateTime('now');
$end = new DateTime('- 7 day');
$diff = $end->diff($start);
$interval = DateInterval::createFromDateString('-1 day');
$period = new DatePeriod($start, $interval, $diff->days);
foreach ($period as $date) {
echo $date->format('m-d') . '<br>'; // or whatever you want to do
}
@johnabela
johnabela / [PHP] intToOrdinal()
Last active August 29, 2015 14:09
Add Ordinal Text (st/nd/th) To Integer
//
//
///////////////////////////////////////////////////////////////////////
// intToOrdinal()
//
// - Description:
// Add Ordinal Text To Integer
//
// - Usage:
// $str_return = intToOrdinal($number);
@johnabela
johnabela / [PHP] bitly_MakeShortLink()
Last active September 8, 2015 09:55
Use the bit.ly api to generate short URL
@johnabela
johnabela / [PHP] howManyDaysBetweenTwoDays()
Last active August 29, 2015 14:09
How many days between two unix time stamps
//
//
///////////////////////////////////////////////////////////////////////
// howManyDaysBetweenTwoDays()
//
// - Description:
// How many days between two unix time stamps
// 86400 is derived from:
// 60 (seconds) multiplied by 60 (minutes) multiplied by 24 (hours)
//