RSSAmplifier

Blog

{code that works}

Recent content on {code that works}

sadique.ioRSS feed ↗186 posts

Latest posts

Using Linux Capabilities through Systemd

In this blog post, we will continue exploring Linux Capabilities by learning how to use Capabilities through Systemd configurations. This is part of a series on Capabilities and the previous posts are recommended as pre-requisites for understanding this.

Using Linux Capabilities with pam_cap.so

In this blog post, we will continue exploring Linux Capabilities by learning how to use pam_cap.so , a PAM module provided by libcap . This module allows Capabilities to be made available to Users’ sessions as they go through PAM authentication process. And these Capabilities gets assigned to any Process launched in the resulting sessions.

Making sense of Linux Capabilities

In this blog post, we will explore Linux Capabilities, which is a way to ensure that Processes and executables have just enough rights to perform the actions they are deemed safe to perform, without giving them carte blanche to anything and everything by running as the root user.

On Dave Egger's _The Monk of Mokha_

As someone who started enjoying coffee much later in my life, I vaguely knew about the history of coffee the drink - it’s discovery in Ethiopia, it’s domestication and cultivation in Yemen and how it was brought to India by a Saint who stole saplings. In Dave Egger’s The Monk of Mokha , I learned about the history of coffee, warts and all. Perhaps the most surprising element was…

Launching Terminals from Nautilus with Shortcuts

This is a blog post about how to set up Nautilus 1 to launch any chosen Terminal emulator for the currently open directory. It was inspired by this comment about missing features in Ghostty 2 . By default Nautilus has a context menu entry that launches the default GNOME Terminal at the open directory. There are two missing pieces here - one is that the action needs to be invoked from the context…

TIL: sysfs - a filesystem for exporting kernel objects

While tweaking kernel parameters on the MacBook running Linux , I learned about sysfs 1 - a filesystem that provides access to the kernel data. That blog post described how startup chimes can be modified by setting UEFI parameters by using the efivarfs filesystem 2 , which was created as a improvement over sysfs for storing UEFI parameters. Looking at the hid_apple module 3 , it’s state is…

Configuring WezTerm on my Linux MacBook Air

After setting up Linux on the MacBook Air as we discussed in the last blog post, the next item to sort out was making sure that the keyboard shortcuts that I have always used continue to work. Since the macOS key bindings I set up using gnome-macos-remap-wayland had special configurations in place to handle Ctrl+ shortcuts in Gnome Terminal 1 , that is where I started. It became apparent that…

Keeping a Mid-2011 MacBook Air Running With Linux

I have a 2011 vintage MacBook Air that has not seen much usage recently. It was originally purchased from a previous employer’s auction of used computers. It did just enough things right - browsing, watching videos, working on documents, and writing some code in a pinch. Somewhere along the way, the battery stopped holding a charge and the MacBook became tethered to a power cable. This led…

Using GitHub and Bitbucket issues for comments on Static sites

One thing that statically generated sites like this typically lack is a commenting system. There are solutions like Disqus that you can embed, but then the commenter will need to create an account there, and you now have one more dependency. Sometimes, that is a perfectly reasonable approach. I came up with an approach 1 that uses GitHub issues and Bitbucket issues to host comments. Since this…

My HLedger Setup

From 2014 to 2023, I kept track of all our finances, in one way or another. I started out with Intuit’s Mint - it did a good job of aggregating accounts and presenting consolidated views. At some point, I became weary of Intuit having passwords to all my financial accounts and decided to keep track of everything in a Google Sheet, fronted by a Google Form to enter data.

Rendering PlantUML Diagrams in Hugo

This blog is generated using Hugo 1 . I have always wished that it had a way to render PlantUML diagrams 2 . I am not alone in wishing for this - this is a feature that people have requested for over 5 years for now 3 . But because of the peculiarities of Hugo’s opinionated security posture 4 and how PlantUML requires starting a Java process 5 , it has always been rejected 6 . People have…

