There are many HTTP clients that can be utilized in your Ruby applications such as Faraday, rest-client, httparty and Typhoeus. Many of these, however, are third-party implementations of Net/HTTP, which is part of Ruby’s Standard Library. This is the client that we will be examining today.
In order to start executing http requests, we will create a new ruby file and at the top, require the “net/http” gem.
The #get method allows us to simply retrieve data from a page:
page = URI('https://en.wikipedia.org/wiki/Main_Page')
response = Net::HTTP.get(page)
In the above code, we are passing the website…
When learning a new language, DSL or technology in general, keeping track of all the new commands can be a pain. Recently I’ve been learning Kubernetes, which is an open source system for deploying containerized applications. Learning this technology is hard enough, so I thought I would compile a short list of the most commonly used commands while working with Kubernetes. Commands for MiniKube, which is a version of Kubernetes that can be used locally on your machine, are included as well. …
Recently when attempting to deploy a Rails app using Docker and Kubernetes, I came upon an error early on, telling me that Docker is incompatible with Windows Subsystem for Linux 1, and I need to upgrade to Windows Subsystem for Linux 2. I run the following command in PowerShell to see which versions of WSL are being used by with applications:
PS C:\Users\user> wsl.exe -l -v
NAME STATE VERSION
* Ubuntu Running 1
docker-desktop Running 1
docker-desktop-data Running 1
In this case, both Ubuntu and Docker are running WSL1. To upgrade Ubuntu to to WSL2, we will follow the template:
Recursive functions, simply put, are functions that call themselves. Fibonacci numbers, for instance, are a sequence of numbers in which each successive number is the sum of the previous 2 numbers. The first few numbers in the sequence are 1, 1, 2, 3, 5, 8, 13, 21, 34, + … n. The following is a simple method that calculates the nth Fibonacci number:
return n if n < 2
fib_calc(n-1) + fib_calc(n-2)
Sending emails in Rails is quite simple and intuitive thanks to ActionMailer. In this 2 part tutorial, we will cover how to send emails in Rails 6 using ActionMailer and Sendgrid. In part 1, we will cover how to set up mailers for user account sign up notification. In part 2, we will configure Sendgrid in order to send emails in a production environment.
Mailers in Rails function very similarly to controllers. When we generate a mailer we create associated views as well. We can also utilize instance variables that are accessible in the views, where views for mailers are…