Skip to content

Instantly share code, notes, and snippets.

View codingforentrepreneurs's full-sized avatar
🔥

Coding For Entrepreneurs codingforentrepreneurs

🔥
View GitHub Profile
@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 March 15, 2024 03:31
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.

@codingforentrepreneurs
codingforentrepreneurs / nextjs-pbkdf2.js
Created July 18, 2023 16:02
A custom crypto pbkdf2 method for Next.js
/*
Next.js/Edge function method for hasing passwords
Using the Web API Crypto feature instead of
Built-in Node.js Crypto
*/
export default async function pbkdf2(password, salt, iterations, keylen) {
const enc = new TextEncoder();
const passwordBuffer = enc.encode(password);
const saltBuffer = enc.encode(salt);