Skip to content

Instantly share code, notes, and snippets.

View wong2's full-sized avatar
🍃
Waiting for autumn

wong2 wong2

🍃
Waiting for autumn
View GitHub Profile
@wong2
wong2 / README.md
Last active December 3, 2024 12:19
How to run Claude computer use demo on macOS

Note

It is necessary to give Terminal (or iTerm or whatever you use) the permission to control the computer. This can be done in System Settings ➔ Privacy & Security ➔ Accessibility.

Guide

  • Install cliclick for mouse & keyboard emulation
    • brew install cliclick
  • Clone Anthropic quickstart repo
    • git clone https://github.com/anthropics/anthropic-quickstarts.git
  • cd computer-use-demo
  • Replace computer-use-demo/computer_use_demo/tools/computer.py with the modified version below
from io import BytesIO
import torch
from fastapi.responses import StreamingResponse
from leptonai.photon import Photon
from loguru import logger
class JPEGResponse(StreamingResponse):
media_type = "image/jpeg"
async function* streamAsyncIterable<T = unknown>(stream: ReadableStream<T>) {
const reader = stream.getReader()
try {
while (true) {
const { done, value } = await reader.read()
if (done) {
return
}
yield value
}
import HDWalletProvider from "@truffle/hdwallet-provider";
import { OpenSeaPort, Network } from "opensea-js";
import { PRIVATE_KEY } from "./consts.mjs";
const provider = new HDWalletProvider({
privateKeys: [PRIVATE_KEY],
providerOrUrl: "https://rpc.ankr.com/eth",
});
provider.engine.on("error", (err) => {
@wong2
wong2 / node-canvas-fill-text-max-width.js
Created August 21, 2019 06:12
node canvas auto wrap text by max width
function fillText(ctx, text, x, y, maxWidth, spacing = 0){
const lines = text.split('\n')
let lineHeight = 0
for (const line of lines) {
if (!line) {
y += lineHeight
continue
}
let s = ''
for (const char of line) {
@wong2
wong2 / tantan.py
Created February 18, 2016 16:37
自动like探探上的所有人
#-*-coding:utf-8-*-
import hashlib
import hmac
import time
import requests
HMAC_KEY = '5tT!TQkf5fYbabw5?KL2659XgL^JgxWw8r9Y+bAvGwP-QfteQL'
class TanTan(object):
import { Chain, Common } from "@nomicfoundation/ethereumjs-common";
import { TransactionFactory } from "@nomicfoundation/ethereumjs-tx";
import { VM } from "@nomicfoundation/ethereumjs-vm";
import { ForkBlockchain } from "hardhat/internal/hardhat-network/provider/fork/ForkBlockchain";
import { ForkStateManager } from "hardhat/internal/hardhat-network/provider/fork/ForkStateManager";
import { makeForkClient } from "hardhat/internal/hardhat-network/provider/utils/makeForkClient";
const JSON_RPC_URL = "https://rpc.ankr.com/eth";
async function simulateTx(signedTx: string) {
@wong2
wong2 / SocialRecoveryAccount.sol
Last active August 26, 2022 04:00
Minimum social recovery wallet implementation on zkSync https://vitalik.ca/general/2021/01/11/recovery.html
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@matterlabs/zksync-contracts/l2/system-contracts/interfaces/IAccountAbstraction.sol";
import "@matterlabs/zksync-contracts/l2/system-contracts/TransactionHelper.sol";
import "@matterlabs/zksync-contracts/l2/system-contracts/Constants.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
{
"contracts": {
"@openzeppelin/contracts/access/Ownable.sol": {
"Ownable": {
"storageLayout": {
"storage": [
{
"astId": 7,
"contract": "@openzeppelin/contracts/access/Ownable.sol:Ownable",
"label": "_owner",

How to build MetaMask extension with Snaps enabled

  1. Clone the source code from https://github.com/MetaMask/metamask-extension
  2. Switch to snaps branch
  3. yarn setup
  4. Copy the .metamaskrc.dist file to .metamaskrc and replace the INFURA_PROJECT_ID value with your own.
  5. yarn run build prod --build-type flask
  6. The build should be located at directory dist.