Docker + K8s Workshop - chroot example

Create a chroot jail mkdir jail Create directories for system binaries mkdir jail/bin Copy the bash binary from the host cp -v /bin/bash jail/bin Create a list of libraries needed for the binary to work list_of_libs="$(ldd /bin/bash | egrep -o '/lib.*\.[0-9]')" echo $list_of_libs Copy the libraries recursively for i in $list_of_libs; do cp -v --parents "$i" `pwd`/jail; done Create a demo script…

Docker + K8s Workshop - Setup for Part 1

Hello World docker run hello-world Explanation Docker containers are run time instances of images. Think of a Docker image as a set of files (like the set of files we placed in the jail directory in the chroot demo). In this case, we are asking docker to create a container with the image hello-world . The image has to come from somewhere. By default, Docker searches in a public repository of…

Docker + K8s Workshop - Setup for Part 1

1. Install Docker Linux Install Docker Community Edition for your Linux distro based on instructions available at the official installation page . Ensure that you can run Docker as a non-root user. Instructions for this are available here . Test your set up by running the command docker run hello-world . MacOS Install Docker Desktop for MacOS using instruction available here . Test your set up by…

Flushing Metrics in Dropwizard Commands

Users of Dropwizard Metrics will be familiar with ScheduledReporter - it is a nice pattern that allows metrics reporting to be off loaded to a different thread which periodically sends out the collected metrics instead of making a network call every time a metric is collected. In most use cases, this works great - especially if you are running a server.

Managing environment lifecycles for Dropwizard Commands

If you have built background workers or other non-server applications with Dropwizard, chances are that you used the Dropwizard Command pattern. In fact, even the sever you wrote with Dropwizard executes a command - specifically io.dropwizard.cli.ServerCommand . While the server command is great, sometimes you want to build applications that have all the goodies that Dropwizard offers, but you…

Looking up Enum types and values in Postgres

In this blog post, we will explore how Postgres stores Enum types and how to query for Enum types and their values. Postgres’ Enum, like their counterparts in many programming languags are data types that allow only a predefined set of values to be assigned to them. An interesting difference is that compared to programming languages, Postgres does allow blanks within the values of Enums.

Viewing Sequence ownership information in Postgres

This blog post is an exercise in identifying all the sequences in a PostgreSQL database that is associated with a table column via an OWNED BY relationship. Figuring out how to do this was harder than it should have been and this journals my understanding of it.

Understanding trailing @ processing in SAS input

One of the first things I noticed when I started poking around in SAS code is that the input statement is very powerful, flexible and hence sometimes hard to understand. It can read pretty much anything in to a dataset as long as you tell it what to do. The use of trailing @ s to take control of how SAS advances the input pointer is a powerful technique to read from input files where the data is…

Importing the SASUSER datasets in SAS Studio

I have been playing around with SAS for the last two weeks. I started with a SAS University Edition running on a VirtualBox instance on my MacBook, but soon realized that it was way more convenient to use a SAS OnDemand account. Having made the switch, I realized that all learning materials made references to and used examples with datsets from a library named SASUSER . It was not clear how to get…

My talk at GraphQL Summit 2018

I had the opportunity to give a talk at GraphQL Summit 2018 about the experience of introducing GraphQL for our Payments API at Braintree . It was well received, as far as I could tell - I received a lot of nice feedback and had great conversations with members of the community. The slides are available here on SpeakerDeck . I will update this post with links to the video of my talk when it…

Formatting Java Instant for resolutions

I have had to look up how to format Java’s Instant with a given resolution - for example in microseconds or nanoseconds. After fiddling with various formatters, I was happy to finally get this right.

FreeBuilder plugin for IntelliJ

My work uses FreeBuilder extensively to generate the Builder pattern for Java classes. In addition to this, we use the generated Builder classes to deserialize the data calsses using Jackson. After a while it became tiresome to type @FreeBuilder and class Builder extends ... everywhere. So I decided to write and IntelliJ IDEA plugin that does it for me.

