Skip to content

Instantly share code, notes, and snippets.


Max Ivak maxivak

View GitHub Profile
maxivak /
Last active Nov 2, 2020
Let's encrypt SSL certificates using certbot in docker

Directories on host machine:

  • /data/certbot/letsencrypt

  • /data/certbot/www

  • Nginx server in docker container

docker run -d --name nginx \
maxivak /
Last active Feb 22, 2019
Issue with Carrierwave, ImageMagick with processing svg files

Issue with Carrierwave, ImageMagick (or MiniMagick) with processing svg files


When uploading svg file with Carrierwave you may get an error:

Failed to manipulate with MiniMagick, maybe it is not an image? 
Original Error: `identify /tmp/mini_magick20190222-32759-1g7lnmy.svg` failed with error:

maxivak /
Last active Nov 27, 2020
Webpack, Yarn, Npm in Rails
maxivak /
Last active Jul 22, 2020
Datetime picker in Rails app

Date time picker in Rails app

There are several options to make Date input in Rails application:

  • Default inputs from simple_form
  • HTML 5 date input
  • Text input with jQuery UI Date time picker
  • Other plugins for date input with Bootstrap 4
maxivak /
Last active Oct 20, 2019
Rails: Audit Globalize translations
  • Globalize adds model translations to ActiveRecord models.
  • Audited is an ORM extension that logs all changes to your models.

Using Audited gem it will only logs changes to the base model and ignore changes to the translation table.

Below is how to add audited to the translation model.

Audited and Globalize

maxivak /
Last active Nov 21, 2017

Error logging

  • log errors

    • on disk on server
  • notify errors

    • notify to slack or email or using other system
maxivak /
Created Oct 22, 2017
Dockerize Rails app

Rails app in Docker

maxivak /
Created Oct 10, 2017
Bootstrap 4 tabs (pills) underlined

Bootstrap 4 tabs (or pills) rendered underline.

  • SASS:

_pills_underline_varibles.scss - edit styles using variables

$nav-pills-underline-link-active-color: $link-color !default;
$nav-pills-underline-link-hover-color: $link-hover-color !default;

$nav-pills-underline-bg:    transparent !default;
maxivak /
Last active May 14, 2020
Load code in libraries in Rails 5

Load lib files in production (Rails 5)

If you have your code defined in classes in lib/ folder you may have problems to load that code in production.

Autoloading is disabled in the production environment by default because of thread safety.

Change config/application.rb:

    config.autoload_paths << Rails.root.join("lib")
    config.eager_load_paths << Rails.root.join("lib")
You can’t perform that action at this time.