duminică, 12 ianuarie 2025

OpenVPN Connecting but No Internet Access on Arch Linux

 Here is an answer: AskUbuntu: OpenVPN Connecting but No Internet Access

On my system running Cinnamon with Network Manager, I followed these steps:

  1. Open Network Settings.
  2. Edit the settings for the specific VPN connection.
  3. Under IPv4, scroll down and check the option "Use this connection only for resources on its network".
  4. Under IPv6, scroll down and check the option "Use this connection only for resources on its network".
  5. Click Apply.

This resolved the issue for me.

sâmbătă, 11 ianuarie 2025

No Password Prompt for VPN? How I Fixed It on Arch Linux

Yesterday, I upgraded packages on my Arch Linux system. Today, I noticed that the VPN refused to connect. There were no error messages, but the dialog to enter the password didn’t appear. I discovered that Arch Linux (and possibly most modern Linux distributions) no longer uses `/var/log/syslog` or `/var/log/messages`.  
To debug, I used the following command (https://wiki.archlinux.org/title/Systemd/Journal#Filtering_output):  

journalctl --since "2 min ago"
I found the error:  
Jan 10 15:45:56 myarch NetworkManager[487]: <warn> ...  secrets: failed to request VPN secrets #3: No agents were available for this request.


I searched Google for the error and came across these helpful links:  
Unix Stack Exchange: Failed to request VPN secrets #3 
Arch Linux Forums: Failed to request VPN secrets 
 

The solution I found was to "Store the password for all users."  In my case, this translates to the following steps:  
1. Open Network Settings.  
2. Edit the VPN connection.  
3. Go to the Identity section.  
4. Click the dropdown to the right of the password field.  
5. Select Store the password for all users.  
Additionally, I discovered that logs specific to NetworkManager can be viewed with:  

journalctl -u NetworkManager

I also found that I can see all NetworkManager connections using nmcli command or listing the content of the directory /etc/NetworkManager/system-connections/. Then try to start that connection:

nmcli conn up <my-vpn-config>

Then I saw this message

You need to authenticate to access the Virtual Private Network “my-vpn-config”.
Warning: password for 'vpn.secrets.password' not given in 'passwd-file' and nmcli cannot ask without '--ask' option.
Error: Connection activation failed: No valid secrets
Hint: use 'journalctl -xe NM_CONNECTION=453a0f43-dc10-4557-b524-a762c99833d4 + NM_DEVICE=wlp3s0' to get more details. 
Thus
nmcli conn up <my-vpn-config> --ask

also solved the issue.

A more general solution

sudo pacman -S gnome-keyring 

Etimologia zilelor săptămânii

Această postare a apărut când exersam zilele săptămânii împreună cu fiica mea în engleză și am observat că atât ea, cât și eu ne amintim mai greu cum se spune joi în engleză. Am înțeles că este din cauză că nu avem asociații cu Thursday. Așa că m-am gândit că ar fi bine să investighez puțin. Întrebarea a fost: în română, zilele săptămânii provin de la denumirile planetelor (sau ale zeilor ale căror nume le poartă planetele). Dar în engleză? Aici m-a ajutat prietenul meu, care mi-a oferit un punct de pornire și mi-a spus că Thursday vine de la zeul Thor, iar Friday de la zeița Frigg (soția lui Odin).

English Monday Tuesday Wednesday Thursday Friday Saturday Sunday

The Moon Týr Odin (also known as 'Woden') Thor Frigg Saturn The Sun
Română Luni Marți Miercuri Joi Vineri Sâmbătă Duminică

Lunae dies („Ziua Lunii”) Marte Mercur Jupiter Venus Saturn Dies Dominicus („Ziua Domnului”)

Týr este zeul războiului (precum e Marte la romani).

Surse:




luni, 12 august 2024

Building with Gradle

1. Problem

Failed to calculate the value of task ':compileJava' property 'javaCompiler'.

Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=21, vendor=any, implementation=vendor-specific} for WINDOWS on x86_64.