Command line clients for gRPC - polyglot

Polyglot was the second gRPC client that I looked at. One of the things that I liked about it is the fact that it does not need users to generate protoset files. It generates the protoset files in flight every time it runs. This, combined with the fact that it is written in Java does have a disadvantage - every time the client makes a call, it has to fire up a JVM, generate protosets and make the…

Command line clients for gRPC - grpcurl

We are in the middle of considering replacing JSON over HTTP with gRPC for communication between our internal services. One of my concerns about this was how we would be able to debug and poke around things in a world where we will no longer be able to use cURL. I have been looking at cURL like command line utilities we can use to replace most of the capabilities, if not all of cURL. So far, I…

A Jackson and FreeBuilder quirk

Jackson is a great tool to have in your tool set if you deal with JSON or XML. It facilitates easy serialization and de-serialization to and from Java classes with a convenient annotation based interface. With the same set of annotations, we can achieve both XML and JSON serialization and de-serialization. With Jackson’s data-format-xml it is even possible to give the same Class a different…

Net::HTTP and the simplest of explanations

This blog post exists purely to remind myself that Ruby’s Net::HTTP expects a host and a port as parameters when creating a new connection and not a url string. This is a story about how many layers of abstractions and indirections one works through on a daily basis as a developer and the effort required to dive through these layers, all the while ignoring the simplest of explanations of why…

Python URL manipulation revisited

My last blog post about publishing standalone files to Nexus repositories prompted me to revisit URL manipulation in Python. When I did this the last time , I used Python stand library’s urlparse and it did the job. This time around, I needed to do a different kind of manipulation. Given a URL, I had to set credentials on it. I started at urlparse and soon realized that Python3 moved this…

Uploading a standalone artifact to Nexus 3

This is one of those “I had to figure out how to do this today, so the next time I google this, I have a place to look” blog posts. Today, I had to upload a zip file as a build artifact to our Nexus 3 repository. The zip file had been generated by custom shell scripts that did not have a Maven, Ivy or Gradle projects to wrap them.

Implementing feature toggles for a Spring Boot application - Part 4

In the fourth part of this series about implementing feature toggles for a Spring Boot application, we will take a look at how our implementation so far introduced a dependency on the application being restarted for changes to take place.

Implementing feature toggles for a Spring Boot application - Part 3

In the third part of this series about implementing feature toggles for a Spring Boot application, we will take a look at exposing the state of feature flags as a Spring Boot management end point for monitoring and testing purposes.

Implementing feature toggles for a Spring Boot application - Part 2

In the second part of this series about implementing feature toggles for a Spring Boot application, we will look at exposing the features to the Angular front-end so that features can be toggled in UI components.

Implementing feature toggles for a Spring Boot application - Part 1

In one of our recent projects at work, we implemented feature toggles for a Spring MVC / Angular JS code base and this series of blog posts discusses our motivations and requirements, the approach we took and what we learned from it.

Setting up a secure etcd cluster behind a proxy

This is a blog post that explains how to set up a highly available etcd cluster behind a proxy and securing the communication between a client and the proxy, between the proxy and the individual member in the cluster and between members in the cluster.

A very basic introduction to deploying a Java application using Kubernetes

I have been playing around with Kubernetes and Docker lately. To borrow the description of Kubernetes from their website, “Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.” One of the first things I did was to try and see what it would take to go from an application to deploying it. I started with a simple Java…

Handling Deserialization errors in Spring Redis Sessions

One of the challenges of using storing spring sessions in Redis is that the objects that gets stored as part of a session often undergoes changes as the application evolves and these changes cause de-serialization exceptions to be thrown after a deployment when a session created before the deployment is presented to the application. This blog post discusses a method to work around this issue.

CSRF Protection with Spring Security and Angular JS

