Skip to content

Instantly share code, notes, and snippets.

View mornir's full-sized avatar
🎮
Gaming

Jérôme Pott mornir

🎮
Gaming
View GitHub Profile
const blocks = `blocks[] {
...,
photos[] {
...,
"metadata": asset->metadata,
},
markDefs[] {
...,
_type == "internalLink" => {
"slug": @->slug.current,
@mornir
mornir / schema.js
Created February 7, 2021 16:01
Unused schema snippet for terminofeu
{
name: 'collection',
title: 'Terminologiesammlung',
type: 'string',
options: {
list: [{ title: 'BSV 10-15', value: 'bsv_10-15' }],
},
},
{
name: 'domain',
@mornir
mornir / deskStructureWithRoles.js
Created September 19, 2020 18:12
Simple example on how to return a structure depending on the logged in user‘s role.
import S from '@sanity/base/structure-builder'
import userStore from 'part:@sanity/base/user'
// remember to add rxjs/operators to your dependencies with npm or yarn
import {
map
} from 'rxjs/operators'
export default () => userStore.currentUser.pipe(
map(({user}) => {
const {role} = user
@mornir
mornir / easings.css
Created July 25, 2020 15:42 — forked from argyleink/easings.css
Handy CSS properties for easing functions
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
@mornir
mornir / mailchimp_netlify_form.js
Created June 24, 2020 18:51
Submit email to Mailchimp via Netlify Form. Delete data from Netlify after submission to Mailchimp.
const axios = require('axios')
const crypto = require('crypto')
const region = process.env.MAILCHIMP_API_KEY.split('-')[1]
const apiRoot = `https://${region}.api.mailchimp.com/3.0/lists/${process.env.MAILCHIMP_LIST_ID}/members/`
function deleteSubmission(id) {
const url = `https://api.netlify.com/api/v1/submissions/${id}?access_token=${process.env.NETLIFY_ACCESS_TOKEN}`
return axios.delete(url)
@mornir
mornir / cron_job.yml
Created February 25, 2020 18:38
Trigger Sanity Backup through serverless function
name: Trigger Backup
on:
schedule:
# Runs at 04:00 UTC on the 1st and 17th of every month
- cron: '0 4 */16 * *'
jobs:
build:
name: Trigger Netlify Function
runs-on: ubuntu-latest
steps:
@mornir
mornir / nuxt-polyfill.js
Created January 17, 2020 11:20
Example of config for nuxt-polyfill module
polyfill: {
features: [
{
require: 'object.entries',
detect: () => 'entries' in window.Object,
install: entries => entries.shim(),
},
{
require: 'url-search-params-polyfill',
detect: () => 'URLSearchParams ' in window,
@mornir
mornir / challenge-1.js
Last active January 3, 2020 19:07
GROQ Pokédex Challenges
// Find the weakest Pokémon overall
*[]{
"overall": base.HP + base.Attack + base.Defense + base["Sp. Attack"] + base["Sp. Defense"] + base.Speed,
"name": name.english,
}|order(overall)[0]
@mornir
mornir / sanity-backup.js
Created December 25, 2019 20:13
Netlify Cloud function for content backup of Sanity CMS to Google Drive with notification to Slack
const differenceInDays = require('date-fns/differenceInDays')
const parseISO = require('date-fns/parseISO')
const sanity = require('@sanity/client')
const exportDataset = require('@sanity/export')
const { google } = require('googleapis')
const fetch = require('node-fetch')
const path = require('path')
const fs = require('fs')
const FOLDER_ID = process.env.FOLDER_ID
const isDraft = id => id.includes('drafts')
export default function resolveProductionUrl(document) {
if (!isDraft(document._id)) return undefined
const url = 'https://your-website.com'
if (document._type === 'recipe') {
return `${url}/rezepte/preview/?preview_id=${document._id}`
}