const groupBy = key => array =>
array.reduce((objectsByKeyValue, obj) => {
const value = obj[key];
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
This file contains 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
// with thanks to https://github.com/Urigo/graphql-modules/blob/8cb2fd7d9938a856f83e4eee2081384533771904/website/lambda/contact.js | |
const process = require('process') | |
const { promisify } = require('util') | |
const sendMailLib = require('sendmail') | |
const { validateEmail, validateLength } = require('./validations') | |
const sendMail = promisify(sendMailLib()) |
This file contains 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
{"name":"vs-code-profile","settings":"{\"settings\":\"// Place your settings in this file to overwrite the default settings\\n{\\n // Controls the font family.\\n \\\"editor.fontFamily\\\": \\\"'Cascadia Code', 'Operator Mono', 'Fira Code', Consolas, 'Courier New', monospace\\\",\\n // Controls the font size.\\n \\\"editor.fontSize\\\": 18,\\n // Controls the line height. Use 0 to compute the lineHeight from the fontSize.\\n \\\"editor.lineHeight\\\": 24,\\n // Enables font ligatures\\n \\\"editor.fontLigatures\\\": true,\\n // Controls if file decorations should use badges.\\n \\\"explorer.decorations.badges\\\": false,\\n // Insert snippets when their prefix matches. Works best when 'quickSuggestions' aren't enabled.\\n \\\"editor.tabCompletion\\\": \\\"onlySnippets\\\",\\n // Controls whether the editor should render whitespace characters\\n \\\"editor.renderWhitespace\\\": \\\"none\\\",\\n \\\"[javascript]\\\": {\\n \\\"editor.formatOnSave\\\": true,\\n \\\"editor.defaultFormatter\\\" |
This file contains 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
import Image, { ImageProps } from 'next/image'; | |
import { imageBuilder } from './sanity'; | |
import type { SanityImageSource } from '@sanity/image-url/lib/types/types'; | |
interface MyImageProps extends Omit<ImageProps, 'src'> { | |
src: SanityImageSource; | |
quality?: number; | |
blur?: number; | |
} |
This file contains 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
import React, { ReactNode } from 'react' | |
import Link from 'next/link' | |
import Head from 'next/head' | |
type Props = { | |
children?: ReactNode | |
title?: string | |
} | |
const Layout = ({ children, title = 'This is the default title' }: Props) => ( |
This file contains 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
/** | |
* Changes XML to JSON | |
* Modified version from here: http://davidwalsh.name/convert-xml-json | |
* @param {string} xml XML DOM tree | |
*/ | |
function xmlToJson(xml) { | |
// Create the return object | |
var obj = {}; | |
if (xml.nodeType == 1) { |
This file contains 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
{ | |
"sites": [ | |
{ | |
"cid": "4cad9ae6f9b740844b9bd85b", | |
"date": 1619661482694, | |
"id": 1, | |
"label": "Top Sites", | |
"starred": false, | |
"websites": [ | |
{ |
This file contains 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
module.exports = function(eleventyConfig) { // This only happens once in your template! | |
// Blah blah, whatever other Eleventy stuff you need. | |
eleventyConfig.addLiquidShortcode("vimeo", (vimeoId, aspectRatio) => { | |
return `<div class="aspect-ratio" style="--aspect-ratio: ${aspectRatio}"><iframe src="https://player.vimeo.com/video/${vimeoId}" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen class="video video--vimeo"></iframe></div>`; | |
}); | |
// Blah blah, whatever other Eleventy stuff you need. | |
This file contains 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
import React from 'react' | |
const VideoEmbedPreview = ({ value }) => { | |
const url = value.url | |
const responsiveVideoContainer = { | |
padding: "56.25% 0 0 0", | |
position: "relative" | |
} |
NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.
- Each line is a valid JSON value
- Line separator is ‘\n’
cat test.json | jq -c '.[]' > testNDJSON.json
NewerOlder