Skip to content

Instantly share code, notes, and snippets.

>> 30.days.from_now
=> Sun, 13 Sep 2015 17:39:30 BRT -03:00
>> 30.days.from_now.class
=> ActiveSupport::TimeWithZone
>> Date.today + 30
=> Sun, 13 Sep 2015
>> (Date.today + 30).class
=> Date
@debborafernandess
debborafernandess / install_mysql_5x.md
Last active March 22, 2017 17:53
Install and run MySQL 5.7
date = Date.parse('2017-06-18')
report = File.new("nps_#{date}.csv", 'w')
report << "Location, Count\n"
LocationGroup.find(25).all_locations.enabled.map do |location|
count = Survey.ordered.
in_range(
date.to_date.beginning_of_day,
date.to_date.end_of_day
yesterday = Date.parse('2017-06-21')
this_in_last_week = Date.parse('2017-06-21') - 7
report = File.new("exportacao.csv", 'w')
report << "Location, #{yesterday.strftime('%d-%m')}, #{this_in_last_week.strftime('%d-%m')}, \n"
locations_br = Country.find_by(name: 'Brasil').locations.active
locations_br.each do |location|
new_access = location.accesses.by_period(yesterday.beginning_of_day, yesterday.end_of_day).count
old_access = location.accesses.by_period(this_in_last_week.beginning_of_day, this_in_last_week.end_of_day).count
Install
- https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/
setup docker as root ( to do not use sudo )
>
Create the docker group.
$ sudo groupadd docker
Add your user to the docker group.
$ sudo usermod -aG docker $USER
@debborafernandess
debborafernandess / update_free_days.rb
Last active August 31, 2017 19:58
Atualiza os dias de free days de acordo com o expires_at da PurchaseAddon
purchase_addons = PurchaseAddon.where.not(free_days_expired_at: nil)
purchase_addons.update_all(free_days: 30)
@debborafernandess
debborafernandess / retry_daily_report_cache.rb
Created September 18, 2017 21:21
Rodar o relatorio diario para as unidades que nao rodaram
str_date = '2017-09-16'
locations_cached_ids = DailyReportCache.where('reference_date = ?', str_date).map &:location_id
active_locations_ids = Location.active.map &:id
location_ids = active_locations_ids - locations_cached_ids
location_ids.each do |location_id|
parsed_date = Date.parse(str_date).strftime('%d/%m/%Y')
# Gate ñ está expportando acesso: ?
# Addon não cancela:
# Ver se tem Location::Addon criado para a unidade / addon, muitas vezes no tem, mas tem no PurchaseAddon
# se precisar cancelar manualmente
user = User.find(x) # o solicitante do tkt
cancelling = PurchaseAddonCancelator.new(purchase, addon, user)
cancelling.send :transaction
Steps:
- Na AWS, na instancia do `RDS DB`, ver o DNS da instância do banco
- Pegar no `database.yml` o user e password do banco da aplicação
- Rodar o comando `mysqldump -u user -h 'DNS_DA_INSTANCIA_DO_BANCO' DATABASE -p > dump.sql
- Informar a senha da aplicação quando for exigida a senha do banco.
@debborafernandess
debborafernandess / install-gm-w-librvg.sh
Created January 5, 2018 17:13 — forked from tavinus/install-gm-w-librvg.sh
Installs ImageMagick --with-librsvg on Amazon Linux
# With this I was able to successfuly install everything
# on a x86 (32-bit) instance of Amazon Linux.
#
# You should probably not run this script
# It is a much better idea to use this as an Install guide
# Just follow it down, use your tab and be happy
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig
export PATH=/usr/bin:$PATH
export LDFLAGS=-L/usr/lib64:/usr/lib