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,
/** @license React v16.0.0
* react-dom.production.min.js
*
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
(function (global, factory) {
@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--;
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,

Preact for Electrode

This document outlines the results of an attempt to get Preact working with the Electrode platform. Getting this to work required two minor adjustments to the client archetype and server:

Client

To get Preact working with the client bundle all I had to do was alias react and react-dom to preact-compat

console.groupWithTrace = (name, fn) => {
console.group(name);
fn();
console.groupCollapsed();
console.trace(name);
console.groupEnd();
console.groupEnd();
};
function add(x, y) {