Skip to content

Instantly share code, notes, and snippets.

View cgcardona's full-sized avatar
💭
🤖

Gabriel Cardona cgcardona

💭
🤖
View GitHub Profile
@cgcardona
cgcardona / app.py
Last active September 25, 2023 02:03
Flask app to serve a GET request at "/" which accepts a `?prompt=my creative and expressive stable diffusion prompt`
# all the imports
import io, torch, time, math, os
# import specified modules
from flask import Flask, request, send_file
from torch import autocast
from diffusers import StableDiffusionPipeline
# create a new flask app
app = Flask(__name__)
# all the imports
import torch, time, math, os
# import specified modules
from torch import autocast
from diffusers import StableDiffusionPipeline
# confirm GPU supports the NVIDIA machine learning toolkit
assert torch.cuda.is_available()
# Stable Diffusion v1.4: CompVis/stable-diffusion-v1-4
@cgcardona
cgcardona / exposing-and-forwarding-ec2-port.md
Last active September 18, 2023 22:07
Steps for exposing a port to the Web and port forwarding on EC2

Exposing a port to the Web and port forwarding on EC2

By default a new AWS EC2 instance only exposes port 22 to the Web to enable accessing the new EC2 instance via ssh. Often it's helpful to open other ports to the Web so that you can access them via a browser. This tutorial shows 2 different ways of exposing ports on AWS EC2 instances.

Additionally if you're not interested in exposing a port to the Web but would still like to access it via your browser you can use port forwarding in VS Code which is covered in the final section below.

Exposing a port to the Web on an AWS instance

When launching a new EC2 instance, fill out the following items

@cgcardona
cgcardona / hardhat-config.ts
Created June 28, 2023 17:30
Config file for using Hardhat with Avalanche. More info: https://hardhat.org. https://docs.avax.network.
import { task } from "hardhat/config"
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"
import { BigNumber } from "ethers"
import "@nomiclabs/hardhat-waffle"
// When using the hardhat network, you may choose to fork Fuji or Avalanche Mainnet
// This will allow you to debug contracts using the hardhat network while keeping the current network state
// To enable forking, turn one of these booleans on, and then run your tasks/scripts using ``--network hardhat``
// For more information go to the hardhat guide
// https://hardhat.org/hardhat-network/

$RUN

Slides

https://docs.google.com/presentation/d/1az-hY7Zas2lEQm0jS6laDcoxnJz__FxM0uNd7Gqy5ec/edit?usp=sharing

Introduction

Let's go ahead and get started. My name is Gabriel Cardona and I am a Developer Evangelist from Ava Labs. I'm on the Developer Relations Squad. We are led by the amazing Luigi Demeo and the team now consists of Usman, Martin, Meaghan, Andrea and myself. Our goal is to accelerate the adoption of Avalanche by developers by providing resources needed for devs to go from idea to application and from hobbyist to professional. We are always hiring so check out https://www.avalabs.org/careers to see which opening we have on the DevRel Squad and across all of Ava Labs.

Scale Infinitely via Subnets

What is Avalanche?

Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and decentralized apps.

We accomplish this through the notion of Subnets. Subnets allow anyone anywhere to spin up a taylor-made network w/ custom virtual machines and complex validator rulesets.

Avalanche is a network of networks. It's a platform of platforms where we invision thousands and thousands of public and private Subnets all emerging into this global marketplace which we call The Internet of Finance.

Introduction To Avalanche

Introduction

We're going to go ahead and get started. My name is Gabriel Cardona. I'm Developer Evangelist at Ava Labs. Today's presentation is going to be a high level introduction to the Avalanche Network. We're going to talk about a few of the unique attributes of the Avalanche network which are namely Avalanche Consensus, Subnets and Virtual Machines.

What is Avalanche?

Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and decentralized apps.

How to Launch an Avalanche Subnet

Introduction

We're going to go ahead and get started. My name is Gabriel Cardona. I'm a Developer Evangelist at Ava Labs. Today's presentation is going to be "How to launch an Avalanche Subnet" with a high level introduction to the Avalanche Network followed by demo. We're going to talk about several of the unique attributes of the Avalanche network which are Avalanche Consensus, Network of Networks, Subnets and Virtual Machines and then I'll show how to deploy a local test network for development.

What is Avalanche?

The obvious place to start is what is Avalanche? Avalanche is a global financial network for the issuing and trading of all digital goods. We enable potentially millions of validators to process thousands of transactions per second with near instant finality using a protocol which is completely green and quiescent. We've paired this high throughput and fast finality protocol w/ an architecture that can meet the needs of unique financial services and d

@cgcardona
cgcardona / walkTheDom.js
Last active February 19, 2023 17:46
Recursive function which allows us to go through the tree and visit all the nodes. From Douglas Crockford: An Inconvenient API - The Theory of the DOM @ 27:34 https://youtu.be/Y2Y0U-2qJMs?t=1654
function walkTheDOM(node, callback) {
callback(node)
node = node.firstChild
while (node) {
walkTheDOM(node, callback)
node = node.nextSibling
}
}