Skip to content

Instantly share code, notes, and snippets.

@motine
motine / GitHubFlavoredMarkdown.md
Last active April 10, 2024 10:34 — forked from Myndex/GitHubFlavoredMarkdown.md
GitHub Flavored Markdown Cheat Sheet

Markdown Short Intro

Headers

H1

H2

H3

H4

H5
H6
@motine
motine / 01 Proposal.md
Last active August 21, 2023 18:35
Rails Patterns

Proposal

Create an official repository of patterns similar to the Rails Guides, but with a focus on solving common tasks with the framework.

Proposal

Motivation

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.

// 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,

DSL Boilerplate

We want something like this:

class LakeSuperior
  include LakeDSL

  lake_name 'Lake Superior'
 fish 'trout'
@motine
motine / waft.js
Last active September 1, 2021 06:23
// moved to: https://codepen.io/motine/pen/RwgrdOx
@motine
motine / cleanup_job.rb
Last active April 22, 2021 16:45
Simple Rails Monitoring
# 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
// 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",
@motine
motine / gist:8af309be7db58b76eb9b571b703acfa6
Created July 15, 2020 07:14
spec/support/config_capybara.rb
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)
@motine
motine / Hello.vue
Last active March 28, 2020 11:32
Rollup multi page bundles
<template>
<div class="hello">Hello {{ name }}.</div>
</template>
<script>
export default {
data() { return { name: 'Manfred' } }
}
</script>
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