Prefer natural language over abstracted strings for language keys. This helps to make the views easier to read and understand.
Take advantage of the fact that spaces are legal in YAML keys:
# Bad
t('.all_label')
desc 'Raise exception if used in production' | |
task protect_prod: [:environment] do | |
raise 'This task cannot be run in production' if Rails.env.production? | |
end | |
['db:drop', 'db:reset', 'db:seed'].each do |t| | |
Rake::Task[t].enhance ['protect_prod'] | |
end |
To convert json to csv with headers using jq
and the @csv
filter.
jq -r '[first|keys_unsorted] + map([.[]]) | .[] | @csv' example.json > converted.csv
This would work on a simple json structured like:
[
# A small script to generate memorable one-time codes. | |
# | |
# OneTimeCode.generate | |
# => "ubahow-idea-easy-aveda" | |
class OneTimeCode | |
def initialize(length = 12) | |
@length = length | |
@mod_result = MOD_RESULT.sample | |
end |
# This example follows a Stripe webhook through the application life cycle. | |
# In this case, a customer has created a Checkout, which is an object in our application that acts like a shopping cart. | |
# It relates to the products that are being purchased and encapsulates the customer's existing record, or the data required to create a new customer. | |
class Checkout < ApplicationRecord | |
include Amountable | |
include BtcpayInvoice | |
include StripePaymentIntent | |
belongs_to :user, optional: true |
{"version":1,"resource":"file:///Users/ryanheneise/Projects/api/src/services/fees/index.js","entries":[{"id":"DXVN.js","timestamp":1667270770299},{"id":"VJk1.js","timestamp":1667270856905},{"id":"pi2q.js","timestamp":1667271038502}]} |
# frozen_string_literal: true | |
module MxIsoagent | |
class Client | |
BOARDING_URL = Rails.configuration.mx_iso_agent['boarding_url'] | |
CHECKOUT_URL = Rails.configuration.mx_iso_agent['checkout_url'] | |
INVITE_CODE = Rails.configuration.mx_iso_agent['invite_code'] | |
BOARDING_KEYS = Rails.configuration.mx_iso_agent['api_key'] | |
BUSINESS_TYPES = [ |
# frozen_string_literal: true | |
module GravatarHelper | |
def gravatar_image_tag(email, attrs = {}) | |
attrs = { | |
class: 'h-10 w-10 rounded-full' | |
}.update(attrs) | |
image_tag gravatar_url(email), attrs | |
end |
We're looking for a talented and competent Ruby on Rails developer to help us re-engineer an existing app that's hard to maintain and expensive. The existing app is built using React on the frontend and Apache Airflow on the backend. We're going to re-engineer the app to make it more maintainable and remove some unneeded complexity that makes it difficult to maintain and expensive to develop.
The purpose of this app is to receive credit card processing reports, apply a markup algorithm, and then generate a report for each store based on the result.
The current process is handled by two separate apps:
# frozen_string_literal: true | |
# bundle exec rails runner create_accounts.rb | |
# An organization that the above users don't have access to | |
organization = Organization.find_or_create_by(slug: 'accounting-demo') do |o| | |
o.name = 'Accounting Demo' | |
o.invite_code = Rails.configuration.mx_iso_agent['invite_code'] | |
end |