Add this file to your AI assistant's system prompt or context to help it avoid common AI writing patterns. Source: tropes.fyi by ossama.is
| require_relative 'spec/spec_helper.rb' | |
| require 'pry-byebug' | |
| class SpecFile | |
| CREATE = ' create(:'.freeze | |
| BUILD_STUBBED = ' build_stubbed(:'.freeze | |
| attr_reader :file_name, :content_array | |
| def initialize(file_name) |
Сегодня попался рельсовый код, в котором используются монады, сервисы и прочее. Решил сделать обзор с объяснением того, что в коде не нравится и что можно исправить.
Данный разбор основан только на личном опыте и избегает попытку написать самый идеальный код на свете. К сожалению пошарить ссылку на код не могу, потому что автор попросил опубликовать анонимно.
Главная операция, которая вызывается из контроллера выглядит следующим образом:
| # FOR BUSY JOBS | |
| # take the process_id from the /busy page in sidekiq and kill the longest running one. | |
| workers = Sidekiq::Workers.new | |
| long_process_id = 'integration.3:4:71111aaa111' # Eg: 'integration.3:4:71d1d7f4ef5a' | |
| workers.each do |process_id, thread_id, work| | |
| process = Sidekiq::Process.new('identity' => process_id) | |
| process.stop! if process_id == long_process_id | |
| end | |
| # FOR SCHEDULED JOBS |
| # taken from https://www.postgresql.org/download/linux/debian/ | |
| # assumes you are root | |
| echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' > /etc/apt/sources.list.d/pgdg.list | |
| wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | |
| apt-get update | |
| yes Y | apt-get install postgresql-client-10 |
| http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
| http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
| #payload: [{"kind"=>"person"}] | |
| Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
| #data: {"interest"=>["music", "movies", "programming"]} | |
| Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
| Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
| Segment.where("jsonb_array_length(data->'interest') > 1") |
| brew tap homebrew/versions | |
| brew install v8-315 | |
| gem install libv8 -v '3.16.14.13' -- --with-system-v8 | |
| gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315 | |
| bundle install |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
Un guide bienveillant pour les propriétaires de chien : des parcours d'apprentissage, des guides pratiques, des fiches de races et un assistant qui répond à vos questions en s'appuyant uniquement sur ces guides.
Sweet Dog est un « concierge du canon » : son assistant ne répond qu'à partir des guides publiés ci-dessous et ne contredit jamais un guide. Édition française (langue de référence) ; l'édition anglaise suit, après le séparateur.
- Sweet Dog — poser une question: La page d'accueil EST l'assistant : posez une question, il répond à partir des guides.
- Apprendre: Le catalogue des parcours et des guides.
In the below keyboard shortcuts, I use the capital letters for reading clarity but this does not imply shift, if shift is needed, I will say shift. So ⌘ + D does not mean hold shift. ⌘ + Shift + D does of course.
| Function | Shortcut |
|---|---|
| New Tab | ⌘ + T |
| Close Tab or Window | ⌘ + W (same as many mac apps) |
| Go to Tab | ⌘ + Number Key (ie: ⌘2 is 2nd tab) |
| Go to Split Pane by Direction | ⌘ + Option + Arrow Key |