Gabe Romualdo

Gabe Romualdo @gaberomualdo

About: See many of my blog posts here on DEV.

Joined:
Aug 11, 2018

Gabe Romualdo
articles - 35 total

Random Seed in JavaScript and Node.js

Random seed is a method of initializing random number generators using an initial seed value. Random generators with the same seed will output the same pseudo-random results. I found this method to be particularly useful when developing a game I'm working on, which has a random 'Daily Challenge'. In this case, random seed can be useful to select a random game using the current date as a seed. Seed random is one of a few features that is present in most major programming languages but is not available out-of-the-box in JavaScript. It can be incredibly useful in a wide array

Learn More 34 2Mar 26 '21

An Algorithm to Swap Two Variables Synchronously, Without Creating a Temporary Variable

Let's say you want to swap the values of two integer variables, a, and b. Simply setting a equal to b and then b equal to a does not work, since a and b would just end up both equaling the initial value of b. So, typically, you'd create another variable - let's call it c - and set that variable to the value of a, and then do something like this. This is very simple, but the extra variable is not actually necessary. Note that some programming languages, for example Python, provide the ability to swap two variables in

Learn More 29 11Mar 24 '21

How to Set Up Rate Limiting and Rate Slowing Down in Express.js

Rate limiting is the process of preventing repeated requests to a server in effort to remove spam requests. Typically, a limit is set, such as 200 requests to the server per minute, and any IP address that exceeds that limit will be blocked from making requests for a set period of time. Rate slowing down is the process of slowing down server responses to an IP that has been sending too many requests. For example, the slow down limit could be set to 200 requests per minute, and an extra 2.5 seconds more response time could be added for each

Learn More 23 0Jan 12 '21

Programs to Compute Trig Functions in Python, JavaScript, & Perl (with Maclaurin Series)

Have you ever wondered how your computer calculates certain mathematical functions, like division, or trigonometric functions like sine or cosine? Well, for some of these mathematical functions, there exist useful formulas to calculate very accurate results pretty easily. I've written programs to implement these two computations in three major scripting languages: Python, JavaScript, and Perl. These programs do not include any built-in trig functions or other utilities except the use of the in-built π constant in some cases. All code is CC0 licensed. The approach I used creates a generalized function called computeSeries which takes in x as the number

Learn More 26 5Dec 31 '20

How to Use the HTML5 Gamepad API (with complete examples)

The HTML5 Gamepad API is one of the more exciting HTML5 APIs in my opinion. The API allows browser games and sites to take input from real game controllers connected to the user's machine. Hundreds of game controllers are supported, both wireless and wired, including Xbox One controllers, PS4 controllers, and more. In this article, I'll provide a full explanation of the many features that the Gamepad API offers, with examples in JavaScript. Information on browser support, gamepad button codes, taking input from the gamepad sticks, and more is included.

Learn More 45 1Dec 15 '20

How to Schedule Cronjobs in Python

Cronjobs are tasks that can be run periodically, such as every five minutes, or every day at midnight, or even every Friday at noon. Cronjobs have a number of different use cases, and are widely used in many notable codebases. Many hosting servers have existing ways to set up cronjobs, but if you don't have that capability, you may want to go for a different solution. I'll explain how you would go about creating cronjobs in Python, in which a Python function, program, or system command can be run periodically, whether that be every day, every few minutes, or even

Learn More 34 0Dec 12 '20

How to Generate the Sierpinski Triangle in Vanilla JavaScript with HTML5 Canvas

The Sierpinski triangle is a famous mathematical figure which presents an interesting computer science problem: how to go about generating it. In this article I'll explain one method of generating the Sierpinski triangle recursively, with an implementation written in Vanilla JavaScript using HTML5 canvas.

Learn More 31 5Nov 21 '20

Performance of AI Algorithms in Playing Games — Empirical Evidence From Jupiter, My 2048 AI

I recently worked on an open source project called Jupiter, an online AI written in JavaScript to beat the popular online game 2048. In this article, I'll be analyzing the performance and speed of Jupiter's algorithm with empirical data, and note potential improvements made to the algorithm and its JavaScript implementation on the web. I ran 50 trial games with the AI at 200 simulations per move in about 34 minutes (avg. 40.8s/trial), storing data after every move.

