Skip to content

Instantly share code, notes, and snippets.

View cgood92's full-sized avatar

Clint Goodman cgood92

View GitHub Profile
@cgood92
cgood92 / structured_output_with_reasoning_attribute.ts
Last active April 17, 2025 22:15
Structured output with reasoning attribute
import { ChatPromptTemplate } from '@langchain/core/prompts'
import { AzureChatOpenAI } from '@langchain/openai'
import { z } from 'zod'
import { zodToJsonSchema } from 'zod-to-json-schema'
const azureOpenAi4o = new AzureChatOpenAI({
model: 'gpt-4o',
temperature: 0,
maxRetries: 2,
})
-- Create the table
create table survey_responses (
customer_id varchar(30),
timely_responses int,
timely_fixes int,
timely_replacement int,
reliability int,
"options" int,
respectful int,
courteous int,
// useMeasureElementWidth.js
import { useEffect, useState } from 'react'
export default function useMeasureElementWidth() {
const [width, setWidth] = useState()
useEffect(() => {
setWidth(document.body.offsetWidth)
}, [])
// app.js
import React from 'react'
import { Router, Route } from 'react-router-dom'
import { createHashHistory } from 'history'
// How would you "mock" this in a way that could be changed on a test-basis?
const history = createHashHistory()
export default function App() {
return (
@cgood92
cgood92 / creative-mocking-example1.js
Last active February 3, 2022 13:49
Creative mocking example #1
// constants.js
export const IS_FIREFOX = true
// fixAspectRatio.js
import { IS_FIREFOX } from './constants'
export default function fixAspectRatio(img) {
if (IS_FIREFOX) {
img.width = 10
}
@cgood92
cgood92 / getDomInfo.js
Last active September 15, 2021 15:27
Get info on a dom element in string format to compare
let totalResult = []
function getInfo(element, depth){
const id = getIdentifier(element)
const styles = getStyles(element)
const listeners = getListeners(element)
const result = {
id, styles, listeners, depth
}
@cgood92
cgood92 / gist:42171b571d1646f689d778249ff8b161
Created February 9, 2021 18:18
Change React component with props to object
export default function (babel) {
const { types: t } = babel;
return {
name: "ast-transform", // not required
visitor: {
JSXElement(path) {
const { openingElement } = path.node
const name = getReactComponentName(path.node);
if (name === "Route" || name === "PageRoute") {
class Person {
constructor(...traits) { traits.forEach(trait => this[trait] = true) }
}
const storyBegins = "7/18/17"
const laura = new Person("smart", "kind", "caring")
const clint = new Person("hard working", "attentive", "fast")
const activities = ["frisbee", "institute"]
import { useRef } from 'react'
const useIsInitialValue = watchedValue => {
const initialValue = useRef(watchedValue)
const cache = useRef(null)
if (cache.current != null) {
return cache.current
}