Welcome to Backyard

Login Signup

Posts:

Tiny guide to setup Java JDK in a Macbook M3

By sborrazas on 2024-04-25

I use fish shell and VSCodium (a fork of VS Code without telemetry).

  1. Install Homebrew https://brew.sh/
  2. Install fish with brew install fish
  3. This guide is for fish shell, so be sure to continue in fish shell by running fish. Optionally, you can set fish as your default shell on macOS
  4. Install openjdk with brew install openjdk
  5. After installing openjdk, I get the following caveat text from Homebrew (which you can read again by running brew info openjdk):
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

openjdk is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.

If you need to have openjdk first in your PATH, run:
fish_add_path /opt/homebrew/opt/openjdk/bin

For compilers to find openjdk you may need to set:
set -gx CPPFLAGS "-I/opt/homebrew/opt/openjdk/include"
  1. Run fish_add_path /opt/homebrew/opt/openjdk/bin to be able to run javac
  2. Run /usr/libexec/java_home -V to get the JAVA_HOME of the installed jdks. Mine returns:
Matching Java Virtual Machines (1):
    21.0.2 (arm64) "Homebrew" - "OpenJDK 21.0.2" /opt/homebrew/Cellar/openjdk/21.0.2/libexec/openjdk.jdk/Contents/Home
/opt/homebrew/Cellar/openjdk/21.0.2/libexec/openjdk.jdk/Contents/Home
  1. To set JAVA_HOME environment variable, run set -Ux JAVA_HOME /opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home. You can check this is a symlink to the installed jdk with ls -lart /opt/homebrew/opt/openjdk
  2. Create a file called Hello.java with the following content:
public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
  1. Run javac Hello.java which will create a file called Hellow.class. Then you can run java Hello to run your new class (beware this command takes the class name, not the filename). The output of the command is Hello, World!
  2. Now that you have the java development kit up and running in your computer, it’s time to get some IDE support to get auto-completion, auto-import, etc. You can choose between Eclipse, IntelliJ, VS Code, etc. In my personal computer I use VSCodium. Install VSCodium with brew install vscodium (or visual-studio-code if you prefer)
  3. You can open VSCodium from the terminal with codium .. Search for extensions in VSCodium and install Extension Pack for Java which installs several convenient extensions for working with Java. I started with Language Support for Java™ by Red Hat but it misses some functionality, so my recommendation is to go for the extension pack
  4. Congratulations! You got your Java development environment ready. You might want to install maven with brew install maven

Set fish shell as default in macOS

By sborrazas on 2024-04-25

How to set fish shell as default shell in macOS.

  1. Install fish with brew install fish
  2. Test the installation by running fish
  3. Add the path fish to /etc/shells. First, get the path with which fish. In my case the path is /opt/homebrew/bin/fish. You can append the path with the command sudo sh -c 'echo /opt/homebrew/bin/fish >> /etc/shells'
  4. Set the shell with chsh -s /opt/homebrew/bin/fish
  5. Log out of your current shell

Recipes

By sborrazas on 2024-01-20

Here are some of my favorite recipes, which are typical Argentine dishes.

Argentine style pancakes

Ingredients

Directions

  1. Throw the ingredients in a blender and blend for 2 minutes.
  2. Bring the mixture to the fridge for at least 20 minutes.
  3. Grease pan with butter and cook them to medium heat. Flip after a few minutes.

Pizza dough

This pizza dough can be used for many different types of pizzas. Take into account you have to let it rest for 1 day in the fridge at minimum.

I learn this recipe from Roberto Petersen Enseña Cómo Hacer La Mejor Pizza | EP01 HORNEADOS .

Ingredients:

Directions

  1. Put the water in a big bowl
  2. Mix the salt in the water
  3. Mix the yeast in the water
  4. Wait 2 minutes for the yeast to hydrate
  5. Add the flour and mix well until the ingredients are combined. There is no need to kneed.
  6. Cover the mixture and leave it rest for 20 minutes.
  7. Kneed the mixture for 10 minutes. If the bowl is big enough you can mix it in the bowl.
  8. Transfer to a bowl with olive oil.
  9. Cover the mixture and leave it rise for 2 hours (or until the duplicates volume).
  10. Move the bowl to the fridge and let it rest there for a minimum of 1 day and a maximum of 4 days.
  11. Manipulate the dough with some olive oil to avoid sticking.
  12. With this dough you can make three thin pizzas or two tick ones.
  13. Add the ingredients and leave it rest for a few minutes.
  14. I use the maximum heat possible in the oven to cook the pizza.

Alternative to Pi-hole in NixOS

By sborrazas on 2024-01-09

Now that my son has some internet access, I decided to make internet a bit safer at home.

I try to use NixOS in most of my devices. I have an old computer serving borrazas.org. I have another old computer serving as a “media center” where we watch the News for kids in Dutch. NixOS allows me to have all system configuration in one file: /etc/nixos/configuration.nix. If for some reason I have to reinstall the computer, I only have to backup that one file.

I have seen Pi-Hole recommended in Hacker News a couple times, and I checked myself and it looked like the right tool to make internet a bit more child-friendly.

My goal:

I searched for instructions how to install Pi-Hole in NixOS, but seems that nobody has packaged it yet 12. One of the comments in the thread requesting Pi-Hole for NixOS mentioned that AdGuard Home and blocky are packaged for NixOS.

I prefer to avoid for-profit companies for blocking stuff because there are several bad examples such as Adblock Plus, and free VPN companies with fishy terms of service.

Anyway, I checked the AdGuard Home Github repo looks like a nice project in Go, with a GNUv3 license. It looks trustworthy enough for me.

Changes in /etc/nixos/configuration.nix:

(1). Add adguardhome to the list of packages

packages = with pkgs; [
    neovim  
    wget
    curl  
    # ...
    go
    tmux
    adguardhome
    ];
};

(2). Open up Firewall ports

  # Open ports in the firewall.
  networking.firewall.allowedTCPPorts = [ 3000 80 ];
  networking.firewall.allowedUDPPorts = [ 53 ];

(3). Enable the service (I had to search for available options on NixOS Option Search). I used the following

  # Adguard home
  services.adguardhome = {
    enable = true;
    openFirewall = true;
    settings = {
      bind_port = 3000;
    };
  };

I tried to add a password but currently it’s not possible with the current options.

Assuming the IP of your machine is 192.168.1.123, go to http://192.168.1.123:3000/ and you should see the AdGuard Home Dashboard.

In Settings, DNS Settings I added “https://base.dns.mullvad.net/dns-query” which blocks ads, malware and phishing. Here is a list of more DNS options. I personally trust Mullvad. I wanted something like all.dns.mullvad.net, so I looked up Mullvad block lists in https://github.com/mullvad/dns-blocklists and added the lists in Filters, DNS blocklists.

I had to follow Pi-Hole guide to setup my Fritzbox internet router. The trick was to use the same IP in preferred and alternative, and to disable “Fallback to public DNS servers when DNS disrupted”.

https://docs.Pi-Hole.net/routers/fritzbox/#optional-increasing-the-priority-of-dns-requests

I have been using it for around a week and it works fine.