Skip to content

Instantly share code, notes, and snippets.

// via https://github.com/vectorized/solady/blob/main/src/utils/FixedPointMathLib.sol
BigInt.prototype.lnWad = function (): bigint {
let x = this.valueOf();
if (x <= 0n) throw new Error("LN_WAD_UNDEFINED");
let r: bigint = 0n;
// We want to convert `x` from `10**18` fixed point to `2**96` fixed point.
// We do this by multiplying by `2**96 / 10**18`. But since
import math
import openai
import random
import time
import os
import orjson
import polars as pl
from collections import deque
from concurrent.futures import ThreadPoolExecutor
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "solmate/auth/Owned.sol";
import "solmate/utils/SafeCastLib.sol";
import "solmate/utils/ReentrancyGuard.sol";
import "./utils/SignedWadMath.sol";
import "./cars/Car.sol";
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.FunctionReturnDecoder;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.crypto.Credentials;
import org.web3j.crypto.RawTransaction;
import org.web3j.crypto.TransactionEncoder;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.request.Transaction;
import { OpenAI } from "openai-streams";
import { yieldStream } from "yield-stream";
const stream = await OpenAI(
"chat",
{
model: "gpt-3.5-turbo",
n: 2,
temperature: 1,
messages: [{ role: "user", content: "hi" }],
@transmissions11
transmissions11 / repro.py
Created March 2, 2023 18:12
Reproduces a bug in the OpenAI Chat completions API when streaming w/ n>1
import openai
openai.api_key = "[REDACTED]"
responses = {}
for resp in openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Write a hash function in java."}],
n=5,

Keybase proof

I hereby claim:

  • I am transmissions11 on github.
  • I am transmissions11 (https://keybase.io/transmissions11) on keybase.
  • I have a public key whose fingerprint is 5C7B 88CD 9C5F BA41 AFAB E967 4149 A854 A550 484C

To claim this, I am signing this object:

//SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;
library LibString {
function toString(uint256 n) internal pure returns (string memory str) {
if (n == 0) return "0"; // Otherwise it'd output an empty string for 0.
assembly {
let k := 78 // Start with the max length a uint256 string could be.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0;
contract Test {
mapping(uint256 => uint256) public a;
mapping(uint256 => uint256) public b;
function test1() public {
b[0]++;
b[0]--;
@transmissions11
transmissions11 / mulDiv.sol
Last active January 28, 2022 05:46
mulDiv Optimization Challenge
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
assembly {
// Store x * y in z for now.
z := mul(x, y)
// Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))