Skip to main content

Posts

How to compile Electron from source (for arm64 / x64)?

Sometimes if prebuilt binaries of electron are not available for your platform or if you want to modify the electron source to customize to your need, you are at the right place. I had a requirement to have a <webview> tag inside another <webview> tag. Seems it is not supported out of the box. As per the suggestion provided in the above link, I thought I could modify a couple of lines and see if it works. Coincidentally I am running Kubuntu arm64 build on M1 mac via parallels. So I wanted a aarch64 (a.k.a arm64 ) build. So I provisioned a  t4g.medium (2vCPU , 4 GB RAM)   with Ubuntu 22.04 LTS.   I tried checking out the code as mentioned below. But within 30 mins I ran out of CPU credits and had to switch to   r6g.large (2vCPU , 16 GB RAM) . Code was checked out pretty fast (fast for 50GB of code). Yes you will need at least 60GB of disk. Ok, lets go through the steps for checking out and compiling. Step-1: Prepare the build environment su...

How to use Groovy + GraalVM + Quarkus together?

If you are one among those who like Groovy for its simplicity and tight integration with Java (and not for its dynamic capabilities) and wondered how to write Groovy code in a Quarkus application and compile it to native using GraalVM? I have you covered. You dont have to look anywhere else. Scope groovy code as part of quarkus application statically compilable groovy code with no dynamic feature compile the final application to native code using graalvm Code example can be found here . Steps Create a quarkus application as outlined here Add your groovy class under src/main/java Annotate your groovy class with @groovy.transform. CompileStatic create a file called application.properies under src/main/resources folder with the following content. quarkus.native.additional-build-args=\ --allow-incomplete-classpath, \ --report-unsupported-elements-at-runtime, \ --initialize-at-build-time, \ --initialize-at-run-time=org.codehaus.groovy.control.XStreamUtils\\,groov...

How to retry a method call in Spring or Quarkus?

Have you ever come across a situation where you wanted to retry a method invocation automatically? Let's say you are calling a stock ticker service for a given stock and get a transient error. Since it is a transient error, you will try again and it may work in second attempt. But what if it doesn't? Well, you will try third time. But how many times can you try like that? More importantly after how much time will you retry? Imagine if you have a handful of methods like this. Your code will become convoluted with retry logic. Is there a better way? Well, if you are using spring/spring boot, you are in luck. Here is how you can do that using spring. Let's write our business service as follows. import java.time.LocalDateTime; import java.util.concurrent.CompletableFuture; import lombok.extern.slf4j.Slf4j; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; import org.springframework.scheduling.annotation.Async; import...

HTTP/2 Java Server using Embedded Jetty - Part 2

In the last post we saw how to spin a http/2 server using embedded jetty. In this post we will see, how to use asynchronous servlet (as well as AIO a.k.a non-blocking IO) and why that is important? Asynchronous Servlets ≠ Asynchronous IO [1] The concept of Asynchronous Servlets is often confused with Asynchronous IO or the use of NIO. However, Asynchronous Servlets are not primarily motivated by asynchronous IO, since: HTTP Requests are mostly small and arrive in a single packet. Servlets rarely block on requests. Many responses are small and fit within the server buffers, so servlets often do not block writing responses. Asynchronous Servlets Use-case The main use-case for asynchronous servlets is waiting for non-IO events or resources. Many web applications need to wait at some stage during the processing of a HTTP request, for example: waiting for a resource to be available before processing the request (e.g., thread, JDBC Connection) waiting for an applica...

HTTP/2 Java Server using Embedded Jetty - Part 1

Have you ever wanted to configure internal Java servers using HTTP/2 (or H2 in short), because of the following advantages? Internal clients making concurrent calls, can now use a single connection by utilizing the multiplexing nature of HTTP/2. Server will/can use less threads as there are less connections overall. Servers can also push resources/data and can communicate using websockets But what if you don’t want to go through tedious process of setting up SSL/TLS certificates? HTTP/2 insists on SSL/TLS as no browser supports HTTP/2 on insecure mode. Or what if you want to save every bit of CPU and time by skipping encryption and decryption? You are at the right place. Since everyone nowadays is moving towards (or talking about) micro services, we will also configure Jetty HTTP/2 server in embedded mode. What more? We are also going to configure our server to use Asynchronous Servlets and Asynchronous IO (aka non-blocking IO or NIO) in Part-2 of this article. ...

Using Apache as (SSL) proxy server

If you are a using any Java web server (such as Tomcat) or app server (such as Wildfly, JBoss or Glassfish), then you know that they dont listen on http port 80. Well, why does it have to listen on port 80? because if you want your user to specify only the url and not the port; for example, http://mydomain.com and not http://mydomain:8080 Note: throughout this article mydomain.com can be replaced with localhost, if your product is in development stage. Software used: Ubuntu apache2 Any Java web/app server What we want to achieve We are going to divert all user requests coming on port 80 to Tomcat running 8080 on the same host. Installation Run the following commands sudo apt-get install apache2 sudo apt-get install libxml2-dev sudo apt-get install libapache2-mod-proxy-html Note: If your ubuntu OS is latest, then you may not have libapache2-mod-proxy-html package. Instead run the following command. sudo a2enmod proxy_html Configuration 1. Append t...

How to install (K)Ubuntu alongside Yosemite and Windows 8 on Mac Book Pro?

Here let's see how we can install Windows 8 and (K)ubuntu 15.10 (Wily Werewolf) along side Mac Yosemite as triple boot. Software/Hardware required Mac book Pro 11,1 (instruction might be similar for newer models) Yosemite Windows 8 (K)Ubuntu 15.10  Wily Werewolf (might work with 15.04 as well) Refind (not reEFIt) Here is the summary of what we are going to do. Partition mac to have windows boot-camp partition  Install windows 8 Create two new partitions from mac partition for Linux Install (K)ubuntu Fix GPT-MBR Install Refind Step-0 In case you want to backup your mac:  Restart mac and hold  This will boot Mac in recovery mode as shown below    Plugin an external drive and choose Disk Utility option Select the mac partition (not your hard disk root) and go to restore tab Choose your external drive as the destination as shown below Important: ensure that your mac partition is the Source Click Restore to take a cop...