| <%= form_with model: citizen, class: "card flex flex-col gap", data: { controller: "form" } do |form| %> | |
| <div class="flex flex-col gap mb-2"> | |
| <div class="flex flex-col gap-half"> | |
| <% countries = Country.order(:name) %> | |
| <%= label_tag :country_id, "Country", class: "text-sm font-medium leading-none" %> | |
| <%= select_tag :country_id, options_from_collection_for_select(countries, :id, :name, citizen.country_id), include_blank: "Select one", class: "input", data: { action: "form#submit", form_submitter_param: "on_country_change" } %> | |
| </div> | |
| <div class="flex flex-col gap-half"> | |
| <% states = State.where(country_id: citizen.country_id).order(:name) %> |
- Rails 7.0.2
- stimulus js
- importmaps
- dropzone.js
- direct upload ActiveStorage
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
| // This helper file provides a consistent API for testing Stimulus Controllers | |
| // | |
| // Use: | |
| // import { getHTML, setHTML, startStimulus } from './_stimulus_helper'; | |
| // import MyController from '@javascripts/controllers/my_controller'; | |
| // | |
| // beforeEach(() => startStimulus('my', MyController)); | |
| // test('should do something', async () => { | |
| // await setHTML(`<button data-controller="my" data-action="my#action">click</button>`); | |
| // |
Do you really need Elastic Search?
- https://www.postgresql.org/docs/current/pgtrgm.html
- https://scoutapm.com/blog/how-to-make-text-searches-in-postgresql-faster-with-trigram-similarity
- https://about.gitlab.com/blog/2016/03/18/fast-search-using-postgresql-trigram-indexes/
- https://mazeez.dev/posts/pg-trgm-similarity-search-and-fast-like
- https://alexklibisz.com/2022/02/18/optimizing-postgres-trigram-search.html
- https://www.freecodecamp.org/news/fuzzy-string-matching-with-postgresql/
| /* | |
| Want to know when ECS events happen in Slack? Try this. | |
| (1) Create a new Slack app with an incoming webhook, save the webhook URL | |
| (2) Create an SNS topic called something like ECSEvents | |
| (3) Create a CloudWatch Rule that publishes all ECS events to the topic | |
| (4) Create a Node.js Lambda that is triggered by the SNS topic | |
| (5) Add a WEBHOOK_URL environment variable to the Lambda with the webhook URL | |
| (6) Paste this code into index.js | |
| (7) Paste the contents of https://unpkg.com/node-fetch/lib/index.js into fetch.js | |
| (8) Deploy and enjoy |
| # build/Dockerfile | |
| FROM ruby:2.7.1-buster | |
| RUN mkdir -p /usr/src/app | |
| WORKDIR /usr/src/app | |
| RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | |
| RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | |
| RUN apt-get update && apt-get install -y nodejs yarn default-mysql-client nano --no-install-recommends && rm -rf /var/lib/apt/lists/* |
The first step is to use the Expo CLI to initialize the project. If you don't have the latest version of the Expo CLI tool, (or you don't have it installed) run npm install -g expo-cli.
Now run the following commands in the same order:
expo init my-app -t expo-template-blank-typescriptnpx install-peerdeps --dev eslint-config-airbnbnpm i --save-dev @typescript-eslint/parser @typescript-eslint/eslint-pluginnpm i --save-dev prettier eslint-config-prettier eslint-plugin-prettier
Create or edit the file .eslintrc.json with the following content:
This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.
For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai
Thank you everybody, Your comments makes it better
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"