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 ...
Dynamically import class with no SSR in Next.js
In this tutorial, I will show you how to dynamically import class with no SSR in Next.js. Probably you already have seen this Next.js documentation regarding dynamically importing component with n...
Test Doubles Stubbing & Mocking
What are test doubles? Test doubles are a substitute for production apps used for testing purposes. There are at least five (5) types of test doubles according to Gerard Meszaros but we are going t...
How to use FullCalendar in Next.js
This tutorial has been updated for React v18, Next.js v13, and FullCalendar v6. If you are looking for the older version of this tutorial, you can access it here. In this tutorial, we would be...
Rails file upload using ActiveStorage
In this tutorial, we would be learning to upload files in Rails. Rails file upload have become easier since the release of Active Storage. It allows us to handle file uploads without using any gem....