If you are like many (most?) of us, you have encountered Rails
Credentials/Secrets and secret_key_base and may have been
left a bit (or more) confused.
This post is an attempt to remove some of that confusion by
| #!/bin/bash | |
| # Production Docker Host Hardening Script v2 | |
| # For Ubuntu Server 24.04 LTS (Noble) | |
| # Suitable for both Kamal deployment and builder hosts | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| # --- Constants --- |
| http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
| http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
| #payload: [{"kind"=>"person"}] | |
| Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
| #data: {"interest"=>["music", "movies", "programming"]} | |
| Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
| Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
| Segment.where("jsonb_array_length(data->'interest') > 1") |
| # put this inside spec/support/random_ids.rb | |
| # NOTE: this works, but will break tests whee something like Article.last is used | |
| # a more clever approach is used in 02 below | |
| # Some tests may pass when they should have failed | |
| # due to Rails using sequential ids. This allows us | |
| # to fix that by having random ids. | |
| class ActiveRecord::Base | |
| before_create :generate_random_id |
| library(stats) | |
| library(forecast) | |
| ### DATALOAD ### | |
| # nemocnice | |
| pripady<-read.csv('fnhk_pripady.csv',header=T) | |
| vykony<-read.csv('fnhk_vykony.csv',header=T) | |
| zup<-read.csv('fnhk_zup.csv',header=T) | |
| data_length<-nrow(pripady) | |
| # PSC po okresech |
It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:
>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
| # Use: | |
| # This is in file config.ru | |
| # 1) gem install rack | |
| # 2) rackup | |
| # 3) visit http://localhost:9292 in browser | |
| # 4) Timer info will be in console | |
| # 5) when changing code, will have to restart rackup | |
| # Include rack | |
| require 'rack' |
| # config/routes.rb | |
| resources :documents do | |
| scope module: 'documents' do | |
| resources :versions do | |
| post :restore, on: :member | |
| end | |
| resource :lock | |
| end | |
| end |