- You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use
rails new
first to generate all of the boilerplate files necessary. - Create an app in the current directory with
rails new .
- Use Tailwind CSS for styling. Use
--css tailwind
as an option on therails new
call to do this automatically. - Use Ruby 3.2+ and Rails 8.0+ practices.
- Use the default Minitest approach for testing, do not use RSpec.
- Default to using SQLite in development.
rails new
will do this automatically but take care if you write any custom SQL that it is SQLite compatible. - An app can be built with a devcontainer such as
rails new myapp --devcontainer
but only do this if requested directly. - Rails apps have a lot of directories to consider, such as app, config, db, etc.
- Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
- Guard against incapable browsers accessing controllers with `allo
This file contains hidden or 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
;;=============== play with flow ============== | |
(require '[clojure.core.async :as async] | |
'[clojure.core.async.flow :as flow] | |
'[clojure.pprint :as pp] | |
'[clojure.datafy :as d] | |
'[clojure.walk :as w]) | |
(set! *warn-on-reflection* true) | |
(defn monitoring [{:keys [report-chan error-chan]}] |
This file contains hidden or 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
#!/usr/bin/env bash | |
set -eo pipefail | |
CERT_FILE="./certs/dev/dev-ca/rootCA.pem" | |
CERT_NAME="Nextjournal Development Root CA" | |
echo "Installing development Root CA into system store..." | |
if uname -a | grep -q Darwin; then | |
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain $CERT_FILE |
This file contains hidden or 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
mkdir -p ~/.conda/pkgs && printf 'pkgs_dirs:\n - ~/.conda/pkgs\n' >> ~/.condarc |
If your master.key has been compromised, you might want to regenerate it.
No key regeneration feature at the moment. We have to do it manually.
- Copy content of original credentials
rails credentials:show
somewhere temporarily. - Remove
config/master.key
andconfig/credentials.yml.enc
- Run
EDITOR=vim rails credentials:edit
in the terminal: This command will create a newmaster.key
andcredentials.yml.enc
if they do not exist. - Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
- Add and Commit the file
config/credentials.yml.enc
This file contains hidden or 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
# Instead of loading all of Rails, load the | |
# particular Rails dependencies we need | |
require 'sqlite3' | |
require 'active_record' | |
# Set up a database that resides in RAM | |
ActiveRecord::Base.establish_connection( | |
adapter: 'sqlite3', | |
database: ':memory:' | |
) |
This file contains hidden or 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
#!/bin/bash | |
# NB: First install nscd with sudo apt-get install nscd | |
# run this command to flush dns cache: | |
sudo /etc/init.d/dns-clean restart | |
# or use: | |
sudo /etc/init.d/networking force-reload | |
# Flush nscd dns cache: | |
sudo /etc/init.d/nscd restart |
This file contains hidden or 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
""" | |
Shows how to do a cross join (i.e. cartesian product) between two pandas DataFrames using an example on | |
calculating the distances between origin and destination cities. | |
Tested with pandas 0.17.1 and 0.18 on Python 3.4 and Python 3.5 | |
Best run this with Spyder (see https://github.com/spyder-ide/spyder) | |
Author: Markus Konrad <post@mkonrad.net> | |
April 2016 |
This file contains hidden or 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
;; Code folding | |
(add-hook 'ruby-mode-hook | |
(lambda () (hs-minor-mode))) | |
(eval-after-load "hideshow" | |
'(add-to-list 'hs-special-modes-alist | |
`(ruby-mode | |
,(rx (or "def" "class" "module" "do" "{" "[")) ; Block start | |
,(rx (or "}" "]" "end")) ; Block end | |
,(rx (or "#" "=begin")) ; Comment start |
NewerOlder