Skip to content

Instantly share code, notes, and snippets.

View enmachs's full-sized avatar
馃彔
Working from home

Enmanuel Chirinos enmachs

馃彔
Working from home
View GitHub Profile
@enmachs
enmachs / mongo_relations_test.rb
Created March 13, 2019 20:11
Example in case of many_to_many association
# Method
def has_many_mongoid(field, options)
raise ArgumentError, "inverse_of missing" unless options[:inverse_of].present?
foreign_key = "#{options[:inverse_of]}_id"
through = options[:through]
# register_dependent_pg field, options.delete(:dependent), foreign_key
has_many field, options
klass = (through ? through : options[:class_name]).constantize
@enmachs
enmachs / delayed_job_issue.md
Last active January 8, 2019 02:35
Delayed Job Issue

Runned RAILS_ENV=production script/delayed_job status in live server. Returns delayed_job: running [pid 17880]

Note: Delayed jobs keep being created

Probably method to apply into rails console on production: RAILS_ENV=production script/delayed_job restart Important: I don't how this command would affect DB records.

Referential info:

Mongo installion issues

  • Try run mongod, and got this:
2018-12-23T22:57:00.013-0400 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-12-23T22:57:00.016-0400 I CONTROL  [initandlisten] MongoDB starting : pid=3342 port=27017 dbpath=/data/db 64-bit host=thnkpd
2018-12-23T22:57:00.016-0400 I CONTROL  [initandlisten] db version v4.0.5
2018-12-23T22:57:00.016-0400 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2018-12-23T22:57:00.016-0400 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018
gem 'pg':
- bug: "You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application"
- solution: "sudo apt-get install libpq-dev"
# --- Soluci贸n para error de rmagick al bundle install
# checking for gcc... yes
# checking for Magick-config... no
# checking for pkg-config... yes
# checking for outdated ImageMagick version (<= 6.4.9)... no
# checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
# checking for Ruby version >= 1.8.5... yes
# checking for stdint.h... yes
# checking for sys/types.h... yes
# checking for wand/MagickWand.h... no
@enmachs
enmachs / sliceweekend_exercises.text
Last active May 30, 2018 02:08
Ejercicios previos al evento para practicar la l贸gica y habilidad para resolver problemas.
1. Dada una funci贸n que reciba por par谩metro (n1, n2), ambos valores enteros,
elevar el primer par谩metro (n1) a la n2 cantidad y verificar si el resultado
es m煤ltiplo de 3.
2. Dado un array de ciudades. ['New York', 'San Francisco', 'Austin', 'Seattle', 'Washington']
Crear una funci贸n que recorra cada una de ellas y sustituya las 'a' por 'x'. Imprimiendo
un nuevo array con las nuevas ciudades y la cantidad total de letras 'a' que fueron
sustituidas.
3. Funci贸n que retorne un booleano dependiendo si el n煤mero de 'x' es igual al n煤mero de 'y'.