Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created July 23, 2023 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjn1056/e41cf355bb70e6b108abdf7068bc872f to your computer and use it in GitHub Desktop.
Save jjn1056/e41cf355bb70e6b108abdf7068bc872f to your computer and use it in GitHub Desktop.
an example using pg_vector to store information about colors via their RGB values
-- Assuming you already have a database named 'my_database'
CREATE TABLE colors (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
color_vector VECTOR(3)
);
INSERT INTO colors (name, color_vector) VALUES
-- Primary colors
('Red', '[255, 0, 0]'),
('Green', '[0, 255, 0]'),
('Blue', '[0, 0, 255]'),
-- Various shades of Red
('Crimson', '[220, 20, 60]'),
('Maroon', '[128, 0, 0]'),
('Indian Red', '[205, 92, 92]'),
('Fire Brick', '[178, 34, 34]'),
('Dark Red', '[139, 0, 0]'),
-- Various shades of Green
('Lime Green', '[50, 205, 50]'),
('Forest Green', '[34, 139, 34]'),
('Olive Drab', '[107, 142, 35]'),
('Sea Green', '[46, 139, 87]'),
('Dark Green', '[0, 100, 0]'),
-- Various shades of Blue
('Dodger Blue', '[30, 144, 255]'),
('Sky Blue', '[135, 206, 235]'),
('Navy', '[0, 0, 128]'),
('Midnight Blue', '[25, 25, 112]'),
('Slate Blue', '[106, 90, 205]'),
-- Randomly generated shades
('Teal', '[0, 128, 128]'),
('Purple', '[128, 0, 128]'),
('Orange', '[255, 165, 0]'),
('Yellow', '[255, 255, 0]'),
('Pink', '[255, 192, 203]'),
('Brown', '[165, 42, 42]'),
('Cyan', '[0, 255, 255]'),
('Magenta', '[255, 0, 255]'),
('Gold', '[255, 215, 0]'),
('Silver', '[192, 192, 192]'),
('Gray', '[128, 128, 128]'),
('Black', '[0, 0, 0]'),
('White', '[255, 255, 255]'),
('Aqua', '[0, 255, 255]'),
('Lavender', '[230, 230, 250]'),
('Khaki', '[240, 230, 140]'),
('Coral', '[255, 127, 80]'),
('Turquoise', '[64, 224, 208]'),
('Violet', '[238, 130, 238]'),
('Indigo', '[75, 0, 130]'),
('Linen', '[250, 240, 230]'),
('Salmon', '[250, 128, 114]'),
('Tomato', '[255, 99, 71]'),
('Dark Orange', '[255, 140, 0]'),
('Sandy Brown', '[244, 164, 96]'),
('Dark Slate Gray', '[47, 79, 79]'),
('Rosy Brown', '[188, 143, 143]'),
('Medium Purple', '[147, 112, 219]'),
('Powder Blue', '[176, 224, 230]'),
('Pale Green', '[152, 251, 152]'),
('Orchid', '[218, 112, 214]'),
('Pale Violet Red', '[219, 112, 147]'),
('Dark Khaki', '[189, 183, 107]'),
('Medium Orchid', '[186, 85, 211]'),
('Slate Gray', '[112, 128, 144]'),
('Medium Aquamarine', '[102, 205, 170]'),
('Dark Orchid', '[153, 50, 204]'),
('Lawn Green', '[124, 252, 0]'),
('Chartreuse', '[127, 255, 0]'),
('Hot Pink', '[255, 105, 180]'),
('Dark Goldenrod', '[184, 134, 11]');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment