Base64 has been my go-to encoding when uploading files from my external front-end apps such as React Native to my Rails APIs. It’s a simple way to represent a binary data as string, where string i...
Check if Sidekiq is running
There is a simple command to check whether sidekiq is running or not. $ ps aux | grep '[s]idekiq' If it’s running you should get something like the following as a response: davidangulo 5526...
Check if Redis is running
Redis CLI There is a simple command to check whether redis is running or not. Just simply run the following command on your command line. $ redis-cli ping If it is running it should respond wit...
How to get statusbar height in React Native
There are different ways of getting the statusBarHeight in React Native and I will show some ways. Expo If you’re using Expo you can use Constants.statusBarHeight. import Constants from 'expo-con...
How to convert char to int in C/C++
I have encountered a problem when taking CS50’s Problem Set 1 where I need to convert a char number to int. Luckily there is an easy and clever way to do that. char_to_int function int char_to_i...
Simple PayPal checkout in Ruby on Rails using Orders API v2
Recently, PayPal archived most of their SDK repositories that uses v1 of the API and added a deprecation notice. This includes the PayPal-Ruby-SDK. In this tutorial, we would be moving away from P...
Remove all cookies in JavaScript
The following snippet allows you to remove all cookies in JavaScript (client-side). document.cookie.split(';').forEach((c) => {document.cookie = c.replace(/^ +/, '').replace(/=.*/, `=;expires=$...
Rails authentication with Devise
In this tutorial, we will be dealing with Rails authentication with Devise. If you don’t want to use Devise for authentication, you may refer to the article create basic authentication in Ruby on ...
Remove an element from array in JavaScript
The following snippets allow you to remove an element from array in JavaScript. Mutating Using pop let myArray = [1, 2, 3, 4, 5] myArray.pop() console.log(myArray) // [1, 2, 3, 4] Removes an el...
Add an element to array in JavaScript
The following snippets allow you to add an element to array in JavaScript. Mutating Using push let myArray = [1, 2, 3, 4] myArray.push(5) console.log(myArray) // [1, 2, 3, 4, 5] Adds an element ...