Skip to content

Instantly share code, notes, and snippets.

View BetterProgramming's full-sized avatar

BetterProgramming

View GitHub Profile
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;
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');
// 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'
'#################################################'
);
}
ConnectWallet = async (type) =>
{
var web3;
try {
// Get network provider and web3 instance.
if (type == 0)
web3 = await getWeb3();
else
web3 = await getWalletConnect();
} catch (error) {
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);
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();
import { Router } from 'itty-router'
const router = Router()
// Define a simple data set for our API
const animals = [
{
name: 'cow',
id: 1,
type: 'mammal'
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;
}
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
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,