Skip to content

Instantly share code, notes, and snippets.

View programbo's full-sized avatar

John Lombardo programbo

View GitHub Profile
@programbo
programbo / GetJournalArticlesQuery.ts
Created September 27, 2022 14:57
GetJournalArticlesQuery
type GetJournalArticlesQuery = {
__typename?: "Query" | undefined
entries: Array<
| {
__typename?: "test_default_Entry"
slug: string
title: string
uri: string
postDate: any
}
@programbo
programbo / ChartWithChildren.tsx
Created December 14, 2021 07:59
Configured with data vs Composition with children
import { MultidimensionalChart as Chart } from './components/MultidimensionalChart'
export default function ChartWithChildren() {
return (
<div className="text-sky-900">
<div className="container px-6 pt-10 pb-24 mx-auto">
<div className="flex flex-col w-full max-w-xl mx-auto divide-y space-y-14">
<Chart className="pt-10" showLabels showValues>
<Chart.Bar label="Albany Hospital">
<Chart.BarSegment label="Albany Hospital mnisplaced 52 patients" value={52} color="#009FAE" />
@programbo
programbo / Copilot suggestions
Created October 27, 2021 12:33
Based on a file called CallRecorder.machine.ts
Synthesizing 10/10 solutions
=======
const CallRecorder = Machine({
id: "callRecorder",
initial: "idle",
states: {
idle: {
on: {
@programbo
programbo / questions.ts
Created November 12, 2020 05:29
Energy Profiler questions
interface FutureScore {
efficiencies: number
growth: number
sustainability: number
}
export interface Answer {
label: string
score: number
future?: FutureScore
@programbo
programbo / machine.js
Last active June 17, 2020 03:36
Generated by XState Viz: https://xstate.js.org/viz
const setAnswer = (key, fallback) => (context, { value = fallback }) => {
let answerField = context[key];
if (Array.isArray(answerField) && typeof value === 'string') {
const index = answerField.indexOf(value);
if (index > -1) {
answerField.splice(index, 1);
}
else {
answerField.push(value);
<?php
use SilverStripe\ORM\DataExtension;
class DocumentExtension extends DataExtension
{
private static $db = [
'Description' => 'HTMLText',
];
}
<?php
namespace WAIRC;
use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\Forms\TabSet;
use SilverStripe\Forms\TreeMultiselectField;
# Let's React!
## Phase 1 - Like this, do that
1. Make a new directory - `mkdir lets-react`
1. Open this directory in VS Code
1. Open a new terminal in VS Code
1. Initialise a new project:
```
npm init -y
@programbo
programbo / custom-type.ts
Last active November 22, 2018 13:30
Firestore timestamp to JS timestamp
import { types } from 'mobx-state-tree'
interface ITimestamp {
nanoseconds: number
seconds: number
}
export const FirestoreTimestamp = types.custom<number, ITimestamp>({
name: 'Timestamp',
fromSnapshot(value: number) {
import Head from 'next/head'
import React from 'react'
import SbEditable from 'storyblok-react'
import { colors, Theme } from '../../styles'
import Kats from '../Icons/Kats'
import { DetailsContent } from './Details'
interface MapContent {
api_key: string
map_style: string