Skip to content

Instantly share code, notes, and snippets.

View nmenag's full-sized avatar

Nicolas Mena nmenag

View GitHub Profile
@nmenag
nmenag / kafka-commands.md
Last active January 31, 2023 04:46
Kafka commands

docker-compose file

version: "2.2"
services:
  kafka:
    image: confluentinc/cp-kafka:latest
    container_name: kafka
    ports:
 - "9092:9092"
@nmenag
nmenag / docker-compose.yml
Created July 15, 2022 00:57 — forked from rmoff/docker-compose.yml
Docker-Compose for Kafka and Zookeeper with internal and external listeners
---
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
@nmenag
nmenag / install.sh
Created February 12, 2021 17:44
GRPC server configuration in elixir
# 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
@nmenag
nmenag / dropdatabase.bash
Created November 17, 2020 20:27
Drop multiples databases Postgres
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
@nmenag
nmenag / gist:09c3c60162ecf9fa0b12b762204da0df
Last active January 31, 2020 14:06
restore a postgres backup for a Docker app
# 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
@nmenag
nmenag / posgres-docker.sh
Created January 24, 2020 01:27
install and configuration postgresql on docker
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
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
@nmenag
nmenag / hash_to_csv.rb
Last active October 1, 2019 18:38
Script for save the hash data to CSV file
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)
@nmenag
nmenag / erb_layout.rb
Created July 10, 2019 20:17
using template with ERB class
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
@nmenag
nmenag / remove_braches.md
Created October 16, 2018 15:08
Remove all local branches