Learn More 21 0Oct 11 '20

I Built Jupiter – A Machine Learning Based 2048 AI that Runs on the Web

Today I'm proud to release my online 2048 AI, Jupiter. Jupiter uses a machine learning method called the Monte Carlo Tree Search (MCTS) algorithm. I've released an article detailing the algorithm and implementation used in Jupiter: Using the Monte Carlo Tree Search (MCTS) Algorithm in an AI to Beat 2048 (and other games). Jupiter (formerly known as Jacob) started as a small AI project in January 2018. I got the idea of using Monte Carlo simulations and search trees as a method to play 2048 from this StackOverflow answer.

Learn More 37 0Sep 13 '20

Using the Monte Carlo Tree Search Algorithm in an AI to Beat 2048 (and other games)

I recently worked on an open source project called Jupiter, an online AI to beat the popular online game 2048. In writing this AI, I decided to use a machine learning method called the Monte Carlo Tree Search (MCTS) algorithm. Monte Carlo algorithms like the one used in Jupiter have been used in several notable AIs, including DeepMind's AlphaGo, which famously beat the Go world champion in May 2017. In this article, I'll explain: How and why the Monte Carlo method works; When and where Monte Carlo algorithms can be useful; How I used the Monte Carlo method in an

Learn More 54 0Sep 13 '20

How to Parse XML in Python

I recently spent a few hours refactoring some of the backend code on this site. In changing the backend, I wanted to make sure the refactored code worked the same way as my old code. To do this, I wrote a unit test in Python that sent a request to every URL on my site running the old backend code and the corresponding URL with my local server running the new code, to make sure they worked exactly the same.

Learn More 28 0Aug 16 '20

Build and Deploy a Discord Bot with Node and Discord.js in 5 minutes

Discord bots can be useful in doing a variety of things like playing music in a voice chat, or sending automated announcements when a Youtuber releases a new video. I'm active on several Discord servers myself and have always wanted to build my own Discord bot. After building, deploying, and using my own bot for over a month now, I've written this article as a starting point in building a basic bot and moving from there. We'll be building a bot that does something pretty simple: solves math equations. Users will be able to send a message on any channel

Learn More 34 0Aug 8 '20

How to Create a Beautiful Custom Scrollbar for Your Site in Plain CSS

Custom scrollbars on the web can make a site or design stand out. They can help in portraying key design aspects of a site, whether that be a specific color or a particular style. For example, the scrollbar at Outlook.com's web app portrays a very minimalist style. CSS-Tricks' scrollbar shows their signature orange and pink look. In this post, we'll be building a minimalist custom scrollbar, similar to that on the Outlook.com web app.

Learn More 118 10Aug 1 '20

AP Test Submission Problems Show Lack of Developer Adoption of .HEIC File Type

Due to lockdown and quarantine in numerous countries, this year's AP tests were moved to an online platform created by College Board, the creator of the AP program and other tests such as the SAT. In most online AP tests this year, students were given 1-2 questions on the exam web app, and were given the option to submit either a photo of their work, a supported text file (ex: .txt, .docx), or copy and paste written text.

Learn More 24 1May 24 '20

I Built Coronavirus Live Monitor - stats, news, and WHO press releases on the virus all in one place

Today, I am proud to release my latest web app and project: Coronavirus (COVID-19) Live Monitor, your hub for news and information on the Coronavirus outbreak. The code can be found on the GitHub repo. Go check it out!

Learn More 52 10Mar 21 '20

IIFE's (Immediately-Invoked Function Expressions) in JavaScript Explained in 3 Minutes

Global variables can cause serious problems and bugs in large-scale projects and web apps. IIFE's solve this problem by wrapping code in an immediately invoked function, so that no global variables are created, but the code still runs without having to be directly called. For smaller sites and scripts, I would personally simply recommend actively trying to use IIFE's whenever possible, and limiting global code. I personally do use global variables in some basic sites for brevity, but it's important to have a clear understanding of what your code's global scope looks like and what sorts of unexpected problems could

