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 openai | |
openai.api_key = "your-api-key" | |
model_engine = "text-davinci-002" | |
n_epochs = 3 | |
batch_size = 4 | |
learning_rate = 1e-5 | |
max_tokens = 1024 |
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
class BinaryTree: | |
def __init__(self, root): | |
self.root = root | |
self.parent = None | |
self.left_node = None | |
self.right_node = None | |
def add_node(self, value): | |
if type(value) is not BinaryTree: | |
raise ValueError("Node must be of instance BinaryTree") |
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
a = list() | |
b = set() | |
c = "some value" | |
print(c in a) # O(n) | |
print(c in b) # O(1) |
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
class Employee(models.Model): | |
bio_short = models.CharField(max_length=256) | |
bio_long = models.TextField() | |
work_experience = JSONSchemaField( | |
schema='schemas/jsonschema.example.json', default=dict, blank=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
{ | |
"title" : "work experience", | |
"type" : "object", | |
"additionalProperties": false, | |
"properties":{ | |
"data": {"type": "array", | |
"items": { | |
"properties" : { | |
"job_title": {"type": "string"}, | |
"speciality": {"type": "string"}, |
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 inspect | |
from jsonschema import ( | |
validate, | |
exceptions as jsonschema_exceptions | |
) | |
from django.core import exceptions | |
from django.contrib.postgres.fields import JSONField |