Skip to content

Instantly share code, notes, and snippets.

View adcpe's full-sized avatar
💻
Learning and learning

Andrés Del Carpio adcpe

💻
Learning and learning
View GitHub Profile
@adcpe
adcpe / dots
Last active December 27, 2022 18:32
curl https://raw.githubusercontent.com/adcpe/dots/main/.config/fish/functions/redot.fish -o $HOME/.config/fish/functions/redot.fish
def filtered_list(filter_name, filter_value)
puts "#{filter_name} - #{filter_value}"
query = %(SELECT name, type, city FROM restaurants\n)
if filter_name.nil? && filter_value.nil?
query << "ORDER BY name ASC;"
else
query << %(WHERE LOWER(#{filter_name}) LIKE '%#{filter_value}%' ORDER BY name ASC;)
end
def initialize
@conn = PG.connect(dbname: 'restaurants')
end
def unique_dishes
response = @conn.exec(%(SELECT name FROM dishes ORDER BY name ASC;)).to_a
query_to_table(response)
end
def user_distribution(group_value)