ruby Active Model Serializer vz Jbuilder vz Rabl vz Grape-entity for rendering JSON When architecting an API only application one the of the most important points of discussion among the team members is which framework to use ? * Should we be using Rails and render JSON ? * Should we be using Grape ? * Should we be using Rails-API ? Also, how are we gonna format the JSON
ruby Error handling with Grape, Rails and ActiveRecord CanCan I have been working on a project developing the backend API using Rails and Grape. One fine morning I pulled the latest code from the git repo that my colleague wrote, and was going to review the code. As usual, the first thing I did was to run the Integrations
grape Using helper methods and helper modules in Rails Grape to keep the code DRY I was working with a Grape API and got into a situation where I was kind of reimplementing some methods on more than one mounted API. So naturally, I wanted to refactor the code, keep it DRY and extract it as helper methods and eventually into helper module. So here
API JSON Web Tokens explained and how to use JWT in authentication with APIs Introduction Over the last few years web application development has seen drastic changes, with the front-end frameworks coming to the scene, the popularity of hybrid applications, mobile first strategy, rising demand for SPAs, Microservices etc. In older times, both the frontend and the backend would be in a single place,
docker Docker difference between run, cmd, entrypoint commands If you have built a docker image, you would be familiar with the commands RUN, CMD, ENTRYPOINT. While some of you know what these means, where to use those and when to use those, there are some who might not know the exact difference between those commands. These commands are
elixir Behaviours in Elixir explained Behaviours provide a way to define an interface which a module can implement. A module declares that it implements the Behaviour with the @behaviour annotation. The functions in the modules implementing the behaviour will be checked at compile time to see if they match the function specifications in the behaviour
elixir require vz import vz use vz alias directives in Elixir One of an essential feature of a language when developing software is to reuse the code or the modules. What are directives ? So directives are a way via which we can reuse our code, import it and use it with other modules. What are the available directives in Elixir When
git Install, configure and use git hooks to automate your workflow with distributed team My team [https://redpanthers.co] uses Git as the center of our development process, leveraging all those cool features git provides us - git workflow, feature branching, switching branches for code reviews, Pull Requests and all such cool stuff. Using git is an integral part of our workflow, which means
rails Rails : Devise : Send different Emails for Confirmation based on the presence of attribute or parameter So what am I up to today? - I thought of scribbling down some pieces of code that I wrote to help one of my interns in my company to help complete a task. I was juggling with my daily work and I suddenly got a ping in our slack
osx Share button not working in Safari on OSX El-Capitan Share button not working in Safari on OSX El-Capitan Since upgrading to the new El Capitain I have not been able to use the share button, one of the features that I liked the most with Safari. The strange thing was that it was working on my mac mini, while
rails Testing carrierwave file uploads with RSpec and FactoryGirl. TLDR; In this blog post, I am gonna focus only on testing carrierwave. So if you are looking for instruction on installing/setting up carrierwave in your project I would suggest you looking at the carrierwave's wiki over here [https://github.com/carrierwaveuploader/carrierwave/wiki]. So let's assume we have
elixir fizzbuzz in elixir using OTP and GenServer Speaking of Erlang/Elixir the first thing that comes to mind is OTP. The erlang veterans would definitely playing around with it on a daily basis, but to the novice, it would sound a relatively strange term, and would be wondering what this is. So I thought of scribbling down
til Some best practices while developing meteor.js apps Recently I was working as a consultant for a meteor.js app, reviewing the entire codebase, and came across some of the common mistakes the developer makes when writing his/her first meteor.js app. Though some of them are trivial, some others can have bigger consequences on the security
shell RVM error when starting zsh __rvm_cleanse_variables: function definition file not found I was getting this error when opening new zshell: __rvm_cleanse_variables: function definition file not found command not found: rvm_error Running the following solved the problem: rm -f ~/.zcompdump* Note: The * is incase there are multiple .zcompdump files. So what goes behind the scenes: ZSH uses compinit to
shell Run the last shell command with sudo I often an into the situation where I type in a long command, hit enter and then figure out that I needed to run that command as root user. Instead of typing the same command with sudo prefixed we can do the same thing using a shortcut. To run the
shell How do I get a process to run in the background? Simple / Usable things first If you want a start script without much effort, you could use the upstart service. See the corresponding manual page and /etc/init/*.conf for examples. After creating such a process you can start your server by calling service my server start If you want more
docker Remove Untagged Images From Docker To delete all untagged images: docker rmi $(docker images -q --filter "dangling=true")
til Docker: Remove all images and containers To delete all the containers we have created so far: docker rm $(docker ps -a -q) To delete all the images in docker: docker rmi $(docker images -q) NB: Deleting docker containers and images is not reversible. Make sure you know what you are upto. Ref: Docker Issue [https://github.
meteor Restricting users signup to a particular domain in meteor.js If you want to restrict the user registration to a particular domain only, say for e.g.: codingarena.in, then you can do the same by adding the following code: Accounts.config({restrictCreationByEmailDomain:'codingarena.in'});
git Git fatal: remote origin already exists One of my colleagues was facing an issue with git, trying to add a remote to the git repo. ➜ repo_name git:(master) git remote add origin [email protected]:username/repo_name.git fatal: remote origin already exists. As the error message indicates, there is already a remote configured
database How to Fix [ERROR] Unknown/unsupported storage engine: InnoDB After playing around with my MySQL configuration file in my docker container, MySQL was throwing a weird error, and was failing to start. I checked the error logs and found an entry in the error log. [ERROR] Plugin ‘InnoDB’ init function returned error. [ERROR] Plugin ‘InnoDB’ registration as a STORAGE
meteor Format time using moment.js in meteor If you want to format a time field from you database, say for e.g.: createdAt, the following helper can be used. UI.registerHelper('formatTime', function(context, options) { if(context) return moment(context).format('MM/DD/YYYY'); }); An alternate way would be to write a helper for one particular view,
meteor Masonry in meteor.js Code snippet to make masonry work with meteor.js Template.activity_feed.rendered = function () { $('.masonry-container').isotope({ itemSelector: '.item', layoutMode: 'masonry', masonry: { columnWidth: 200, gutterWidth: 5 } }) };
ruby Visualise your Gemfile dependencies If you ever wanted to visualise the gem dependencies of in your ruby/rails app, then bundler is there for rescue. Type in the following from your terminal: bundle viz Viz generates a PNG file of the current Gemfile as a dependency graph. Viz requires the ruby-graphviz gem (and its
ruby Connecting Ruby & Active Record Without Rails require 'active_record' require 'mysql2' # or 'pg' or 'sqlite3' # Change the following to reflect your database settings ActiveRecord::Base.establish_connection( adapter: 'mysql2', # or 'postgresql' or 'sqlite3' host: 'localhost', database: 'your_database', username: 'your_username', password: 'your_password' ) # Define your classes based on the database, as always class YourModel < ActiveRecord: