Skip to content

Instantly share code, notes, and snippets.

@dgca
dgca / exploring-zero-knowledge-proofs-for-verifying-function-outputs-in-java-script.md
Last active April 20, 2023 06:56
Exploring Zero-Knowledge Proofs for Verifying Function Outputs in JavaScript

ChatGPT Convo: Exploring Zero-Knowledge Proofs for Verifying Function Outputs in JavaScript

@me:

The following is a question about whether or not it is possible to do something in Javascript. If it is possible please explain how one could achieve this:

Say I have a pure function that takes some input, does some synchronous computation, and produces an output. Is it possible to verify that a potential result was the result of that function without running the function myself?


@dgca
dgca / copy-chatgpt-logs.md
Last active March 26, 2023 21:41
Bookmarklet: Copy ChatGPT Logs to Clipboard

Bookmarklet: Copy ChatGPT Logs to Clipboard

How to install:

  1. Copy the following code:
javascript:(function()%7Bfunction%20getChatRoot(current%20%3D%20document.querySelector(%22main%22))%20%7B%0A%20%20if%20(current.firstChild.nodeType%20%3D%3D%3D%201)%20%7B%0A%20%20%20%20return%20getChatRoot(current.firstChild)%3B%0A%20%20%7D%0A%20%20return%20current.parentElement%3B%0A%7D%0A%0Aconst%20chatRoot%20%3D%20getChatRoot()%3B%0A%0Aconst%20logs%20%3D%20%5B...chatRoot.children%5D%0A%20%20.map((node%2C%20i)%20%3D%3E%20%7B%0A%20%20%20%20if%20(!node.innerText)%20%7B%0A%20%20%20%20%20%20return%20%22%22%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20(i%20%3D%3D%3D%200)%20%7B%0A%20%20%20%20%20%20return%20node.innerText%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20(i%20%25%202%20%3D%3D%3D%201)%20%7B%0A%20%20%20%20%20%20return%20%22**Me%3A**%5Cn%5Cn%22%20%2B%20node.innerText%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20%22**ChatGPT%3A**%5Cn%5Cn%22%20%2B%20node.innerText%3B%0A%20%20%7D)%0A%20%20.join(%22%5Cn%5Cn---%5Cn%5Cn%22)

ChatGPT prompt behavior generator

I want you to act as an OpenAI ChatGPT prompt behavior generator. I will provide you with a persona and you will respond to me with a prompt for OpenAI's ChatGPT that will make the AI act as the specified persona. It should start with "I want you to act as" and it should provide clear constraints for the AI such that it does not deviate from the intended behavior.

Product description generator

I'm working on a new product and I'm having a hard time explaining what it is. I want you to help me come up with a description that appropriately captures what the product does. I'll start by giving you an initial description of the product. I want you to respond with two things:

  1. How much you think you understand the product as a percentage
  2. Any questions you can think of that would help us write a better description
@dgca
dgca / same-value-different-variable.md
Created July 7, 2021 18:39
Different ways of assigning the same value to different variable declarations

Different ways of assigning the same value to different variable declarations

Assignment waterfall

const x = y = z = Symbol('hi');

console.log(x === y && y === z);
@dgca
dgca / useDispatchMethods.js
Last active August 12, 2022 19:17
Abstraction over `useReducer` to make writing reducer functions easier and without switch statements.
/**
* Abstraction over `useReducer` to make writing reducer functions easier and without
* switch statements.
*
* @see https://codesandbox.io/s/usedispatchmethods-wwkcw?file=/src/App.js
* @example
*
* const Thinger = () => {
* const [state, dispatch] = useDispatchMethods(
* {
@dgca
dgca / styled-components-breakpoint-utils.js
Last active July 10, 2020 17:34
Utility functions to facilitate writing media queries in Styled Components
/**
* @example
* import styled from "styled-components";
* import {bp, atAndBelow} from '../path/to/styled-components-breakpoint-utils';
*
* const Text = styled.p`
* font-size: 20px;
*
* ${atAndBelow(bp.s, (css) => css`
* font-size: 18px;