Skip to content

Instantly share code, notes, and snippets.

View mindmergedesign's full-sized avatar

Juan Giraldo mindmergedesign

View GitHub Profile
{"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\\\"
@mindmergedesign
mindmergedesign / SanityImageLoader.ts
Created September 22, 2022 19:23 — forked from ulises-codes/SanityImageLoader.ts
Custom Sanity loader for Next JS Image component.
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;
}
@mindmergedesign
mindmergedesign / group-objects-by-property.md
Created August 10, 2022 01:46 — 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;
@mindmergedesign
mindmergedesign / Layout.tsx
Created March 23, 2022 00:18
sample layout component using typescript
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) => (
@mindmergedesign
mindmergedesign / xmlToJson.js
Created June 10, 2021 03:41 — forked from chinchang/xmlToJson.js
Function to convert XML to JSON
/**
* 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) {
@mindmergedesign
mindmergedesign / mission_control_ext_bkp.json
Last active May 24, 2021 19:12
Mission Control Chrome Extension Backup Data
{
"sites": [
{
"cid": "4cad9ae6f9b740844b9bd85b",
"date": 1619661482694,
"id": 1,
"label": "Top Sites",
"starred": false,
"websites": [
{
@mindmergedesign
mindmergedesign / .eleventy.js
Created April 23, 2021 17:13 — forked from freshyill/.eleventy.js
Vimeo Editor Component for Netlify CMS
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.
@mindmergedesign
mindmergedesign / videoEmbed.js
Created March 19, 2021 15:56 — forked from bzerangue/videoEmbed.js
videoEmbed.js contentType - preview component for Sanity.io CMS richText PortableText editor - based off of Knut's YouTube Preview, https://www.youtube.com/watch?v=kLsER_zHiS4
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’

1. Convert JSON to NDJSON?

cat test.json | jq -c '.[]' > testNDJSON.json
@mindmergedesign
mindmergedesign / deleteDocsWithoutSchema.js
Created February 2, 2021 20:43 — forked from kmelve/deleteDocsWithoutSchema.js
Delete documents without corrensponding schema definition in a Sanity Studio folder
/**
* This script can be placed in the root of your studio folder,
* and be run with `sanity exec deleteDocsWithoutSchema.js --with-user-credentials
*/
import client from 'part:@sanity/base/client'
const getSanitySchema = require('./node_modules/@sanity/core/lib/actions/graphql/getSanitySchema')
const Schema = getSanitySchema(process.cwd())
const types = Schema._original.types.map(({name}) => name)