Skip to content

Instantly share code, notes, and snippets.


Mike Elsmore ukmadlz

View GitHub Profile
ukmadlz / fb.min.js
Created Mar 6, 2018
Fizz Buzz without a for, with ternary operators and even smaller!
View fb.min.js
ukmadlz / fb.js
Created Mar 6, 2018
FizzBuzz without a for and on one line
View fb.js
console.log([...Array(100).keys()].map(function (i) { return i % 3 === 0 && i % 5 === 0 ? 'FizzBuzz' : i % 3 === 0 ? 'Fizz' : i % 5 === 0 ? 'Buzz' : i; }));
ukmadlz /
Created Mar 1, 2018
NodeJS Dev Questions: SWAPI

Using the API answer these questions




  • What is the difference between the youngest and oldest characters in Star Wars?
  • What’s the most common Species in the Star Wars universe listing the names of the characters that belong to the species?
  • Implement a basic Character search?
ukmadlz /
Last active Mar 1, 2018
NodeJS Dev: Time API

WebApi Time

Build a simple API to return the current timestamp in Unix time as a JSON object when a GET request is made to /time


Time is a hard concept.

Produce a system that takes a timestamp and an offset return the UTC, the local timestamp and new timestamp with the relevant offset.

View gist:dd9563c15c8efbe5cb8f539510dafe34
Alternative technical tasks
- Time is a hard concept, produce a system that takes a timestamp and an offset return the UTC, the local timestamp and new timestamp with the relevant offset.
- Write a program that prints all the numbers from 1 to 100. For multiples of 3, instead of the number, print "Fizz", for multiples of 5 print "Buzz". For numbers which are multiples of both 3 and 5, print "FizzBuzz".
- Write a single endpoint the accepts Basic Auth access and returns a JSON response of (NOTE: you do not need a data structure underneath)
ukmadlz / basic-manifest.json
Last active May 10, 2017
Cloudinary PWA React Blog
View basic-manifest.json
"name": "Donate App",
"description": "This app helps you donate to worthy causes.",
"icons": [{
"src": "images/icon.png",
"sizes": "192x192"
View service-worker-registration.js
// Add Service Worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./sw.js', { scope: './' }).then(function(reg) {
if (reg.installing) {
console.log('Service worker installing');
} else if (reg.waiting) {
console.log('Service worker installed');
} else if ( {
console.log('Service worker active');
View service-worker-install-task.js
var cacheNameStatic = 'cloudinary-pwa-react-v1';
var currentCacheNames = [ cacheNameStatic ];
var cachedUrls = [
// 3rd party CDN
View service-worker-fetch-task.js
self.addEventListener("fetch", function (event) {
event.respondWith( {
return cache.match(event.request).then(function(response) {
var fetchPromise = fetch(event.request).then(function(networkResponse) {
cache.put(event.request, networkResponse.clone());
return networkResponse;
return response || fetchPromise;
View service-worker-activate-task.js
// A new ServiceWorker is now active
self.addEventListener("activate", function (event) {
.then(function (cacheNames) {
return Promise.all( (cacheName) {
if (currentCacheNames.indexOf(cacheName) === -1) {
return caches.delete(cacheName);