Skip to content

Instantly share code, notes, and snippets.

View troyatomic's full-sized avatar

Troy Dugger troyatomic

View GitHub Profile
@troyatomic
troyatomic / index.js
Created September 22, 2022 16:05
Cloud Function that gets document data, posts to PubSub Topic with a Schema and deletes the document
const { Logging } = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.log('publishToBigQuery');
const { PubSub } = require('@google-cloud/pubsub');
const pubsub = new PubSub();
const protobuf = require('protobufjs');
const Firestore = require('@google-cloud/firestore');
export default {
name: 'productAnnotation',
type: 'object',
title: 'Reference to Product',
fields: [
{
title: 'Product',
name: 'productReference',
type: 'reference',
to: [
@troyatomic
troyatomic / pubspec.yaml
Created August 10, 2022 19:57
puspec.yaml file for pets project demo
name: petsproject
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
@troyatomic
troyatomic / main.dart
Last active August 16, 2022 14:36
Flutter main.dart file for Pets Project demo
import 'dart:convert';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:json_annotation/json_annotation.dart';
part 'main.g.dart';
void main() {
@troyatomic
troyatomic / pet.js
Last active August 15, 2022 16:30
Full content of modified pet.js file from Sanity's example Pets Project demo
import {JsonView} from '../components/views/JsonView'
import {DocumentIcon, EyeOpenIcon, StarIcon, PackageIcon} from '@sanity/icons'
import S from '@sanity/desk-tool/structure-builder'
import {PetPreview} from '../components/views/PetPreview'
import {RangeInput} from '../components/inputs/RangeInput'
import {CharacterCount} from '../components/inputs/CharacterCount'
import petIcon from '../components/icons/petIcon'
import ProductRenderer from "./components/ProductRenderer"
export default {
@troyatomic
troyatomic / pet-partial.js
Created August 8, 2022 19:22
Code snippet to replace line 47 of pet.js from `of: [{type: 'block'}, {type: 'image', options: {hotspot: true}}],`
of: [
{
type: 'block',
marks: {
annotations: [
{
name: 'product',
type: 'reference',
to: [
{
@troyatomic
troyatomic / ProductRenderer.js
Last active August 8, 2022 19:30
Sanity Annotation Renderer
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import sanityClient from 'part:@sanity/base/client'
const apiVersion = `2021-05-19`
const client = sanityClient.withConfig({ apiVersion })
let count = 0;
const ProductRenderer = props => {
const [product, setProduct] = useState({});