Skip to content

Instantly share code, notes, and snippets.

View chrisjonesio's full-sized avatar

Chris Jones chrisjonesio

View GitHub Profile
@chrisjonesio
chrisjonesio / emoji_flags.php
Created September 15, 2018 14:53
An array of country flag emojis for PHP 7+ unicode codepoint escape syntax
<?php
// ISO country code source: https://en.wikipedia.org/wiki/ISO_3166-1
// Emoji unicode codes: http://unicode.org/emoji/charts/full-emoji-list.html#country-flag
// An array to hold all the countries
$emoji_flags = array();
// Now, all the country flags as emojis
$emoji_flags["AD"] = "\u{1F1E6}\u{1F1E9}";
$emoji_flags["AE"] = "\u{1F1E6}\u{1F1EA}";
@chrisjonesio
chrisjonesio / offline-article-titles-descriptions.js
Last active September 19, 2018 01:59
A quick demo showing how to grab the title and descritpion of cached articles on an offline page displayed from a service worker
// first open the articles cache
// this cache is specified in the service worker where the
// offline handling code is kept
caches.open('articles')
.then(articlesCache => {
articlesCache.keys()
.then(keys => {
// loop over each article from the cache
keys.forEach(request => {
let markup = '';