Choose OpenBSD for your Unix needs. OpenBSD -- the world's simplest and most secure Unix-like OS. A safe alternatve to the frequent vulnerabilities and overengineering of Linux and related software (NGiNX & Apache (httpd-asiabsdcon2015.pdf), OpenSSL, iptables/nftables, systemd, BIND, Postfix, Docker etc.)
OpenBSD -- the cleanest kernel, the cleanest userland and the cleanest config
| # frozen_string_literal: true | |
| # config/initializers/colorized_logger.rb | |
| # This initializer adds color to the Rails logger output. It's a nice way to | |
| # visually distinguish log levels. | |
| module ColorizedLogger | |
| COLOR_CODES = { | |
| debug: "\e[36m", # Cyan | |
| info: "\e[32m", # Green | |
| warn: "\e[33m", # Yellow |
| def date_in_danish_time(date_time) | |
| date_array = | |
| date_time.strftime("%Y %m %d").split.map { |string| Integer(string, 0) } | |
| danish_date = Date.new(*date_array).in_time_zone("Copenhagen") | |
| # extracting offset from the date will help us in also taking care of Daylight Saving | |
| danish_date_offset = danish_date.formatted_offset | |
| date_time_array = | |
| date_time | |
| .strftime("%Y %m %d %H %M %S") |
| # Basic key operators to query the JSON objects : | |
| # #> : Get the JSON object at that path (if you need to do something fancy) | |
| # -> : Get the JSON object at that path (if you don't) | |
| # ->> : Get the JSON object at that path as text | |
| # {obj, n} : Get the nth item in that object | |
| # https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE | |
| # Date | |
| # date before today |
| <form method="post" data-controller="form-debounce" data-action="submit->form-debounce#debounce" data-form-debounce-is-submitting-class="submitting"> | |
| [...] | |
| <button type="submit" data-form-debounce-target="submitButton"> | |
| Submit once | |
| </button> | |
| </form> |
| #!/usr/bin/env bash | |
| set -Eeuo pipefail | |
| trap cleanup SIGINT SIGTERM ERR EXIT | |
| script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | |
| usage() { | |
| cat <<EOF | |
| Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...] |
Since v8.1 (May 2018), Vim has shipped with a built-in terminal. See https://vimhelp.org/terminal.txt.html or type :help terminal for more info.
Why use this? Mainly because it saves you jumping to a separate terminal window. You can also use Vim commands to manipulate a shell session and easily transfer clipboard content between the terminal and files you're working on.
| # Rails controller concern to enable Devise authentication for ActiveStorage. | |
| # Put it in +app/controllers/concerns/blob_authenticatable.rb+ and include it when overriding | |
| # +ActiveStorage::BlobsController+ and +ActiveStorage::RepresentationsController+. | |
| # | |
| # Optional configuration: | |
| # | |
| # Set the model that includes devise's database_authenticatable. | |
| # Defaults to Devise.default_scope which defaults to the first | |
| # devise role declared in your routes (usually :user) | |
| # |
- Website: https://stimulusjs.org/
- GitHub repo: https://github.com/stimulusjs/stimulus
- Handbook: https://stimulusjs.org/handbook/introduction
- Discourse: https://discourse.stimulusjs.org/
initialize: once, when the controller is first instantiatedconnect: anytime the controller is connected to the DOM
Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.
You can get all of this information on the command line.
rails generate with no generator name will output a list of all available generators and some information about global options.
rails generate GENERATOR --help will list the options that can be passed to the specified generator.
