Skip to content

Instantly share code, notes, and snippets.

View aweary's full-sized avatar
🌐
doing things and stuff

Brandon Dail aweary

🌐
doing things and stuff
View GitHub Profile
import { z } from "zod";
import { zodToTs, printNode } from "zod-to-ts";
// Replace with your `openai` thing
import { openai } from "../openai.server";
import endent from "endent";
function createJSONCompletion<T extends z.ZodType>({
prompt,
schema_name,
use crate::type_context::{Element, TypeContext};
use ::common::unique_name::UniqueName;
use ::hir::{
hir, BinOp, Binding, Expr, ExprKind, Lit, LitKind, Local, StatementKind,
Type as HIRType, UnOp,
};
use ::hir::visit::{walk_component, walk_function, Visitor};
use data_structures::HashMap;
use diagnostics::ParseResult as Result;
@aweary
aweary / pr.sh
Created January 21, 2021 22:59
#!/bin/bash
set -e
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" = 'master' ]
then
echo You must check out a feature branch first
exit 1
fi
// Option is a simple example of an enum
// that is generic, with a variant that doesn't
// use that generic type. (None)
enum Option<T> {
Some(T),
None,
}
// Two functions that take different types of `Option`s
fn with_option_string(input: Option<string>) {}
function signPage() {
document.querySelectorAll("a[id^=sig]").forEach((node) => {
node.click();
});
setTimeout(() => {
document.querySelector('[data-bb-handler="sign"]').click();
setTimeout(() => {
document.querySelector(".goto_next_page").click();
}, 100);
}, 100);
fn for_expr(&mut self) -> Result<ast::Expr> {
self.expect(TokenKind::Reserved(Keyword::For))?;
let lo = self.span;
let pattern = self.local_pattern()?;
self.expect(TokenKind::Reserved(Keyword::In))?;
let expr = self.expr(Precedence::NONE)?;
let block = self.block()?;
let span = lo.merge(self.span);
Ok(ast::Expr {
id: DUMMY_NODE_ID,
console.groupWithTrace = (name, fn) => {
console.group(name);
fn();
console.groupCollapsed();
console.trace(name);
console.groupEnd();
console.groupEnd();
};
function add(x, y) {
@aweary
aweary / App.js
Last active August 29, 2021 14:06
import React from "react";
import useMutableReducer from "./useMutableReducer";
const reducer = (draft, action, state) => {
switch (action) {
case "increment":
draft.count++;
break;
case "decrement":
draft.count--;

Compound Components

  • Give quick overview of current Navigation usage

  • Pose question "Why are we defining our own API?"

    • Why not just use React's component API?
  • Go over Navigation implementation

  • Point out that the reason we're using our own object API

import React from 'react'
import { createSubscription } from 'create-subscription'
// Create the subscription, which will manage adding and removing the
// event listener for us when the component mounts and unmounts, respectively.
const AddEventListenerSubscription = createSubscription({
getCurrentValue() {
// Since there's no "current value" for an event listener, we just