Add Array of Types in a Column using Postgres and Rails

Recently I found a nice feature when defining a column on migrations, is to use array option in the creation of a column: class MyMigration < ActiveRecord::Migration[5.2] def change # Defines a column that stores an array of a type. add_column :transactions, :categories, :string, array: true, default: [] end end With this on categories you can storage an array of values, it’s useful instead of use jsonb because as json you may also need to create the key to store values (hash)....

October 14, 2019 · 1 min · Carlos Ramos

Install yarn if you are using Nodejs with ASDF

I’m using ASDF to install any language that I needed, so problems become when I have to install yarn a js package manager but to do that has a lot of ways of install yarn and problems increasing with nodejs installed using ASDF more problems become using the brew recipe and it doesn’t work with ASDF. I found a practical solution: is to install a separate yarn recipe into ASDF....

September 24, 2019 · 1 min · Carlos Ramos

Configure and install last elixir-ls in Neovim

The last version of ElixirLS have a lot of improvements, for example a new robust code suggestion provided by elixir-sense, intellisense with code documentation and other larger changes, but now i didn’t see an actual release to use it, so in this post we will clone the last repo, compile and will install in our local dev to take advantage of these new features. First clone and generate the executables of elixirLS:...

September 22, 2019 · 1 min · Carlos Ramos

Upgrade to Latest Version on ASDF

ASDF is an incredible version manager, to install/upgrade to latest version available of an language you can do the following steps: asdf list-all <language> this show all of the versions available to install, select the latest: asdf install <language> x.y.z and edit if you have a global ~/.tool-versions to use that version everywhere: <languaje> x.y.z real example to upgrade to latest version of erlang (10/17/2019): asdf list-all erlang asdf install erlang 22....

September 17, 2019 · 1 min · Carlos Ramos

Enable Prettier in Ember templates

Prettier is an opinionated code formatter, has built-in a lot of code formatters for languages, one of that is for handlebars (glimmer/mustache) but is hidden by default, to enable we only need to do this: create a .prettierrc in your home (~) with : { "overrides": [ { "files": "*.hbs", "options": { "parser": "glimmer" // ... other custom configurations } } ] } and now you can use in your favorite editor or simple use directly with the CLI, for example:...

September 16, 2019 · 1 min · Carlos Ramos

How to Show Hex Colors on Neovim

One thing that I like is to show HEX colors on css, html and even on javascript using NEOVIM, to do that I was using Colorizer plugin but now I switched to use vim-hexokinase and it’s asynchronous! to install you might need to install before go language: brew install go and this is my config: let g:Hexokinase_ftOptInPatterns = { \ 'css': 'full_hex,triple_hex,rgb,rgba,hsl,hsla,colour_names', \ 'html': 'full_hex,rgb,rgba,hsl,hsla', \ 'javascript': 'full_hex,rgb,rgba,hsl,hsla' \ } let g:Hexokinase_virtualText = ' ██████' watch all of my dotfiles...

September 12, 2019 · 1 min · Carlos Ramos

How to Manage Environment Variables

In many projects that i have been working I want to manage GLOBAL’s variables, so to do that use direnv. to install (MacOS): brew install direnv Now the project needs to create a file .envrc like this: # Stripe Credentials export STRIPE_PRIVATE_KEY="xxxxxxxxxxxx" export STRIPE_WEBHOOK_SECRET="xxxxxxxxxxxxxxxx" entering in that directory direnv asks to allow the execution and use of that variables, so: direnv allow . And that’s it! you don’t need a custom solution for every programming language....

September 12, 2019 · 1 min · Carlos Ramos

Create a Form With Two Actions on Activeadmin

In a project that already using Activeadmin I had the requeriment of modify the actual form to create a student, but without validating that, so the solution was create into the model of active admin form and declare the form with two actions, one with the clasical behaviour and other when passed the params[:managed] with a custom route ActiveAdmin.register InvestmentItem do # .. form do |f| f.inputs do f.input :student, as: :select, collection: User....

September 11, 2019 · 1 min · Carlos Ramos