This file contains hidden or 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 Book::GenreAutomation | |
| attr_accessor :book | |
| def initialize(book_id) | |
| self.book = Book.find(book_id) | |
| end | |
| def run | |
| genres_array = fetch_genres_from_openai |
This file contains hidden or 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 run | |
| genres_array = fetch_genres_from_openai | |
| return if genres_array.blank? | |
| book.genres.clear | |
| genres_array.each do |genre_name| | |
| genre = Genre.find_by(name: genre_name) |
This file contains hidden or 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
| client = OpenAI::Client.new | |
| response = client.chat( | |
| parameters: { | |
| model: 'gpt-4o', # Required. | |
| response_format: { type: 'json_object' }, | |
| messages: [{ role: 'user', content: content }], # Required. | |
| temperature: 0.7 | |
| } | |
| ) |
This file contains hidden or 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 Book::GenreAutomation | |
| attr_accessor :book | |
| def initialize(book_id) | |
| self.book = Book.find(book_id) | |
| end | |
| end |
This file contains hidden or 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
| OpenAI.configure do |config| | |
| config.access_token = 'YOUR_ACCESS_TOKEN' | |
| config.organization_id = 'YOUR_ORGANIZATION_ID' | |
| config.log_errors = Rails.env.development? | |
| end |
This file contains hidden or 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
| const getComments = () => { | |
| return onSnapshot(collection(db, 'comments'), (value) => { | |
| const comments = value.docs.reduce((acc, item) => { | |
| if (id.id === item.data().coinId) { | |
| acc.push({ ...item.data(), id: item.id }) | |
| } | |
| return acc; | |
| }, []) | |
| setComments(comments); | |
| }); |
This file contains hidden or 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
| const FONT_FACES = `@font-face { | |
| font-display: auto; | |
| font-family: "Elections-Publico"; | |
| font-style: normal; | |
| font-weight: 800; | |
| src: url("https://some-url.com/fonts/Publico-Bold.woff") format("woff"); | |
| } | |
| @font-face { | |
| font-display: auto; | |
| font-family: "Elections-Akkurat-Mono"; |
This file contains hidden or 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 CandidateImage extends HTMLElement { | |
| connectedCallback() { | |
| this.shadow = this.attachShadow({ mode: 'open' }); | |
| this.setupImage(); | |
| this.addWinnerText(); | |
| // Add our styles | |
| this.createStyles(); | |
| } | |
This file contains hidden or 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 CandidateImage extends HTMLElement { | |
| connectedCallback() { | |
| this.shadow = this.attachShadow({ mode: 'open' }); | |
| // Create an image | |
| const image = new Image(); | |
| // Find the right image for the provided name | |
| if (this.getAttribute('name') === 'pete') { | |
| image.src = 'https://cdn-candidates.com/pete.jpg'; |
This file contains hidden or 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 CandidateImage extends HTMLElement { | |
| connectedCallback() { | |
| this.shadow = this.attachShadow({ mode: 'open' }); | |
| // Create an image | |
| const image = new Image(); | |
| // Find the right image for the provided name | |
| if (this.getAttribute('name') === 'pete') { | |
| image.src = 'https://cdn-candidates.com/pete.jpg'; |
NewerOlder