Skip to content

Instantly share code, notes, and snippets.

View bonafernando's full-sized avatar
🏠
Working from home

Fernando Wolf Bona bonafernando

🏠
Working from home
  • independent contractor providing solutions to international clients
  • Porto Alegre
View GitHub Profile
@bonafernando
bonafernando / to_csv.rb
Created August 13, 2019 18:18
Rails controller snippet to send csv report of a query
require "csv"
@query = Model.where(field: "condition")
result_csv = CSV.generate(headers: true) do |csv|
csv << @query.first.attributes.keys
@query.find_each do |row|
csv << row.attributes.values
end
end
send_data(result_csv, filename: "model_report_#{Date.current.to_s}.csv")
@bonafernando
bonafernando / Dockerfile
Created May 5, 2016 19:14
Docker with MongoDB in a brand new Ubuntu 16.04
# Pull base image.
FROM ubuntu:16.04
MAINTAINER W.Bona Fernando <fernando.bona@hp.com>
MAINTAINER Agliardi, Douglas <douglas.agliardi@hp.com>
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
RUN echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
RUN apt-get update && apt-get install -y mongodb-org