Skip to content

Instantly share code, notes, and snippets.

View a-am's full-sized avatar

Adam Randlett a-am

View GitHub Profile
(function (m) {
/*
* PHP => moment.js
* Will take a php date format and convert it into a JS format for moment
* http://www.php.net/manual/en/function.date.php
* http://momentjs.com/docs/#/displaying/format/
*/
var formatMap = {
d: 'DD',
D: 'ddd',
@a-am
a-am / simple-pagination.js
Created July 16, 2019 04:52 — 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;
<template>
<div>
<input v-model="emailAddress" type="email" placeholder="[email protected]" />
<button @click="submitForm">{{subscribeText}}</button>
</div>
</template>
<script>
export default {
data() {
return {
@a-am
a-am / group-objects-by-property.md
Created February 24, 2021 15:14 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@a-am
a-am / module.php
Created June 24, 2022 04:16 — forked from daltonrooney/module.php
Clear Craft CMS cache after Entry save event
<?php
use yii\base\Event;
use Craft;
use craft\elements\Entry;
Event::on(
Entry::class,
Entry::EVENT_AFTER_SAVE,
function(ModelEvent $event) {