This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const today = new Date(); | |
const yyyy = today.getFullYear(); | |
let mm = today.getMonth() + 1; // Months start at 0! | |
let dd = today.getDate(); | |
var todayy = new Date(); | |
if (dd < 10) dd = '0' + dd; | |
if (mm < 10) mm = '0' + mm; | |
const formattedToday = mm + '/' + dddd + '/' + yyyy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import './App.css'; | |
import SimpleContract from './abi/SimpleContract.json'; | |
const ganache = require('ganache'); | |
const Web3 = require('web3'); | |
const options = {} | |
const provider = ganache.provider(options); | |
const web3 = new Web3('http://127.0.0.1:8545'); | |
const CONTRACT_ADDRESS = 'YOUR_CONTRACT_ADDRESS' | |
const USER_ADDRESS = web3.utils.toChecksumAddress('YOUR_ACCOUNT_ADDRESS'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.13; | |
import '@ganache/console.log/console.sol'; | |
contract SimpleContract { | |
constructor() { | |
console.log('\n\n#################################################\n' | |
'#### Now Deploying Contract ####\n' | |
'#################################################' | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConnectWallet = async (type) => | |
{ | |
var web3; | |
try { | |
// Get network provider and web3 instance. | |
if (type == 0) | |
web3 = await getWeb3(); | |
else | |
web3 = await getWalletConnect(); | |
} catch (error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Web3 from "web3"; | |
import WalletConnectProvider from "@walletconnect/web3-provider"; | |
const getWalletConnect = async () => | |
{ | |
const provider = new WalletConnectProvider({ | |
rpc: { 137: "https://polygon-rpc.com/" }, | |
}); | |
// Enable session (triggers QR Code modal) | |
await provider.enable(); | |
const web3 = new Web3(provider); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getWeb3 = () => | |
new Promise((resolve, reject) => { | |
// Wait for loading completion to avoid race conditions | |
window.addEventListener("load", async () => { | |
// Modern dapp browsers... | |
if (window.ethereum) { | |
const web3 = new Web3(window.ethereum); | |
try { | |
// Request account access if needed | |
await window.ethereum.enable(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router } from 'itty-router' | |
const router = Router() | |
// Define a simple data set for our API | |
const animals = [ | |
{ | |
name: 'cow', | |
id: 1, | |
type: 'mammal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Env { | |
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/ | |
// MY_KV_NAMESPACE: KVNamespace; | |
// | |
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/ | |
// MY_DURABLE_OBJECT: DurableObjectNamespace; | |
// | |
// Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/ | |
// MY_BUCKET: R2Bucket; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s3 = boto3.resource('s3') | |
from PIL import Image | |
import io | |
BUCKET_NAME = "YOUR_BUCKET_NAME" | |
FOLDER = "YOUR_BUCKET_PREFIX_NAME/" | |
%%time | |
import json | |
content_type = "application/json" | |
request_body = {"prompt": "a photo of a dog running in a field of flowers.","num_inference_steps":75} | |
#Serialize data for endpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
endpoint_config_name = 'tti-config' + strftime("%Y-%m-%d-%H-%M-%S", gmtime()) | |
print('Endpoint config name: ' + endpoint_config_name) | |
instance_type = 'ml.g4dn.2xlarge' | |
create_endpoint_config_response = sm_client.create_endpoint_config( | |
EndpointConfigName = endpoint_config_name, | |
ProductionVariants=[{ | |
'InstanceType': instance_type, | |
'InitialInstanceCount': 1, | |
'InitialVariantWeight': 1, | |
'ModelName': model_name, |