Learn More 53 5Feb 29 '20

Create a Reading Scroll Progress Bar for Your Blog in JavaScript and CSS

I just recently added a fun little feature on my website: a progress bar when reading blog posts. The bar would show how far users have progressed in reading a post, from 0% at the beginning to when a user finishes reading at 100%. This little feature has become particularly popular among other blogs and Wordpress themes in recent years.

Learn More 397 12Feb 5 '20

CSS Variables Explained in 2 Minutes with an Interactive Demo

CSS variables have been around for quite some time now, but are nevertheless extremely useful. The value of a variable can be just about anything, from pixel values to colors to linear-gradients. You can use a variable almost anywhere by wrapping it in a var function.

Learn More 87 5Jan 27 '20

JavaScript `use strict` Explained in 2 Minutes

In general, normal JavaScript allows for code that is badly written and includes bad syntax. But, use strict solves this problem. Introduced in ES5, the use strict directive provides a way to tell the interpreter to turn badly written JavaScript into errors.

Learn More 108 6Jan 17 '20

I Built Daily Developer Jokes and the First Ever DEV Bot

Today I am proud to release my latest project -- a website and the first ever DEV bot (as far as I know), called Daily Developer Jokes. The Daily Developer Jokes bot will post programmer humor and jokes every day at 8:00 AM (EST).

Learn More 103 12Jan 12 '20

Hello World in LOLCODE: A Very Peculiar Programming Language

LOLCODE is an esoteric programming language, a type of programming language which is defined by the Esolang Wiki as follows: an esoteric programming language is a computer programming language designed to experiment with weird ideas, to be hard to program in, or as a joke, rather than for practical use.

Learn More 13 0Jan 11 '20

3 Modern CSS Features in 2 Minutes

A list of three modern CSS features explained in ~2 minutes reading time. Features include: CSS clip paths, CSS blend modes, and CSS filters.

Learn More 178 6Jan 3 '20

2019 Developer Rewind / Year in Review: The End of a Decade 🎉, the End of an Era?

The developer world is changing quickly. New tech is quickly rendering old languages and frameworks useless, and the hype for new stuff such as WebAssembly, AI, and cryptocurrency is growing quickly. More developers are emerging faster than ever, and this decade could mark the end of an era in programming and the start of a new one.

Learn More 50 3Dec 24 '19

5 Strange Yet Funny Things That Only Happen in JavaScript

JavaScript is a weird language. It's an object-oriented language, but for many years it never had classes. It was built for the browser, but now it can also run on a server and work with the filesystem. Over the years I've seen some pretty peculiar and equally pretty funny things, that will only work with JavaScript. Here are 5 of them.

Learn More 134 5Dec 15 '19

Windows vs MacOS vs Linux: My Story (and share yours too!)

I have used all three operating systems in my lifetime. When I used Windows it felt too bloated and I missed Bash, my Linux experience was really positive but too many apps didn't support the platform, and so I am sticking with MacOS for now. Every developer's needs are different depending on what they are using their machine for. What OS are you using and why?

Learn More 50 27Dec 12 '19

How I Moved a Step Closer to Clean CSS and How You Can Too (with the BEM Methodology)

As your site grows with more pages and features, your CSS can quickly become confusing. BEM is a way to help mitigate that confusion.

Learn More 286 19Dec 4 '19

Building the Flipping Card Animation in Plain CSS

The flipping card animation is a quick way to make your site stand out as something modern. With newer CSS features such as the perspective property, we can make this animation pretty quickly and easily, yet maintain its eye-catching effect.

Learn More 172 1Nov 26 '19

Who are your favorite writers here on DEV?

Who are some people whose posts on DEV you particularly enjoy?

Learn More 70 16Nov 23 '19

A Quick Script to Find Broken Links on Your Site 🎯

It seems like almost every other click on the internet ends up in an error 404 page. So, I've built an automated program to find broken links.

Learn More 71 5Nov 10 '19

Celebrating the Internet at 50 Years: A Brief History of How We Got Here

50 years ago, the first ever message was sent using the Internet. Here's a brief history of what's changed since then.

Learn More 57 0Nov 6 '19