Articles

Viewing imgur through Duckduckgo

Image
In a previous article , I explained how to bypass imgur's country-wide ban by using a cheap VPS as a socks5 proxy. While this worked, it came with the downside that I had to keep an SSH session open at all times. Not long ago, another imgur-related thread popped up on r/morocco. I was about to suggest my workaround, but then I realized that not everyone has a VPS lying around. In addition to this, other users already suggested using a VPN; an admittedly easier solution. I looked into it again and discovered that this issue wasn't limited to INWI. People from other countries suffer from the same problem. During my research I landed on this meta stackoverflow thread . This suggestion in particular caught my eye : I tested it, and it worked as described. Hmm... maybe I could create a browser extension that prepends https://proxy.duckduckgo.com/iu/?u= to any imgur.com links it finds in the DOM ? I opened ChatGPT and star... just kidding. I searched for a similar extensio

Re-imagining mapstruct in D

Mapstruct is a Java library that makes it easy to map one type to another. I've been using it at work to map DTOs to JPA entities and vice versa. While it might seem unnecessary, it's one of those things I adopted just in case our REST responses deviate from our database structure. I won't go into details as to why one should or shouldn't use Mapstruct because it's beyond the scope of this article. What I want to talk about, instead, is the port itself. Motivation One of mapstruct's selling points is that it generates mappings at compile time. I simply write an interface such as this one: @Mapper(componentModel = "spring") public interface Mapper { @Mapping UserDTO toUserDTO(User entity); } With User and UserDTO being: class User { long id; String username; String password; //getters and setters } class UserDTO { long id; String username; //getters and setters } Then after building the project, an im

Imgur fails to load with INWI

Image
I run a PHP script every night to download funny greentexts from the r/4chan subreddit. I like reading them offline when I'm in bed. I don't remember since when I started noticing it, but some of the downloaded pictures would occasionally show signs of corruption. The image viewer would fail to read them. I didn't think much of it and wrote it off as the symptom of an aging SD card, which I've been using it since 2015. It wasn't until someone from r/morocco brought up issues with imgur that I made the connection. Most of the pictures I download from r/4chan are served by i.redd.it, but some of them are served by i.imgur.com. That explained why I thought they were corrupted. The retrieved images were essentially empty. A quick curl -I imgur.com check returned 429 Unknown Error , which confirmed my suspicion. r/morocco redditors submitted a bunch of reports and it quickly became apparent that the problem is limited to the inwi ISP, affecting not only their standar

Using IBM App ID roles with Spring Security

Image
This is something I've been meaning to write for a long time. If you're already familiar with how to set up App ID in a Spring Boot application, feel free to skip to the fifth step. That's where the juicy parts are. 1. Creating a project Let's start off by creating a new Spring Boot project. This link contains a Spring Boot project with the required dependencies: Spring Security, Spring Web and OAuth2 resource server. 2. Configuring App ID Next, let's create service credentials in our App ID instance. Notice that we gave it write permissions. You'll see why soon. While we're here, let's also add the "http://localhost:8080/login" redirect URL in the authentication settings : To make things easier, let's enable the Google provider in the "Identity Providers" tab. This way we can log in with an existing Google account. If you don't want to do this, it's also possible to create an account on Cloud Directo

The challenges of localizing an Android application (with special considerations for Arabic)

Image
I don't usually blog about work-related problems I encounter, but I figured this could be useful for some people. Below is a checklist of potential issues than can crop up when trying to introduce localization to an application that initially supported a single language. Backend error messages Instead of returning error messages, it would be more suitable to return error codes, and have the Android application display their interpretation in the user's language of choice. For example, instead of returning a string that says "This username is already in use", return something like "duplicate_username". One caveat of this approach is how the context that comes with errors should be handled. In the previous example, when a username is already in use, it's customary to return similar usernames that are available. The backend and the frontend should agree on a way to pass this contextual data through the response. Alternatively, you can propagate th

Registering WinRAR on a Linux machine in 2020

Image
The recent LGR video prompted me to write about my experience on how I got an official WinRAR installation to run on Ubuntu. Back in August, I decided to treat myself to something nice to celebrate my thirtieth birthday. After a session of deep introspection, I concluded that it was time to purchase a WinRAR licence. Registering WinRAR was supposedly considered to be a rite of passage in ancient cultures, the turning point where boys became men. I felt that I had finally reached a level of maturity that would permit me to embark in this life changing journey. The process itself was relatively straightforward. I went over to the official website and placed an order, and they sent me an invoice and a link from which to download the licence key, itself compressed in a RAR archive. I couldn't help but marvel at the website, it aged like fine wine. It is reminiscent of an earlier internet, and I look back fondly to a time where websites used to be much simpler. You'll notic

Cloning an infrared remote controller

Image
Context : One of my earliest paychecks went into a cheap 22" TV. It's not fancy at all, but it was a nice upgrade from the old Sony Trinitron TV that was starting to show its age. The new TV has a brand name of "Vision", which is less glamorous than "Sony", but it has been working well so far, so I can't really complain. Just the other day, I found out that it is possible to get it to record something while it's on standby. It's a feature I never knew I needed until I discovered it. A couple of months after I got it, I ran into a problem with the remote controller. Luckily it turned out to be caused by a dead battery. Even though it was trivial to fix, this minor incident planted the seed of fear in me. Since the TV doesn't have physical buttons, I concluded that it would become useless should the remote stop working for some reason or another. Because of this, I decided to make a backup of the remote in case something happens to it. To d