Skip to content

Instantly share code, notes, and snippets.

@andyhite
andyhite / section.tsx
Last active July 12, 2022 18:39
section
const Section = ({ icon, title, content, onClickTitle }) => ...
const accordionContext = React.createContext();
const Accordion = ({ children }) => {
const [openSections, setOpenSection] = useState([]);
return (
<div>
{children}
@andyhite
andyhite / component.tsx
Last active May 23, 2022 21:29
form-spike.tsx
const Form = ({ onSubmit, ...props }) => {
const formBag = useForm(props);
return (
<form onSubmit={formContext.handleSubmit(onSubmit)}>
<FormProvider value={formBag}>{children}</FormProvider>
</form>
);
};
@andyhite
andyhite / delete-workflow-runs.sh
Created May 19, 2022 14:31
Delete all runs of a specific GitHub Workflow with one command
export GH_PAGER=cat # this is important to keep gh from using less as a pager
export GH_REPO="<org-name>/<repo-name>" # for instance, shipengine/shipengine-elements
export GH_WORKFLOW_FILENAME="<workflow-filename>" # for instance, "lint-and-test.yml"
gh api repos/$GH_REPO/actions/workflows/$GH_WORKFLOW_FILENAME/runs --paginate --jq '.workflow_runs[] | .id' | \
xargs -n 1 -I % gh api repos/$GH_REPO/actions/runs/% -X DELETE
router.get("/orders/:id", (req, res) => {
const { sourceCode } = req.query;
try {
const order = await getOrderById(req.params.id);
res.status(200).json(order);
} catch (err) {
if (axios.isAxiosError(err)) {
if (err.code === 404 && sourceCode) {
await refreshOrderSource(sourceCode);
interface ButtonProps {
children: React.ReactNode;
disabled: boolean;
loading: boolean;
onClick: () => void;
variant?: keyof variants;
}
const variants = {
primary: {
### Keybase proof
I hereby claim:
* I am andyhite on github.
* I am andyhite85 (https://keybase.io/andyhite85) on keybase.
* I have a public key ASD7eF8JaayxoojCLdVDJKYbekmxJsMxj5u9KzNTBQTmvgo
To claim this, I am signing this object:
const DOCUMENT_FORMS = {
"pay_application": PayApplicationForm,
"invoice": InvoiceForm,
...
}
const DocumentViewer = (props) => {
const { document } = props;
const DocumentForm = DOCUMENT_FORMS[document.type];
# Is this preferable...
defmodule Invoice do
...
def execute(%Invoice{id: invoice_id} = invoice, %AddLineItem{} = add) do
# Generate %LineItemAdded and %InvoiceTotalUpdated using Commanded.Aggregate.Multi
# The %InvoiceTotalUpdated event would have the new total on it, calculated based on the
# existing invoice total + the new line item's total
end
0x03f2f0bd08F4918f4c64E5b3D2395c0b819f0219
import React, { Component, PropTypes } from 'react';
import { getStyles } from '../../styles';
import { keypath } from '../../utils';
import CheckBoxInput from '../CheckBoxInput';
import Icon from '../Icon';
const renderValueAtKeypath = (row, { key, renderer }) => {
let value = key ? keypath.get(row, key) : row;
if (renderer) value = renderer.call(null, value, row);