This file contains 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 | |
# Abort sign off on any error | |
set -e | |
# Start the benchmark timer | |
SECONDS=0 | |
# Repository introspection | |
OWNER=$(gh repo view --json owner --jq .owner.login) |
This file contains 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
Settings > Editor > File Types > In Recognized File Types find HTML and add *.html.eex to Registered Patterns |
This file contains 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
module FoodPreparer | |
#this can be used for an after_initialize in rails so calling cook_meal | |
#uses the @lookup varibale, otherwise you could just substitute the dis- | |
#patch_table method in its place | |
def build_dispatch_table | |
@lookup = { | |
turkey: -> (n) { cook_turkey n }, | |
ham: -> (n) { cook_ham n }, |
This file contains 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
module Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def filter(filtering_params) | |
results = self.where(nil) | |
filtering_params.each do |key, value| | |
results = results.public_send(key, value) if value.present? | |
end | |
results |
This file contains 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
# Create a Dokku app and addons | |
#------------------------------ | |
## Go to http://SERVER_IP and add a IP address (if you don't it seems to go weird: use a junk one if needed) | |
dokku apps:create APP_NAME | |
## Add postgresql and link it to the application | |
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres | |
dokku postgres:create APP_NAME-db | |
dokku postgres:link APP_NAME-db APP_NAME |
This file contains 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
^[.\ \'\p{L}]*$ |
This file contains 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
# custom_form_builder.rb | |
class CustomFormBuilder < ActionView::Helpers::FormBuilder | |
def error_tag(field, opts = {}) | |
@template.content_tag(:span, @object.errors[field].join(", "), class: "text-danger") if [email protected][field].blank? | |
end | |
end | |
# _form.html.erb | |
<%= form_with(model: <model>, local: true, builder: CustomFormBuilder) do |form| %> |
This file contains 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
update-locale LC_CTYPE=en_US.UTF-8 |
This file contains 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
# Create S3 bucket in any region | |
# Change bucket policy | |
{ | |
"Version": "2018-06-06", | |
"Id": "Policy1528273129416", | |
"Statement": [ | |
{ | |
"Sid": "Stmt1528273125295", | |
"Effect": "Allow", |
This file contains 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
# Creating a Digital Ocean droplet running Rails + Postgres with persistant storage and https | |
#-------------------------------------------------------------------------------------------- | |
# For your ctrl-D pleasure... | |
# SERVER_IP | |
# APP_NAME | |
# RAILS_SECRET (generate with `rails secret`) | |
# ADMIN_EMAIL | |
NewerOlder