Skip to content

Instantly share code, notes, and snippets.


Elinaldo Monteiro elinaldosoft

View GitHub Profile
elinaldosoft /
Last active Feb 19, 2021
Filter dict is a method for search element in depth
In [1]: def filter_dict(data: dict, extract):
...: try:
...: if isinstance(extract, list):
...: for i in extract:
...: result = filter_dict(data, i)
...: if result:
...: return result
...: keys = extract.split('.')
...: shadow_data = data.copy()
...: for key in keys:
elinaldosoft /
Created May 5, 2020
Convert datetime to local date (Django)
import pytz
from django.utils import timezone
elinaldosoft /
Last active Mar 12, 2020
Dump MYSQL - How to make a dump and restore in Mysql

You may need to install this package

  • sudo apt install mariadb-client-10.1 or
  • sudo apt install mysql-client

mysqldump --host= -u username -p database > database.sql

Restore Backup

mysql -u user -p database < database.sql

elinaldosoft /
Last active Mar 5, 2020
Restore dump.rdb redis Mac OS X

Stop Redis

brew redis-server stop

Move backup to directory db redis

mv dump.202003050300.rdb /usr/local/var/db/redis

Backup dump.rdb

mv dump.rdb bk.dump.rdb

Rename restore backup to dump.rdb

mv dump.202003050300.rdb dump.rdb

Start Server

brew redis-server start

elinaldosoft /
Created Jan 28, 2020
Library not loaded: libcrypto.1.1.dylib
brew remove openssl
brew install openssl
ln -s /usr/local/Cellar/openssl@1.1/1.1.1d/lib/libcrypto.1.1.dylib /usr/local/lib
elinaldosoft / example.rb
Created Mar 27, 2019
Release deploy, sentry by capistrano 3
View example.rb
require 'net/https'
require 'uri'
require 'json'
namespace :sentry do
task :notify_deployment do
run_locally do
puts 'Notifying Sentry of release...'
uri = URI.parse(SENTY_URL)
http =, uri.port)
elinaldosoft / .pylintrc
Created Dec 11, 2018 — forked from sblask/.pylintrc
PyLint configuration file, initially generated with `pylint --generate-rcfile ` and then edited. See for disabled messages
View .pylintrc
# Specify a configuration file.
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
# Profiled execution.
from django.db import models, connection
class Assinantes(models.Model):
id = models.AutoField(db_column='ID', primary_key=True) # Field name made lowercase.
msisdn = models.BigIntegerField(unique=True, blank=True, null=True)
# faixaid = models.ForeignKey('Faixa', models.DO_NOTHING, db_column='faixaID', blank=True, null=True) # Field name made lowercase.
faixaid = models.IntegerField(db_column='faixaID', blank=True, null=True) # Field name made lowercase.
docnum = models.CharField(db_column='docNum', max_length=28, blank=True, null=True) # Field name made lowercase.
offeramount = models.DecimalField(db_column='offerAmount', max_digits=7, decimal_places=2, blank=True, null=True) # Field name made lowercase.
elinaldosoft /
Created May 9, 2018 — forked from daltonjorge/
Explicações de conceitos do Rails e outras infos úteis.

Active Record

É um design pattern que o Rails implementa a partir da gem ActiveRecord.

Serve para conectar a camada Model da aplicação com tabelas do database, para assim criar um modelo de domínio persistível, onde a lógica (Model) e dados (BD) são apresentados em uma única solução.

Já persiste no BD:

elinaldosoft / cors.conf
Created Aug 29, 2017
CORS on Nginx The following Nginx configuration enables CORS, with support for preflight requests.
View cors.conf
location ~* ^.+\.(ttf|oft|eot|woff|svg|woff2)$ {
if ($http_origin ~* (https?://[^/]*\[0-9]+)?)$) {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;