Skip to content

Instantly share code, notes, and snippets.

View vitorcalvi's full-sized avatar
🎯
Focusing

Carlos Vitor Botti Calvi vitorcalvi

🎯
Focusing
View GitHub Profile
@vitorcalvi
vitorcalvi / installonMac.sh
Created October 1, 2024 19:47
ComfyUI Mac Silicon
#!/bin/bash
set -e
# Install dependencies
brew install llvm libomp python@3.11
# Set up LLVM paths
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export CC=$(brew --prefix llvm)/bin/clang
export CXX=$(brew --prefix llvm)/bin/clang++
@vitorcalvi
vitorcalvi / open_close_positions.py
Last active August 14, 2024 17:38
Python Script for Opening and Closing Positions in Alpaca
import time
from alpaca_trade_api.rest import REST
# Set your Alpaca API credentials
ALPACA_API_KEY = 'PK1BN6P47Q9J5GMPJSXY'
ALPACA_SECRET_KEY = 'k1sXSgCkrpWSqQ3wyuKqwMT9H7q3hFLEAiVL0lif'
ALPACA_BASE_URL = 'https://paper-api.alpaca.markets'
# Initialize the Alpaca API
api = REST(ALPACA_API_KEY, ALPACA_SECRET_KEY, base_url=ALPACA_BASE_URL)
import os
import logging
import requests
from alpaca.data.historical.news import NewsClient
from alpaca.data.requests import NewsRequest
from datetime import datetime
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
@vitorcalvi
vitorcalvi / gist:e623ac64ef0c7f49713181848dda5f14
Last active July 15, 2024 14:34
Install Jupyter Notebook on Android Mobile
# Step 1: Install the Termux app
# Download and install the Termux app from Google Play Store or F-Droid
# Step 2: Open Termux and run the following commands
# Update and upgrade existing packages
apt update && apt upgrade -y
# Install necessary packages
apt install clang python fftw libzmq freetype libpng pkg-config libcrypt -y
@vitorcalvi
vitorcalvi / docker-install.md
Created June 20, 2024 07:58 — forked from ebta/docker-install.md
Installing docker (latest version) on Ubuntu 20.04

Installing docker on Ubuntu 20.04 / 22.04

Full reference here: https://docs.docker.com/engine/install/ubuntu/

Setup the repository

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release

Add Docker’s official GPG key:

Shrink code
Requirements:
Combined import statements into a single line where possible.
Removed unnecessary whitespace and comments.
Inlined some logic to reduce the number of lines.
Used list comprehensions and generator expressions to simplify the code.
Shortened variable names where readability was not compromised.
@vitorcalvi
vitorcalvi / create_conda_env.sh
Created June 8, 2024 06:51
Create and activate a Conda environment named after the latest directory in ~/Desktop/webllama, then optionally install packages from requirements.txt
NAME=$(basename "$(ls -td ~/Desktop/webllama/*/ | head -1)") && conda create -n "$NAME" python=3.10 -y && conda activate "$NAME" && read -p "Install packages from requirements.txt? (yes/no): " choice && [[ "$choice" == "yes" ]] && pip install -r requirements.txt
@vitorcalvi
vitorcalvi / convertPytorchGGUF.py
Last active May 30, 2024 14:47
Model Conversion and Upload to Hugging Face Hub
import os
import json
import argparse
from huggingface_hub import snapshot_download, HfApi
# Parse command-line arguments
parser = argparse.ArgumentParser(description="Convert and upload a model to Hugging Face Hub.")
parser.add_argument("--hf_token", type=str, required=True, help="Hugging Face token")
parser.add_argument("--model_id", type=str, required=True, help="Model ID on Hugging Face Hub")
parser.add_argument("--outtype", type=str, required=True, help="Output type for the conversion (e.g., q8_0, f16, f32)")
@vitorcalvi
vitorcalvi / cuda_11.8_installation_on_Ubuntu_22.04
Last active June 12, 2024 16:19 — forked from MihailCosmin/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
# Function to print messages
@vitorcalvi
vitorcalvi / auto_env.bash
Last active May 26, 2024 15:58
env creat
# Version 1
#env_name='mlx-chat-app';
#conda deactivate && conda remove --name "$env_name" --all -y && \
#conda create -n "$env_name" python=3.10 -y && conda activate "$env_name" &&
# pip install tensorflow-macos tensorflow-metal &&
# pip install -r requirements.txt
read -p "Enter the name of the conda environment: " env_name && conda deactivate && conda remove --name "$env_name" --all -y && conda create -n "$env_name" python=3.10 -y && conda activate "$env_name" && pip install -r requirements.txt