Skip to content

Instantly share code, notes, and snippets.

@Ziewvater
Ziewvater / gist:998b5806b0d12e4cf35b
Created March 27, 2015 00:25
Determining if swift string contains emoji character
func containsEmoji(text: String) -> Bool {
var containsEmoji = false
for scalar in text.unicodeScalars {
switch scalar.value {
case 0x1F600...0x1F64F:
// Emoticons
containsEmoji = true
case 0x1F300...0x1F5FF:
// Misc Symbols and Pictographs
containsEmoji = true
@stecman
stecman / monday-for-week.php
Last active June 24, 2022 10:13
Reliable PHP function to return Monday for week (pre-PHP 7.1)
<?php
/**
* Find the starting Monday for the given week (or for the current week if no date is passed)
*
* This is required as strtotime considers Sunday the first day of a week,
* making strtotime('Monday this week') on a Sunday return the adjacent Monday
* instead of the previous one.
*
* @param string|\DateTime|null $date