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 FUNCTION insert_user_id() | |
RETURNS trigger AS $BODY$ | |
BEGIN | |
SELECT id INTO NEW.to_id FROM users WHERE email = NEW.to_email; | |
RETURN NEW; | |
END; | |
$BODY$ LANGUAGE plpgsql; | |
CREATE TRIGGER insert_article BEFORE INSERT OR UPDATE ON messages FOR EACH ROW EXECUTE PROCEDURE insert_user_id(); |
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
- Check out | |
- install modern terraform version | |
- ``terraform init`` | |
- get a Hetzner key, | |
- set it before run: ``` export TF_VAR_hcloud_token=...``` | |
- ``terraform plan`` | |
- ``terraform apply`` |
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
<%= form_with(model: team) do |form| %> | |
<div> | |
<%= form.label :name %> | |
<%= form.text_field :name, class: "input" %> | |
</div> | |
<div> | |
<%= f.select :user_id, {}, {placeholder: "Select user"}, {class: "w-full", data: { controller: "select", select_url_value: users_path }} %> | |
</div> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
... | |
</head> | |
<body data-controller="js"> | |
<%= yield %> | |
</body> | |
</html> |
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 Jobbable | |
extend ActiveSupport::Concern | |
# This concern allows model instances to run async jobs that depend on them. | |
# Calling #async_method_name will trigger the MethodNameJob | |
PREFIX = "async_" | |
included do | |
def method_missing(method_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
import { Controller } from "stimulus" | |
import SlimSelect from "slim-select" | |
import "slim-select/dist/slimselect.min.css" | |
import "../style/slimselect-customized.css" | |
export default class extends Controller { | |
connect() { | |
const limit = this.data.get("limit") | |
const placeholder = this.data.get("placeholder") | |
const searchText = this.data.get("no-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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", "6.0.0" |
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
CallDataRecord.find_each do |cdr| | |
next if cdr.file.attached? | |
cdr_url = "https://s3-ap-southeast-1.amazonaws.com/cdr.somleng.org/store/#{cdr.file_id}" | |
cdr.file.attach( | |
io: open(cdr_url), | |
filename: cdr.file_filename, | |
content_type: cdr.file_content_type | |
) | |
end |
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
// Visit The Stimulus Handbook for more details | |
// https://stimulusjs.org/handbook/introduction | |
// | |
// This example controller works with specially annotated HTML like: | |
// | |
// <h4>Tasks</h4> | |
// <div data-controller="nested-form"> | |
// <template data-target="nested-form.template"> | |
// <%= form.fields_for :tasks, Task.new, child_index: 'NEW_RECORD' do |task| %> | |
// <%= render "task_fields", form: task %> |
NewerOlder