Skip to content

Instantly share code, notes, and snippets.

View kay-is's full-sized avatar
🚮
!!

K kay-is

🚮
!!
View GitHub Profile
@kay-is
kay-is / litprotocol.ts
Created December 7, 2023 10:55
Minting Lit PKP via Relayer and WebAuthn
import { ProviderType } from "@lit-protocol/constants"
import { LitAuthClient, WebAuthnProvider } from "@lit-protocol/lit-auth-client"
const litAuthClient = new LitAuthClient({
litRelayConfig: { relayApiKey: LIT_API_KEY },
})
const provider = litAuthClient.initProvider<WebAuthnProvider>(
ProviderType.WebAuthn
)
@kay-is
kay-is / cache.js
Created November 22, 2023 10:53
MEM Carbon Testnet With Upstash Redis
import { guidGenerator } from "./mem-utils.js"
import { MEM_TESTNET_URL } from "./constants.js"
import axios from "axios"
import { Redis } from "@upstash/redis"
const redisClient = new Redis({
url: process.env.UPSTASH_REDIS_REST_URL,
token: process.env.UPSTASH_REDIS_REST_TOKEN,
})
@kay-is
kay-is / index.html
Created December 15, 2022 15:49
Using Lit Protocol with Web3Auth
<!DOCTYPE html>
<title>Using Lit Protocol with Web3Auth</title>
<script src="https://unpkg.com/@web3auth/modal@3.3.0/dist/modal.umd.min.js"></script>
<script src="https://unpkg.com/@web3auth/base@3.3.0/dist/base.umd.min.js"></script>
<script src="https://unpkg.com/ethers@5.7.2/dist/ethers.umd.js"></script>
<script src="https://jscdn.litgateway.com/index.web.js"></script>
<button id="encryptButton">Encrypt</button>
@kay-is
kay-is / controls.ts
Created August 31, 2022 14:42
Simple Keyboard and Touch Controls for Phaser Games
export class Controls {
public up = false
public down = false
public left = false
public right = false
public action = false
constructor(scene: Phaser.Scene) {
if (touchscreenAvailable()) this.initializeTouchscreen(scene)
else this.initializeKeyboard(scene)
// Save one string
let string = "a";
// A string can be written directly into localStorage
localStorage.setItem("myKey", string);
string = localStorage.getItem("myKey");
console.log("String data for myKey:", string);
localStorage.removeItem("myKey");
// Save multiple strings
// Save one string
let string = "a";
// A string can be written directly into localStorage
localStorage.setItem("myKey", string);
string = localStorage.getItem("myKey");
console.log("String data for myKey:", string);
localStorage.removeItem("myKey");
// Save multiple strings
{
"facebooklogin": true,
"fname": "Mark",
"email": "lofqazwczg_1571920845@tfbnw.net",
"facebookid": "101937261244556",
"facebookaccesstoken": "EAAB3KhOVpAIBAKHoP6yqIhGRTnpkjXgaUeeSFXIiMrxT39u5yombL8QIHMqKmKcJ1keM7hYmIJ5V42dbz0O8L1LZCAtB14Vj02XOXkUOEHZA9j6ZCTLz4dTKz4gybkeVgI57f1M2rBS0GDZCjMUNM1xISvOZA2783FhwiVNel6GvuZAz0hkSabFZAHQX62c7mYgqRP7jT1dZB3S91KnXh8JIUBJQApBYjdzEhfkZCiHBTH1Yas7y5t0AE9cboirw1J3kZD",
"facebookavatar": "https://graph.facebook.com/101937261244556/picture?type=large"
}
function useFetch(input, init, useEffectInputs) {
const [error, setError] = useState(null);
const [response, setResponse] = useState(null);
const abortController = useRef();
useEffect(() => {
abortController.current = new AbortController();
fetch(input, { ...init, signal: abortController.current.signal })