openai_101 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/_.rb +1 -0
- data/.builders/boot.rb +39 -0
- data/.builders/generators/01-bootstrap.rb +135 -0
- data/.releaserc.json +1 -1
- data/.rubocop.yml +7 -24
- data/.tool-versions +1 -1
- data/CHANGELOG.md +11 -11
- data/README.md +41 -65
- data/lib/openai_101/version.rb +1 -1
- data/lib/openai_101.rb +0 -11
- data/package-lock.json +2225 -1386
- data/package.json +2 -5
- metadata +11 -89
- data/bin/automate-chatgpt.js +0 -60
- data/bin/automate-midjourney.js +0 -75
- data/bin/convert_webp_to_png.rb +0 -86
- data/bin/gpt_context_gatherer.rb +0 -63
- data/course/course.md +0 -64
- data/course/images/beautiful-llm-models.png +0 -0
- data/course/images/prompts/beautiful-llm-models.txt +0 -1
- data/course/images/prompts/series-2-appydave-gpt-summit.txt +0 -1
- data/course/images/series-2-appydave-gpt-summit.png +0 -0
- data/gpt-context/openai-documentation.md +0 -498
- data/gpt-context/ruby-openai-documenation.md +0 -747
- data/gpt-context/theme-prompts.csv +0 -21
- data/lib/openai_101/config/openai.rb +0 -15
- data/lib/openai_101/tools/automate-images-chatgpt.js +0 -60
- data/lib/openai_101/tools/automate-images-midjourney.js +0 -75
- data/lib/openai_101/tools/bulk_image_bot/base_automator.js +0 -53
- data/lib/openai_101/tools/bulk_image_bot/chatgpt_automator.js +0 -27
- data/lib/openai_101/tools/bulk_image_bot/midjourney_automator.js +0 -49
- data/lib/openai_101/tools/clean_ruby_errors.rb +0 -274
- data/lib/openai_101/tools/edl_to_chapters.rb +0 -56
- data/lib/openai_101/tools/file_content_gatherer.rb +0 -36
- data/lib/openai_101/tools/webp_to_png.rb +0 -124
@@ -1,124 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'mini_magick'
|
4
|
-
|
5
|
-
module Openai101
|
6
|
-
module Tools
|
7
|
-
# Convert WebP to PNG
|
8
|
-
class WebpToPng
|
9
|
-
attr_reader :source_folder
|
10
|
-
attr_reader :target_folder
|
11
|
-
attr_reader :target_filename
|
12
|
-
attr_reader :prefix
|
13
|
-
|
14
|
-
def initialize(target_filename:, source_folder: nil, target_folder: nil, prefix: nil)
|
15
|
-
root = File.expand_path('../../..', __dir__)
|
16
|
-
@source_folder = source_folder || ENV.fetch('DOWNLOAD_DIR', nil)
|
17
|
-
@target_folder = target_folder || File.join(root, 'course/images')
|
18
|
-
@target_filename = target_filename
|
19
|
-
@prefix = prefix
|
20
|
-
end
|
21
|
-
|
22
|
-
def convert
|
23
|
-
puts "\e[31m#{source_filename}\e[0m"
|
24
|
-
image = MiniMagick::Image.open(source_filename)
|
25
|
-
image.format 'png'
|
26
|
-
image.write target_png_file
|
27
|
-
|
28
|
-
self
|
29
|
-
end
|
30
|
-
|
31
|
-
def store_prompt
|
32
|
-
File.write(target_prompt_file, prompt)
|
33
|
-
|
34
|
-
self
|
35
|
-
end
|
36
|
-
|
37
|
-
def backup_source
|
38
|
-
backup_filename = File.basename(source_filename, '.webp')
|
39
|
-
backup = target_path(backup_filename, 'webp', subfolder: 'backups')
|
40
|
-
FileUtils.cp(source_filename, backup)
|
41
|
-
|
42
|
-
self
|
43
|
-
end
|
44
|
-
|
45
|
-
def delete_source
|
46
|
-
File.delete(source_filename)
|
47
|
-
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
def clear_backup
|
52
|
-
FileUtils.rm_rf(File.join(target_folder, 'backups'))
|
53
|
-
|
54
|
-
self
|
55
|
-
end
|
56
|
-
|
57
|
-
def target_file
|
58
|
-
prefix ? "#{prefix}-#{target_filename}" : target_filename
|
59
|
-
end
|
60
|
-
|
61
|
-
def target_png_file
|
62
|
-
target_path(target_file, 'png')
|
63
|
-
end
|
64
|
-
|
65
|
-
def target_prompt_file
|
66
|
-
target_path(target_file, 'txt', subfolder: 'prompts')
|
67
|
-
end
|
68
|
-
|
69
|
-
def prompt
|
70
|
-
grab_prompt(File.basename(source_filename))
|
71
|
-
end
|
72
|
-
|
73
|
-
def source?
|
74
|
-
!source_filename.nil?
|
75
|
-
end
|
76
|
-
|
77
|
-
def source_filename
|
78
|
-
@source_filename ||= find_last_webp_file(source_folder)
|
79
|
-
end
|
80
|
-
|
81
|
-
def sanitize_all_webp_files
|
82
|
-
file_changed = false
|
83
|
-
puts '1'
|
84
|
-
Dir.glob(File.join(source_folder, '*.webp')).each do |file_path|
|
85
|
-
sanitized_filename = sanitize_filename(File.basename(file_path))
|
86
|
-
sanitized_path = File.join(File.dirname(file_path), sanitized_filename)
|
87
|
-
puts sanitized_path
|
88
|
-
if file_path != sanitized_path
|
89
|
-
FileUtils.mv(file_path, sanitized_path)
|
90
|
-
file_changed = true
|
91
|
-
end
|
92
|
-
end
|
93
|
-
sleep(3) if file_changed # Pause if any file was renamed
|
94
|
-
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
def sanitize_filename(filename)
|
99
|
-
filename.gsub(/[^0-9A-Za-z.\-]/, '_')
|
100
|
-
end
|
101
|
-
|
102
|
-
def target_path(filename, extension = nil, subfolder: nil, make_folder: true)
|
103
|
-
folder = subfolder ? File.join(target_folder, subfolder) : target_folder
|
104
|
-
|
105
|
-
FileUtils.mkdir_p(folder) if make_folder
|
106
|
-
|
107
|
-
if extension.nil?
|
108
|
-
File.join(folder, filename)
|
109
|
-
else
|
110
|
-
File.join(folder, "#{filename}.#{extension}")
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def find_last_webp_file(path)
|
115
|
-
Dir.glob(File.join(path, '*.webp')).max_by { |f| File.mtime(f) }
|
116
|
-
end
|
117
|
-
|
118
|
-
def grab_prompt(filename)
|
119
|
-
match = filename.match(/DALL_E_\d{4}-\d{2}-\d{2}_\d{2}\.\d{2}\.\d{2}_-_(.+)\.webp$/)
|
120
|
-
match[1] if match
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|