Both Spring Security and Angular JS provide support for CSRF protection. However, getting these to work together to provide protection from CSRF requires some non-obvious configuration. This blog post explains how to add CSRF protection to an application that uses Spring Security with an Angular JS front end.

Controlling Redis auto-configuration for Spring Boot Session

If you have been using Spring Boot, chances are that you are using the Spring Session library to handle sessions. Spring Session has the ability to persist the sessions to various data stores, including Redis. The default behaviors of Spring Boot when combined with Spring Session is to start using Redis as the session store the moment spring-session-data-redis is detected in the class path,…

JWT authentication with Spring Web - Part 5

In parts 1 through 4 of this series, we built a Spring API that can issue a JWT when a user successfully authenticates and verify the JWT presented by the client for subsequent requests. In this blog post - the last in the series, we will build a simple Angular JS application with authentication that uses this API as the backend.

JWT authentication with Spring Web - Part 4

In parts 1 through 3 of this series, we built a Spring API that can issue a JWT when a user successfully authenticates. In this blog post, we will add the capability to verify the JWT presented by the client for subsequent requests.

JWT authentication with Spring Web - Part 3

In the previous blog post , we built the Spring API that responds with Profile information. Continuing on the path to building authentication with JWT, in this blog post, we will create a login mechanism that issues a JWT when the user presents the correct credentials.

JWT authentication with Spring Web - Part 2

In the previous blog post in this series, we looked at the basics of JWT. We will move on to building the Spring API that we will use JWT for authentication in this blog post.

JWT authentication with Spring Web - Part 1

JSON Web Tokens (JWTs) are signed tokens issued by a server that it can use to verify a claim made by a client. This blog post is the first in a series where I implement authentication based on JWT in a Spring Web application with an Angular JS front end.

JSON logging for Spring applications

If you have an application that writes logs, there are many reasons to make it write the log in JSON format. It makes it easier to search and analyze them when using tools such as the ELK Stack [^1]. JSON formatted logs make it easier to look at them when looking at how the app is behaving in real time using tools like jq [^2]. This blog post documents how to format logs as JSON in a Spring…

Injecting dependencies into a Spring @Configuration

This is one of those blog posts about things I wish I had known before I spent a lot of time figuring out when something was not working as expected. Recently, we have been trying to extend a WebMvcConfigurerAdapter to wire up an HTTP request interceptor. And things did not work as we expected it to and we learned that our understanding of how Spring behaved under this situation was wrong. This is…

Filtering responses in Spring MVC

Yesterday my colleague Imdad asked if there was a mechanism to add filtering to a Spring MVC end point that responded with JSON. We both started looking at it and this blog post explores a way to do it, albeit for a specific type of responses that was relevant to our discussions.

On Inverness

Two weeks ago, I was in the Scottish Highlands - soaking in the beauty of the city of Inverness, hiking through the South Loch Ness trail and traveling across the Black Isle. It was a wonderful trip - one that I wish was longer. This was a trip that invoked so many memories in me - among other things, of a man whose voice was part of growing up. A voice that traveled from the BBC Studios in the…

Deprecating domain events in Axon

Recently at work, we had to deprecate a domain event. This event used to represent an error scenario. However, the business had since decided that this is no longer a valid error scenario. Removing the Java class is not straight forward - since there are events of this type stored in the event store, every time the aggregate associated with this event is loaded, Axon will throw errors trying to…

Programmable exit codes for spring command line applications - 2

In the last blog post , we took a look at how to implement programmable exit codes for spring command line applications by using exceptions that implement ExitCodeGenerator . This time, we will take a look at how to achieve the same without having to depend on an exception.

Programmable exit codes for Spring command line applications

Spring’s CommandLineRunner provides a great mechanism to build command line applications. While this convenience is great, applications that use CommandLineRunner require extra effort in some areas like integration testing. Exit codes are such an area - applications that use command line runners always report their exit code as 0 even if there are exceptions thrown. This blog post explains a…