Skip to content

Instantly share code, notes, and snippets.

View skolo-online's full-sized avatar

Skolo Online Learning skolo-online

View GitHub Profile
@skolo-online
skolo-online / search.py
Created January 8, 2022 22:41
Twitter API V2 search
import tweepy
import config
import json
def getClient():
client = tweepy.Client(bearer_token=config.BEARER_TOKEN,
consumer_key=config.API_KEY,
consumer_secret=config.API_KEY_SECRET,
access_token=config.ACCESS_TOKEN,
@skolo-online
skolo-online / index.html
Created December 28, 2021 12:23
AI Blog Writing Tool - HTML
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Skolo</title>
<!-- Bootstrap CSS -->
@skolo-online
skolo-online / app.py
Created December 28, 2021 12:21
Flask application - AI Blog Writing Tool
from flask import Flask, render_template, request
import config
import blog
def page_not_found(e):
return render_template('404.html'), 404
app = Flask(__name__)
@skolo-online
skolo-online / blog.py
Created December 28, 2021 12:16
AI Blog Generator Tool
import os
import openai
import config
openai.api_key = config.OPENAI_API_KEY
def generateBlogTopics(prompt1):
response = openai.Completion.create(
@skolo-online
skolo-online / image_detailed_view.py
Created October 20, 2021 07:51
Image Detailed View Page
def imageDetailPage(request, slug1, slug2):
category = Category.objects.get(slug=slug1)
image = Image.objects.get(slug=slug2)
context = {}
context['category'] = category
context['image'] = image
return render(request, 'main/image.html', context)
@skolo-online
skolo-online / image_category_view.py
Created October 20, 2021 07:35
Image Category View
def categoryPage(request, slug):
category = Category.objects.get(slug=slug)
images = Image.objects.filter(category=category).order_by('-date_created')[:6]
for x in images:
x.shortDescription = x.description[:130]
context = {}
context['images'] = images
context['category'] = category
@skolo-online
skolo-online / image_models.py
Created October 20, 2021 07:27
Model File for Image Gallery Website
from django.db import models
from django.template.defaultfilters import slugify
from django_resized import ResizedImageField
from django.utils import timezone
from uuid import uuid4
from django.urls import reverse
class Category(models.Model):
@skolo-online
skolo-online / viewsxxx.py
Created August 22, 2021 09:47
Create a PDF and Email to Client
#Dont forget the view imports
def emailDocumentInvoice(request, slug):
#fetch that invoice
try:
invoice = Invoice.objects.get(slug=slug)
pass
except:
messages.error(request, 'Something went wrong')
return redirect('invoices')
@skolo-online
skolo-online / formsx.py
Created August 22, 2021 09:37
Forms - Extend init function with crispy forms layouts
from django import forms
from django.forms import widgets
from .models import *
#Form Layout from Crispy Forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, Row, Column
class DateInput(forms.DateInput):
@skolo-online
skolo-online / viewsxx.py
Created August 22, 2021 09:20
create invoice part 2 view
@login_required
def createBuildInvoice(request, slug):
#fetch that invoice
try:
invoice = Invoice.objects.get(slug=slug)
pass
except:
messages.error(request, 'Something went wrong')
return redirect('invoices')