const groupBy = key => array =>
array.reduce((objectsByKeyValue, obj) => {
const value = obj[key];
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace modules; | |
use Craft; | |
use yii\base\Event; | |
use craft\events\DefineGqlTypeFieldsEvent; | |
use craft\gql\TypeManager; | |
use GraphQL\Type\Definition\Type; | |
use modules\types\VideoGqlType; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#DB Backup Restore *LOCAL ONLY* | |
#You can access other DB variables to add to the command. EX: {server}, {user}, {port}… | |
LOCAL_DB_BIN="/Users/Shared/DBngin/mysql/8.0.27/bin/" | |
BACKUP_COMMAND="${LOCAL_DB_BIN}mysqldump -h {server} -u {user} --port {port} --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --single-transaction --no-data --result-file=\"{file}\" {database} && ${LOCAL_DB_BIN}mysqldump -h {server} -u {user} --port {port} --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --no-create-info --ignore-table={database}.assetindexdata --ignore-table={database}.assettransformindex --ignore-table={database}.cache --ignore-table={database}.sessions --ignore-table={database}.templatecaches --ignore-table={database}.templatecachecriteria --ignore-table={database}.templatecacheelements --ignore-table={database}.templatecachequeries {database} >> \"{file}\"" | |
RESET_COMMAND="${LOCAL_DB_BIN}mysql -h {s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use yii\base\Event; | |
use Craft; | |
use craft\elements\Entry; | |
Event::on( | |
Entry::class, | |
Entry::EVENT_AFTER_SAVE, | |
function(ModelEvent $event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<input v-model="emailAddress" type="email" placeholder="[email protected]" /> | |
<button @click="submitForm">{{subscribeText}}</button> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implementation in ES6 | |
function pagination(c, m) { | |
var current = c, | |
last = m, | |
delta = 2, | |
left = current - delta, | |
right = current + delta + 1, | |
range = [], | |
rangeWithDots = [], | |
l; |
REQUEST
Craft::$app->getRequest()
Craft::$app->getRequest()->getAcceptsJson()
$this->asJson();
CURRENT USER
Craft::$app->getUser()->getIdentity()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Variables used in this script: | |
// $summary - text title of the event | |
// $datestart - the starting date (in seconds since unix epoch) | |
// $dateend - the ending date (in seconds since unix epoch) | |
// $address - the event's address | |
// $uri - the URL of the event (add http://) | |
// $description - text description of the event | |
// $filename - the name of this file for saving (e.g. my-event-name.ics) | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Database Configuration | |
* | |
* All of your system's database configuration settings go in here. | |
* You can see a list of the default settings in craft/app/etc/config/defaults/db.php | |
*/ | |
return array( |
NewerOlder