Skip to content

Instantly share code, notes, and snippets.

View sam-thecoder's full-sized avatar

Samuel M. sam-thecoder

View GitHub Profile
@sam-thecoder
sam-thecoder / company.py
Created December 28, 2019 14:01
Company data
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
@sam-thecoder
sam-thecoder / company_model.py
Created December 28, 2019 13:46
company model
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)
#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
{% 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">
$(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>`;
import asyncio
import websockets
import json
from chatterbot import ChatBot
chatbot = ChatBot(
'Ron Obvious',
trainer='chatterbot.trainers.ChatterBotCorpusTrainer'
)
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
{% 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">
window.onload = function () {
var app = new Vue({
delimiters: ['[[', ']]'],
el: '#app',
data: {
messages: [],
input: '',
send_blank: false,
placeholder: 'Send a message to the chatbot...',
},
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)))