Create an official repository of patterns similar to the Rails Guides, but with a focus on solving common tasks with the framework.
Especially for newcomers, it can be daunting to find idiomatic ways to leverage the framework to solve common problems. For example, if one googles for "how to do authentication in Rails", one gets the recommendation to use the Devise gem (and lots of other blog articles). However, as an experienced Rails developer, we know that implementing a basic login can be written with a few lines of code - without external dependencies. I believe having an official platform to look up such solutions could improve developer velocity, junior confidence, code quality and even security.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.frontendmentor.io/challenges/expenses-chart-component-e7yJBUdjwt | |
{ | |
"spendings": { | |
"2022-05-30": 50.4, | |
"2022-05-31": 72.5, | |
"2022-06-01": 116, | |
"2022-06-02": 65.18, | |
"2022-06-03": 50.75, | |
"2022-06-04": 80, | |
"2022-06-05": 43.5, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// moved to: https://codepen.io/motine/pen/RwgrdOx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# services/monitoring/cleanup_service.rb | |
class Monitoring::CleanupService | |
def self.run | |
Monitoring::Measurement.where("recorded_at < ?", 3.months.ago).delete_all | |
end | |
end | |
# let this service run nightly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mind the casing: camelCase | |
// we use floats and integers not strings | |
// we use null where appropriate | |
// in regard to 4. "standardized analysis names": when we define a standard format, let's make sure to also standardize this | |
// similar for 5. "standardized instrument names": let the homogenization layer take care of this and make sure we define standard names for instrument types | |
{ | |
"name": "GE20_RT3168-3171-3173-3175_20200626_JRU_Prof", | |
"instrument": "LightCycler480", | |
"instrumentId": 6078, | |
"instrumentName": "Prof_6078", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara' | |
require 'capybara/rspec' | |
# please see notes in README.md | |
Capybara.server_host = '0.0.0.0' | |
Capybara.server_port = '56556' | |
Capybara.app_host = 'http://localhost:56556' | |
Capybara.register_driver(:host_chrome) do |app| | |
caps = Selenium::WebDriver::Remote::Capabilities.chrome('goog:chromeOptions' => {'w3c' => false}, 'browserName' => 'chrome') # we need to set w3c to false so uploads do work; see https://github.com/SeleniumHQ/selenium/issues/7666 and https://stackoverflow.com/questions/58296774/ruby-selenium-webdriver-3-142-6-unable-to-upload-file-due-to-seleniumwebdriv | |
driver = Capybara::Selenium::Driver.new(app, browser: :remote, url: 'http://host.docker.internal:9515', desired_capabilities: caps) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="hello">Hello {{ name }}.</div> | |
</template> | |
<script> | |
export default { | |
data() { return { name: 'Manfred' } } | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_PATH = File.expand_path("~/Repositories/beauty") | |
LINE_LENGTH_THRESHOLD = 150 | |
above, total = 0, 0 | |
Dir[File.join(BASE_PATH, "**/*.rb")].each do |path| | |
contents = File.readlines(path) | |
above += contents.count { |line| line.length > LINE_LENGTH_THRESHOLD } | |
total += contents.size | |
end |
NewerOlder