Skip to content

Instantly share code, notes, and snippets.

View iamuteti's full-sized avatar

John Muteti iamuteti

View GitHub Profile
@iamuteti
iamuteti / externalRedirect.ts
Created April 27, 2023 05:51 — forked from justin-schroeder/externalRedirect.ts
Perform an external redirect in Nuxt 3 router middleware
import { useNuxtApp } from '#app'
import { sendRedirect } from 'h3'
/**
* Performs an external redirect in a Nuxt3 route middleware. Once this Nuxt3
* pull request is merged, this function can be removed in favor of navigateTo:
*
* https://github.com/nuxt/framework/pull/5022
*
* @param url - An external url to redirect to
@iamuteti
iamuteti / media-query.css
Created August 15, 2020 03:54 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@iamuteti
iamuteti / notify-awssns2fcm.js
Created August 8, 2019 14:25 — forked from shinoda-ak/notify-awssns2fcm.js
Notify FCM for Android via AWS SNS
// Notify Target ARN for Android device
'use strict';
const AWS = require('aws-sdk');
const sns = new AWS.SNS({
apiVersion: '2010-03-31',
region: 'MY_REGION'
});
if (process.argv.length < 3) {
console.log('Usage: node notify.js ENDPOINT_ARN');
process.exit();
@iamuteti
iamuteti / mapOrder.js
Created March 7, 2019 08:45 — forked from ecarter/mapOrder.js
Order an array of objects based on another array order
/**
* Sort array of objects based on another array
*/
function mapOrder (array, order, key) {
array.sort( function (a, b) {
var A = a[key], B = b[key];
@iamuteti
iamuteti / Javascript ISO country code to country name conversion
Created December 28, 2018 11:19 — forked from maephisto/Javascript ISO country code to country name conversion
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
@iamuteti
iamuteti / simple-pagination.js
Created May 12, 2018 11:20 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@iamuteti
iamuteti / template.php
Created February 15, 2016 10:56 — forked from JeffreyWay/template.php
Template Example
<?php
$template = "I am {{name}}, and I work for {{company}}. I am {{age}}.";
# Your template tags + replacements
$replacements = array(
'name' => 'Jeffrey',
'company' => 'Envato',
'age' => 27
);