Skip to content

Instantly share code, notes, and snippets.

View iftheshoefritz's full-sized avatar

Fritz Meissner iftheshoefritz

  • Cape Town, South Africa
View GitHub Profile
@iftheshoefritz
iftheshoefritz / smores.rb
Created August 11, 2023 10:37
Starting point for parallel Ruby conversations
# frozen_string_literal: true
# problem code from Graceful.dev: https://graceful.dev/courses/tapastry/modules/2019/topic/full-utilization/
$tick = 0
def work(seconds)
$tick += seconds
end
def log(message)

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.

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.
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',
# 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?

## 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
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
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
[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": {
namespace :solargraph do
task update_model_definitions: :environment do
if Rails.env.development?
Rails.application.eager_load!
def_file = Rails.root.join('config', 'model_definitions.rb')
File.open(def_file, 'w') do |file|
ApplicationRecord.descendants.each do |model|
file << "class #{model.name}\n"
klass = model.name.constantize
klass.attribute_names.each do |name|