Skip to content

Instantly share code, notes, and snippets.

View borodedamie's full-sized avatar
🏠
Working from home

Onaopemipo Oluborode borodedamie

🏠
Working from home
View GitHub Profile
from __future__ import absolute_import, unicode_literals
from celery import shared_task
@shared_task
def add(x, y):
return x + y
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from datetime import timedelta
os.environ.setdefault('DJANGO_SETTINGS_MODULE', '<project name>.settings')
app = Celery('<project name>')
app.config_from_object('django.conf:settings', namespace='CELERY')
python manage.py startapp <app name>
@borodedamie
borodedamie / lamdba_function.py
Created October 30, 2021 07:39
Lambda function for a cleaning service bot
import json
def get_slots(intent_request):
return intent_request['sessionState']['intent']['slots']
def get_slot(intent_request, slotName):
slots = get_slots(intent_request)
if slots is not None and slotName in slots and slots[slotName] is not None:
return slots[slotName]['value']['interpretedValue']
else:
python -m django –version
python manage.py startapp <project-name>
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / 'static']
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
from django.shortcuts import render
from .models import Image
from .forms import ImageForm
from django.http import JsonResponse
import os, shutil
import glob
import cv2
import pytesseract
def index(request):
@borodedamie
borodedamie / main.js
Created October 25, 2021 18:20
Django OCR Project static file
const alertBox = document.getElementById('alert-box')
const imageBox = document.getElementById('image-box')
const imageForm = document.getElementById('image-form')
const confirmBtn = document.getElementById('confirm-btn')
const input = document.getElementById('id_file')
const text = document.getElementById('text')
const csrf = document.getElementsByName('csrfmiddlewaretoken')
input.addEventListener('change', ()=> {
text.innerHTML = `<p>Select the text portion of the image</p>`
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-uWxY/CJNBR+1zjPWmfnSnVxwRheevXITnMqoEIeG1LJrdI0GlVs/9cVSyPYXdcSF" crossorigin="anonymous">