Skip to content

Instantly share code, notes, and snippets.

View codingforentrepreneurs's full-sized avatar
🔥

Coding For Entrepreneurs codingforentrepreneurs

🔥
View GitHub Profile
@codingforentrepreneurs
codingforentrepreneurs / a-youtube-oauth-django-sample.md
Created September 12, 2024 19:49
YouTube OAuth Workflow for Basic API Calls for Django Views

YouTube OAuth Workflow for Basic API Calls

Claude says:

This code handles YouTube OAuth2 authentication in a Django application. Here's what's happening: The youtube_connect function initiates the OAuth2 flow. It creates a Flow object with the necessary client configuration, scopes, and redirect URI. It then generates an authorization URL and redirects the user to Google's authentication page. The youtube_callback function handles the callback after user authentication. It retrieves the authorization code from the query parameters, creates another Flow object, and attempts to exchange the code for an access token. If successful, it fetches the user's email and channel ID using the token. The function returns an HTTP response indicating success or failure of the authentication process. Both functions use environment variables for client credentials and implement security measures like HTTPS enforcement and state verification. The code also includes error handling and logging for debugging purposes.

@codingforentrepreneurs
codingforentrepreneurs / kafka-install-gist.sh
Last active April 16, 2024 21:02
Kafka Installation Bootstrap Script to run on ubuntu machines for the Coding with Kafka Course
#!/bin/bash
# Public gist available at:
# https://gist.github.com/codingforentrepreneurs/aef0968829883110e24b107f7278255f
# Check if an argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 new_hostname"
exit 1
fi
@codingforentrepreneurs
codingforentrepreneurs / django-celery-redis.md
Last active March 4, 2024 19:18
How to run a sample Django x Celery project

The Django Celery Redis github repo shows a full Django project leveraging the results of this blog post tutorial and this sample project.

git clone https://github.com/codingforentrepreneurs/Django-Celery-Redis
cd Django-Celery-Redis

macos/linux

python3 -m venv venv
@codingforentrepreneurs
codingforentrepreneurs / first-python-rest-api-tutorial.md
Last active February 28, 2024 22:45
Your First Python Rest API App. Learn Python Web Development Basics

Your First Python Rest API App

Python and many ways to create a Rest API endpoint. This one uses FastAP which is designed to easily create API endpoints for nearly anything.

REST APIs are here so software can talk to other software. REST APIs typically send JSON data types (instead of HTML like websites do for humans)

Step 1: Setup

Create virtual environment, activate it, and install FastAPI and Uvicorn:

@codingforentrepreneurs
codingforentrepreneurs / 00-pandas-to-sql.md
Last active February 27, 2024 18:22
Export Pandas Dataframe to a PostgreSQL Database Table

Export Pandas Dataframe to a PostgreSQL Database Table

Export your Pandas analysis really easily to a PostgresSQL database table with this tutorial. We used Docker Compose to create the postgres database with docker compose up and the related compose.yaml file.

Step 1 - Install Requirements

Add requirements.txt from below.

python3 -m pip install -r requirements.txt
@codingforentrepreneurs
codingforentrepreneurs / ollama-llama2-openai-dropin-replacement.md
Created February 27, 2024 17:23
Ollama and Llama 2 as Drop-in Replacement for OpenAI with Python

Ollama Enables Open Source AI LLM Models

Step 1: Download Ollama

Visit https://ollama.com to download for your system.

Step 2: Download an AI Model like Llama 2

In the ollama library we see all kinds of available models. We'll use Llama 2 and we have a few options:

@codingforentrepreneurs
codingforentrepreneurs / Redis-with-Docker-Compose-short.md
Created February 26, 2024 23:01
How I use Redis for new projects with Docker Compose

compose.yaml

version: '3.9'
services:
    redis:
        image: redis
        restart: always
        ports:
 - 6178:6379
@codingforentrepreneurs
codingforentrepreneurs / Postgres-with-docker-compose-short.md
Last active February 29, 2024 05:08
How I use Postgres for Each new project with Docker Compose
version: '3.9'
services:
  db:
    image: postgres
    restart: always
    ports:
        - 5430:5432
 volumes:
@codingforentrepreneurs
codingforentrepreneurs / Extract Endpoint from Serverless Framework.md
Created January 26, 2024 17:52
Extract Endpoint from Serverless Framework

Extract Endpoint from Serverless Framework

The serverless framework lacks native support for outputting the endpoint url for a deployment:

serverless info --stage prod --region us-east-2

Outputs

DOTENV: Loading environment variables from .env, .env.prod:
@codingforentrepreneurs
codingforentrepreneurs / Serverless Framework IAM Policy.md
Last active July 14, 2024 13:32
IAM Policy for Serverless Node.js API on AWS Lambda

Serverless Framework IAM Policy

Use this IAM policy for the Serverless Framework with the AWS Provider for deploying Node.js apps as serverless functions on AWS Lambda.

Replace AWS_ID with your AWS Account ID (e.g. 123456789) which you can find under AWS IAM in the console.