Skip to content

Instantly share code, notes, and snippets.

Avatar

Fritz Meissner iftheshoefritz

  • Cape Town, South Africa
View GitHub Profile
View update_preparable_status.rb
module Restaurant
class UpdatePreparableStatus
include ActiveModel::Validations
attr_reader :preparable, :new_status
validate :can_reject_order, if: :rejecting?
validate :must_have_active_preparable
validate :must_have_order_check_id
validate :must_have_current_preparable
View cfp.markdown

Railsconf 2022 CFP: LSP and Solargraph

Title

Autocomplete is for Ruby too!

Abstract

A concise, engaging description for the public program. Limited to 600 characters.

Do you have editor-envy when you witness other programmers using fancy IDE features like go-to-definition or auto-complete? Perhaps you've only witnessed this with other languages - maybe those with static typing - but that's not how it has to be.

Powerful - albeit sometimes obscure - open source tools with all these features are available for Ruby. Come hear more! I'll explain the building blocks of code intellisense features; something called Language Server Protocol; a Ruby language server called Solargraph; the solargraph-rails gem; and how you can get involved to make them even better.

View kafka-local-troubleshooting.md

Troubleshooting local instance of kafka

Command line kafka utilities

If your rails server or consumer cannot connect to Kafka locally you can try using the command line utilities included with kafka to diagnose whether your kafka is set up properly:

Create a topic:

⚡  kafka-topics --create --partitions 1 --replication-factor 1 --topic new-test-topic --bootstrap-server 127.0.0.1:9092

Created topic new-test-topic.
View delivery_orchestration_controller.js.js
import ActionCableController from 'controllers/action_cable_controller';
console.log("loading delivery orchestration controller.js");
const statusToListTargetMap = {
pending: 'pendingList',
customer_arrived: 'pendingList',
collecting: 'collectingList',
out_for_delivery: 'finishedList',
delivered: 'finishedList',
View louis.rb
# frozen_string_literal: true
class ProductsController < ApplicationController
include ProductWithQuoteFormParams
before_action :redirect_admins
before_action :set_organization
before_action :set_product,
only: %i[edit update destroy make_public make_private] # TODO why the last two actions?
View kafka concepts.org

## Current ordering problems:

  • the most complicated parts of the system are coupled to orders being placed
    • e.g. order -> payment completed -> branch assignment -> driver assignment
    • “everything initiated by an order” is hard to avoid in standard web apps where user input (requests) initiate all activity.
    • This chain is too long, it’s hard to reason about
  • ordering features fight for resources
    • restaurant dashboard vs driver assignment vs order list vs driver list
      • all have different purposes with different requirements in terms of:
        • how often they need to be updated
        • what data is queried
View deferrals.rb
app_ids = {
179684 => [2020,12],
184953 => [2021,1],
193893 => [2021,1],
179940 => [2021,1],
176725 => [2021,1],
199541 => [2021,1],
191108 => [2021,1],
196035 => [2020,10],
173416 => [2021,1],
View generate_solar_plagiarized.rb
namespace :solargraph do
task generate: :environment do
# Add the folder you choose in your config/application.rb
# example:
# config.autoload_paths << Rails.root.join('app/solargraph')
gen_directory = Rails.root.join("config", "yard")
# run the script as a rails runner:
# jundle exec rails r ./bin/generate_solar_models.rb
View generate_solar_plagiarized.rb
namespace :solargraph do
task generate: :environment do
# Add the folder you choose in your config/application.rb
# example:
# config.autoload_paths << Rails.root.join('app/solargraph')
gen_directory = Rails.root.join("config", ".yard")
# run the script as a rails runner:
# jundle exec rails r ./bin/generate_solar_models.rb
View untitled.txt
[Trace - 04:22:37 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///Users/fritzmeissner/devprojects/school-api/app/models/school.rb",
"version": 1
},
"contentChanges": [
{
"range": {
"start": {