No locally installed toolchains match and toolchain download repositories have not been configured.

Solution:

File > Setting > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM: <choose naother JDK> 


luni, 3 iunie 2024

Set-theoretical approach to Open-Closed Principle

Let's state the principle: "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification" (see https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle).

Here are my personal thoughts on how to achieve that. 

Let's consider a "set-theoretical" approach. If we view a class as a set $A$ of lines of code. Then we must not modify the content of $A$. This represents the closure aspect.

However, to extend the functionality of $A$, we will need to modify certain parts of $A$.
Therefore, we must (1) extract those parts from $A$ as external sets, such as $B$, $C$, and so on.
Next, (2) establish relationships $R_1$, $R_2$ ... between the parts of $A$ where code was extracted and the new sets $B$ and $C$.

At this point, we have two options:

  1. Extending the functionality by modifying $B$, $C$, etc., would contradict the Open-Closed Principle for $B$, $C$, etc.
  2. Extending the functionality by introducing new sets (classes) such as $B'$, $C'$, etc., and defining relations $R_1$, $R_2$, etc., in a manner that allows seamless switching between $B$ and $B'$, $C$ and $C'$, etc.


I think option 2 aligns closely with the concept of "decoupling".

Mathematically, to enable the flexibility to switch between $B$ and $B'$, $C$ and $C'$, etc., the relations $R_1$, $R_2$, etc.,
must establish links between set $A$ and families of sets ${B, B', B'', ...}$, ${C, C', C'', ...}$, and so forth. Like set-valued mappings.

For example, the relation "use an object b of extendable class $B"$ is a solution. Because if we have inside $A$ the line

b.method1();
where b is of type B, then we can always replace b with an object of type B', where B' extends B.

A more explicit relationship might be described as "use an object b of interface B" or "use an object b of abstract class B". In light of the above, an interface serves as a relationship to a family or hierarchy of interfaces and classes that implement it.

A specific type of relation is the mapping, or function. If we put inside A the line

method1();
To extend the functionality of method1(), it must relate not only to its own body but also to a family of methods named method1(). This can be achieved using the template method pattern.

Possibly, the last part involving the mapping concept could be refined to "use a method that can be overridden".

Some links:

https://www.cs.utexas.edu/users/downing/papers/OCP-1996.pdf

joi, 23 mai 2024

GPT-2 in about 150 lines of Java

Found a very interesting post "GPT in 500 lines of SQL" (https://explainextended.com/2023/12/31/happy-new-year-15/) which was inspired from "GPT in 60 Lines of NumPy" (https://jaykmody.com/blog/gpt-from-scratch/). And of course I could not resist the temptation to do the same but in Java :-) In addition, "all I saw" in the source code were mostly matrix operations, which I like a lot.

image from https://www.mathsisfun.com/algebra/matrix-multiplying.html  

Thanks to Nd4j library which offers the same flexibility of working with matrices as NumPy, I managed to convert the source code from https://jaykmody.com/blog/gpt-from-scratch/ into about 150 lines of Java (https://github.com/Streeling/RD_Archive/tree/main/ams/gpt2-in-about-150-lines-of-nd4j).


marți, 20 iunie 2023

Debugging (and understanding) Hibernate

Put a breakpoint inside each method of org.hibernate.EmptyInterceptor and hit Debug. 

UPDATE: If we will inspect any Hibernate operation, or more technically chain of Hibernate method calls, we will always find a e method of Interceptor interface (implemented by EmptyInterceptor). In this way placing a breakpoint in EmptyInterceptor methods and inspecting breakpoint neighborhoods we will favor finding the solution.

Also if you want to know which part of your code generated a specific query, then put a conditional break point (e.g. statement.contains("from <my_table>")) inside SqlStatementLogger.logStatement(String statement) method.

Also if you want to know from which cache was the entity loaded

- set log level trace for org.hibernate.event.internal.DefaultLoadEventListener

- set log level debug for org.hibernate.SQL