This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from company.models import Company | |
from django.http import HttpResponse | |
from django.views.decorators.csrf import csrf_exempt | |
from django.db.models import Q | |
from django.core.paginator import Paginator | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import User | |
from location.models import Address | |
class Company(models.Model): | |
name = models.CharField(max_length=500) | |
phone = models.CharField(max_length=500) | |
email = models.EmailField(unique=True) | |
address = models.ForeignKey(Address, related_name="companies", on_delete=models.CASCADE, null=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#inside template tag called app_tags.py | |
@register.filter | |
def image_dimensions(dimensions, ratio): | |
print(dimensions) | |
width, height = dimensions | |
if 'x' in ratio: | |
return ratio | |
x,y = ratio.split(":") | |
x,y = int(x),int(y) | |
ratio = x/y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block js %} | |
<script type="text/javascript" src="/static/js/script.js"></script> | |
{% endblock %} | |
{% block content %} | |
<div id="app" class="container top-padding"> | |
<div class="row"> | |
<div class="col-md-12 messages"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
function get_response() { | |
var value = $('.text').val(); | |
if (value.length > 0) { | |
$('.no-message').addClass('hidden'); | |
$('.text').val(''); | |
var html_string = `<div class="card col-md-6 user-message"><div class="card-body">${value}</div></div>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import websockets | |
import json | |
from chatterbot import ChatBot | |
chatbot = ChatBot( | |
'Ron Obvious', | |
trainer='chatterbot.trainers.ChatterBotCorpusTrainer' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render, render_to_response | |
from django.http import HttpResponse | |
import json | |
from django.views.decorators.csrf import csrf_exempt | |
from chatterbot import ChatBot | |
chatbot = ChatBot( | |
'Ron Obvious', | |
trainer='chatterbot.trainers.ChatterBotCorpusTrainer' | |
) | |
# Train based on the english corpus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block js %} | |
<script type="text/javascript" src="/static/js/script.js"></script> | |
{% endblock %} | |
{% block content %} | |
<div id="app" class="container top-padding"> | |
<div class="row"> | |
<div class="col-md-12"> | |
<div class="card col-md-6" v-for="message in messages" v-bind:class="{ 'user-message': message.user, 'chat-message': message.chat_bot, 'offset-md-6': message.chat_bot}"> | |
<div class="card-body"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function () { | |
var app = new Vue({ | |
delimiters: ['[[', ']]'], | |
el: '#app', | |
data: { | |
messages: [], | |
input: '', | |
send_blank: false, | |
placeholder: 'Send a message to the chatbot...', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_hsv_positions(image, positions): | |
#hsv comes in hue (color of image), saturation and value that's supposed to be how light or dark the color is | |
image = image.filter(ImageFilter.BLUR) | |
hsv_image = image.convert('HSV') | |
values = [] | |
for pixel in positions: | |
values.append(hsv_image.getpixel(tuple(pixel))) |
NewerOlder