Amir Orfi

All generations.

code to explanationMon, 16 Jan 2023

class AliasPluginModel(CMSPlugin): cmsplugin_ptr = models.OneToOneField( CMSPlugin, on_delete=models.CASCADE, related_name='cms_aliasplugin', parent_link=True, ) plugin = models.ForeignKey( CMSPlugin, on_delete=models.CASCADE, editable=False, related_name='alias_reference', null=True, ) alias_placeholder = models.ForeignKey( Placeholder, on_delete=models.CASCADE, editable=False, related_name='alias_placeholder', null=True, ) class Meta: app_label = 'cms

The AliasPluginModel is a subclass of CMSPlugin and it has a one-to-one relation with CMSPlugin. It also has a foreign key relation with CMSPlugin and a foreign key relation with Placeholder.

generate functionMon, 16 Jan 2023

Trad Google mail Andy sabe it ton Google sheet

def sendToGSheet(subject, content): import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'] credentials = ServiceAccountCredentials.from_json_keyfile_name('/content/gspread-275812-baf8a05c34ab.json', scope) gc = gspread.authorize(credentials) wks = gc.open("GoogleMail").sheet1 wks.append_row([subject, content])

Python
View
generate functionMon, 16 Jan 2023

Webhook messanger

def webhook_messenger(name, message): return "You have a new message from {}. {}".format(name, message) webhook_messenger("John", "Hello")

Python
View
generate functionMon, 16 Jan 2023

Webhook server for Facebook messanger

import json from flask import Flask, request from pymessenger.bot import Bot app = Flask(__name__) ACCESS_TOKEN = 'ACCESS_TOKEN' VERIFY_TOKEN = 'VERIFY_TOKEN' bot = Bot(ACCESS_TOKEN) def verify_fb_token(token_sent): #take token sent by facebook and verify it matches the verify token you sent #if they match, allow the request, else return an error if token_sent == VERIFY_TOKEN: return request.args.get("hub.challenge") return 'Invalid verification token' #chooses a random message to send to the user def get_message(): sample_responses = ["You are stunning!", "We're proud of you.", "Keep on being you!", "We're greatful to know you :)"] # return selected item to the user return random.choice(sample_responses) #uses PyMessenger to send response to user def send_message(recipient_id

Python
View

Questions about programming?Chat with your personal AI assistant