Fixing Golang GIN-debug WARNING Headers were already written.

/ Software Development / Golang

If you’re just getting your hands dirty with Golang, and specifically with Gin, which is a web development framework, you might come across this specific warning: [GIN-debug] [WARNING] Headers were already written. Wanted to override status code 400 with 200 Most likely, you’re trying to use BindJSON on a property that does not exist. Here’s an example. I’m building an analytics solution for weremote.eu and for its pageview counter, I wanted to also be able to pass in extra props besides the usual props such an event would carry.

Read more →

How to fix GitHub Actions error docker build requires exactly 1 argument.

I’ve been working on migrating my the remote jobs platform I built in the past months from weremote.ro to weremote.eu. The platform’s backend is a GraphQL API built over Express.js which runs inside a Docker container. I was initially building the image myself, whenever I pushed some changes worth deploying to production, but I very quickly switched to GitHub Actions once I learned about this feature. With this migration to .

Read more →

Stop storing JWT in LocalStorage! And stop using JWT.

I’ve been developing single-page web-apps for a while now, and it’s gotten into my habit to use LocalStorage to store JWTs. The reason I used JWT was to embed data about the user, and keep it on the client-side, to authenticate (identify) requests/users. Figured out a while ago that it was wrong. On many levels! TL;DR — don’t use JWT and don’t store sensitive data in LocalStorage For starters, it’s not okay to store auth data in LocalStorage.

Read more →

How to check if a JavaScript object is empty

/ JavaScript / Software Development

I had the following snippet of code and wanted to log an error only if whatever the catch block receives is an actual object with actual values. Needed a solution. try { const attr = await this.contract.methods.attributes(index) .call(this.defaultConfig); const identifierText = Web3.utils.hexToUtf8(attr); return identifierText; } catch (attributeNotFoundError) { logger.error(`Attribute not found`, attributeNotFoundError); return null; } The code calls a smart contract getter, using Web3.js, retrieves whatever the return value is, and returns its plain text representation.

Read more →

What do the three dots (...) mean in JavaScript?

/ JavaScript / Software Development

The title of the article is from a question I was asked to answer on Quora. Below, is my attempt to explain what do the three dots do in JavaScript. Hopefully, this removes the fog around the concept, for people who will find this article in the future and have the same question. Updates Added more explicit usage of Array.prototype.slice.call(arguments). Thanks @gabriel for commenting and providing feedback. Added resources section with useful links.

Read more →

How to manage i18n translation files for web applications

/ Software Development

Most software developers know that keeping hardcoded strings in your code is bad form. For the most part of our working life, we pester our colleagues to extract stuff in variables, make strings constants, so on and so forth. Text/translation file management became an interesting topic for me in the second year of my software development career. I was building apps that had a lot of repetitive text and I was frustrated because I couldn’t use the same approach I had with my code, that of extracting strings into constants.

Read more →

Environment variables in Webpack builds vs. Node.js apps

/ Software Development / JavaScript

I recently had a discussion with an off-shore team mate who was supposed to add a new environment variable to a client-side app and re-deploy it. He had some trouble doing this, and after talking to him and illustrating how frontend apps use env vars in contrast with Node.js APIs, he finally understood the nuances His misunderstanding was about the way Webpack manages environment variables. Being an ops person, he assumed that environment variables work the same way they do for our Node.

Read more →

Here's why your software developers are delivering so slow.

/ Opinion / Software Development

So here’s the deal. I started listening to some podcasts related to content marketing and social media, since I want to up my game a bit. One of the things that bothered me the most is the continuous bickering of the podcast hosts about how they avoid to go to developers because it always takes a lot of time to get stuff done with devs. So I thought I would write an article detailing the struggles of developers when they get “work” that’s supposed to be ready yesterday.

Read more →

Enable JWT authentication for the Wordpress REST API

/ Software Development / DevOps

This video shows you how to enable JWT authentication for the Wordpress REST API. You will first create a kickass Wordpress development using the official MySQL and Wordpress images from the Docker hub and then go through the whole plugin setup and testing process. Below are the links to everything used in this video Info about JSON Web Tokens and the JWT Authentication Plugin https://jwt.io/ https://enriquechavez.co/ https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/ https://wordpress.org/plugins/search/jwt/ How to access the Wordpress Rest API (permalink structure setup) https://stackoverflow.

Read more →

How I reduced the bounce rate on my GatsbyJS website

/ Videos / Software Development

Watch this video if you want to know how I implemented a related articles section on my GatsbyJS blog. I had an ugly bounce rate on this website, and the first step towards reducing it was to offer users more articles they can read, after going through the article they initially landed on. This article will be updated in the near future, and I will also go in detail about the reason I decided to implement this and what is the benefit of offering users more articles they can go through while they’re on your site.

Read more →
Copyright (c) 2023 Adrian Oprea. All rights reserved.