Skip to content

Instantly share code, notes, and snippets.

View farez's full-sized avatar

Farez Rahman farez

View GitHub Profile
@farez
farez / global_date_formats.json
Last active May 8, 2022 01:48
Array of popular date formats used globally. Key is the date format, Value is the example output. Useful for select lists for selecting a date format.
{
"j F Y": "8 October 2021",
"d F Y": "08 October 2021",
"j n Y": "8 10 2021",
"d n Y": "08 10 2021",
"j m Y": "8 10 2021",
"d m Y": "08 10 2021",
"j M Y": "8 Oct 2021",
"d M Y": "08 Oct 2021",
"j F y": "8 October 21",
@farez
farez / grammatically-correct-list
Last active May 10, 2020 07:28
Converts a delimited string into a grammatically correct comma-separated sentence.
/**
* Converts a delimited string into a grammatically correct comma-separated sentence.
* E.g. andList('pdf,doc,xls') = 'pdf, doc, and xls'.
* And optional mutator function can be applied to each element.
* E.g. andList('pdf,doc,xls', 'strtoupper') = 'PDF, DOC, and XLS'
* @param $string
* @param string $mutator
* @return string
*/
function andList($string, $delimiter = ',', $mutator = '')
@farez
farez / 2-letter-avatar-with-background-colour.php
Last active May 8, 2020 06:00
Simple 2-letter avatars from name initials
/**
* Two letter avatars for https://atworkathome.co
* CSS not included.
**/
/**
* Get the 2-letter initials of the user. Uses the
* initials of the first and last words/names in $name.
* @param $name
* @return string