Home
David Angulo - Software Engineer
Cancel

Force HTTPS website in Cloudflare

If you installed an SSL on your website, you want it to be accessed on https rather than http. If you are also using Cloudflare I will show you how I forced my website to use https. Step 1: Login ...

Convert Blob to base64 in JavaScript

I usually pass files as base64 string to my REST APIs to upload them. Here is my go to utility function that converts blob to base64. function base64FromBlob(blob) { return new Promise((resolve...

Use Trix WYSIWYG editor in Next.js

Trix editor have been my go to WYSIWYG editor on both React and non-React projects, sometimes I am required to use it on a Next.js project, encountered some hiccups but manage to make it work with ...

Whitelist domain in JavaScript

I recently migrated this blog from WordPress to Jekyll and I currently host this blog for free at DigitalOcean App Platform. If you’re DigitalOcean App Platform you can access your website via som...

Redirect 404 pages in JavaScript

I recently migrated this blog from WordPress to Jekyll but due to the differences in permalinks, some posts now appear as 404. My old permalink for post is /:slug while it’s now /posts/:slug. I cu...

Pretty print data in Ruby

In the previous post we have learned to pretty print JSON in JavaScript. Now we’ll try to do the same with Ruby. As a Rails developer, I have been dealing with Rails console almost every day, tryi...

Attach file URL on ActiveStorage Rails

In a past post, we have learned to attach base64 file on ActiveStorage. Now we will learn to attach a file URL to ActiveStorage. Use case In my current job, we maintain REST APIs consumed by 3rd p...

Pretty print JSON in JavaScript

There are times that I use JSON.stringify to print my JSON just to see its contents. When the object is large it gets tedious to look at very fast, especially when dealing with array of objects. L...

DRY by reading .ruby-version in your Gemfile

Most Ruby projects have a .ruby-version file that is used by different version managers to automatically switch Ruby version based on the content of that file. Very useful if you have many projects...

Get the filesize of base64 file

In the previous post, we have learned to attach a base64 file on ActiveStorage in Rails. The another dilemma that I have encountered is how to validate the filesize of the uploaded files that are ...