my_phoenix_api
├── lib
│ ├── my_phoenix_api
│ │ ├── domain
│ │ │ ├── models
│ │ │ │ ├── user.ex # Domain logic (User entity)
│ │ │ │ └── post.ex # Domain logic (Post entity)
│ │ │ ├── services
│ │ │ │ ├── user_service.ex # Service for user-related business logic
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
--- | |
version: '2' | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:latest | |
environment: | |
ZOOKEEPER_CLIENT_PORT: 2181 | |
ZOOKEEPER_TICK_TIME: 2000 | |
kafka: |
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
# Install protobuf | |
# more info: https://grpc.io/docs/protoc-installation/ | |
sudo apt install -y protobuf-compiler | |
# Install curl for GRPC support via ASDF package manager | |
asdf install grpcurl 1.8.0 | |
# Ensure protobuf available |
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
psql -h localhost -U postgres -d postgres -c "copy (select datname from pg_database where datname like '%nominapp_api%') to stdout" | while read line; do | |
echo "$line" | |
dropdb -i "$line" | |
done |
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
# pass the backup to container | |
docker cp latest.dump quincename_db_1:/var/lib/postgresql/data | |
# exec backup | |
docker exec quincename_db_1 pg_restore --no-owner --verbose --clean --no-acl -U postgres -d quincename_development /var/lib/postgresql/data/latest.dump | |
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
sudo docker pull postgres:latest | |
mkdir -p $HOME/docker/volumes/postgres | |
sudo docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres |
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
class RenameReadColumToState < ActiveRecord::Migration | |
def change | |
add_column :messages, :state, :integer, default: 0 | |
execute "UPDATE messages SET state = CAST(read AS INTEGER);" | |
remove_column :messages, :read | |
end | |
end |
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
require 'csv' | |
data = [{'a' => 'aaaa', 'b' => 'bbbb'}] | |
column_names = data.first.keys | |
s=CSV.generate do |csv| | |
csv << column_names | |
data.each do |x| | |
csv << x.values | |
end | |
end | |
File.write('the_file.csv', s) |
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
template = ERB.new(@template) | |
template.def_method(LayoutRenderer, 'render') | |
result = LayoutRenderer.new.render do | |
ERB.new(@content).result(binding) | |
end | |
File.open('tmp/payslip_filename.html', 'w+') do |f| | |
f.write result | |
end |
NewerOlder