Skip to content

Instantly share code, notes, and snippets.

import $ from 'jquery';
const Colors = {
element: $('.background-color'),
steps: [
'rgb(238, 212, 177)',
'rgb(255, 255, 255)',
'rgb(245, 202, 229)',
@good-idea
good-idea / responsiveImage.php
Last active July 6, 2017 23:45
A basic responsive image plugin for Kirby
<?php
function responsiveImage($image, $classNames = [], $sizes = '100vw', $upscale = false) {
$widths = [2800, 1400, 1000, 600, 400, 100];
$imageWidth = $image->width();
$defaultClass = 'srcset-image';
if (gettype($classNames) === 'string') $classNames = explode(' ', $classNames);
array_push($classNames, $defaultClass);
$classString = join($classNames, ' ');
@good-idea
good-idea / getPublicContent.php
Created October 27, 2017 06:33
Export Kirby content as friendlier JSON
<?php
// site/plugins/page-methods.php
/*
* getAllImageURLs
*
* Returns an array of image objects for each image in the page
* (See the buildImage function at the bottom of this gist)
@good-idea
good-idea / LoginController.js
Created January 9, 2018 03:30
Login Controller with State Machine
// @flow
import React from 'react'
import axios from 'axios'
import R from 'ramda'
import Login from './Login'
/**
* LoginController
*/
/**
* Dependencies
*/
const express = require('express')
const Multer = require('multer')
const Busboy = require('busboy')
const os = require('os')
const fs = require('fs')
const path = require('path')
@good-idea
good-idea / postmark.js
Last active April 12, 2018 21:36
Simple postmark emails. (untested POC!)
const postmark = require('postmark')
const config = require('../config')
const client = new postmark.Client(config.postmark.key)
const sendEmail = async ({ From = config.fromEmail, To, Subject, HTMLBody, TextBody, ...opts }) => {
await client.sendEmail({
From,
To,
Subject,
@good-idea
good-idea / getUsers.js
Last active May 1, 2018 01:06
AQL Queries with optional filters
import db from '../../database'
import type { PaginationArgs, PageType } from './types'
// Sample Usage:
// const tenJapaneseUsers = await getUsers({ first: 10, filter: [{ key: 'locale', value: 'jp' }])
const getUsers = async ({ first = 50, filter, after = 0 }: PaginationArgs): Promise<PageType | null | Error> => {
const filterQuery = filter
? filter.reduce((acc, { key, operator }) => `${acc}FILTER u.${key} ${operator || '=='} @${key}`, '')
@good-idea
good-idea / Apollo.js
Created June 3, 2018 19:28
Apollo error logging problems
// @flow
import React from 'react'
import type { Node } from 'react'
import { ApolloProvider } from 'react-apollo'
import { ApolloLink } from 'apollo-link'
import { ApolloClient } from 'apollo-client'
import { onError } from 'apollo-link-error'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { createUploadLink } from 'apollo-upload-client'
@good-idea
good-idea / SketchSystems.spec
Last active August 29, 2018 21:27
Welcome*
Welcome*
selectedTeacherFlow -> TeacherFlow
selectedStudentFlow -> StudentFlow
StudentFlow
back -> Welcome
SelectClassroom
selectedClassroom -> SelectStudent
SelectStudent
selectedStudent -> UserLogin
TeacherFlow
@good-idea
good-idea / SketchSystems.spec
Last active February 5, 2019 17:50
StudentLogin*
StudentLogin*
clickedTeacherLogin -> TeacherLogin
back -> StudentLogin
SelectClassroom
selectedClassroom -> SelectStudent
SelectStudent
selectedStudent -> UserLogin
TeacherLogin
clickedStudentLogin -> StudentLogin
EnterTeacherEmail