<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vincenzo Palazzo</title>
    <description>The latest articles on DEV Community by Vincenzo Palazzo (@vincenzopalazzo).</description>
    <link>https://dev.to/vincenzopalazzo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F727974%2F7819f4e5-6da3-4c39-8fcc-aea40790fe04.png</url>
      <title>DEV Community: Vincenzo Palazzo</title>
      <link>https://dev.to/vincenzopalazzo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vincenzopalazzo"/>
    <language>en</language>
    <item>
      <title>Swing theming: Basic introduction to MaterialTheme System</title>
      <dc:creator>Vincenzo Palazzo</dc:creator>
      <pubDate>Thu, 18 Aug 2022 23:42:17 +0000</pubDate>
      <link>https://dev.to/vincenzopalazzo/swing-theming-basic-introduction-to-materialtheme-system-d9d</link>
      <guid>https://dev.to/vincenzopalazzo/swing-theming-basic-introduction-to-materialtheme-system-d9d</guid>
      <description>&lt;p&gt;Since 2019, material-ui-swing has an experimental feature that is called MaterialTheming. In particular, MaterialTheming is a proposal to add a declarative Theme system inside Swing like the material theming system implemented in Flutter or Jetpack Compose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qsyfssr5nv6rh0y7h9j.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qsyfssr5nv6rh0y7h9j.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction to Material-UI-Swing
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/vincenzopalazzo/material-ui-swing" rel="noopener noreferrer"&gt;Material-UI-Swing&lt;/a&gt; is a library that gives the possibility to import material style inside a very old framework like Swing with the original swing API. The library was originally born as College Project by &lt;a href="https://github.com/atarw" rel="noopener noreferrer"&gt;atharva washimkar&lt;/a&gt; and transformed into a product by &lt;a href="https://github.com/vincenzopalazzo" rel="noopener noreferrer"&gt;vincenzopalazzo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In addition, the original project was forked by vincenzopalazzo because he started to implement some experiments in his own repository, after that, the repository &lt;a href="https://github.com/vincenzopalazzo/material-ui-swing" rel="noopener noreferrer"&gt;https://github.com/vincenzopalazzo/material-ui-swing&lt;/a&gt; was the only repository maintained, but periodically the atharw's receive synchronization with the last update.&lt;/p&gt;

&lt;p&gt;After the original maintainer left the project as maintainer in 2018 and the vincenzopalazzo new maintainer begin in 2018 until now, the scope development of the library start to be to grow as a product. This was also possible by the support from Arizona State University during the integration of the library with one of the most popular Swing software in the world which is JMars.&lt;/p&gt;

&lt;p&gt;The development of the library was focused to experiment with some solutions that provide the building blocks for the end developers to implement any type of style that the user wants without using a standard palette built inside the library.&lt;/p&gt;

&lt;p&gt;This opens two problems, that are described below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implementing a dynamic component that is able to change with user settings can be difficult because can contain a lot of corner cases.&lt;/li&gt;
&lt;li&gt;Swing framework has no easy concept of theme inside (a theme in the sense of Style and not only colors), but that can also change the style of one component.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Introduction to MaterialTheming System
&lt;/h1&gt;

&lt;p&gt;Material Theming system provided of constant build in the library under a &lt;a href="https://vincenzopalazzo.github.io/material-ui-swing" rel="noopener noreferrer"&gt;MaterialTheme&lt;/a&gt; interface and with this concept to have an interface that provides the access to all the value that Swing process to build and styling the UI material-ui-swing is able to support external theme provided in separate jars that include only the style of the application.&lt;/p&gt;

&lt;p&gt;One example of an external theme is &lt;a href="https://github.com/material-ui-swing/DarkStackOverflowTheme" rel="noopener noreferrer"&gt;DarkStackOverflowTheme&lt;/a&gt;, and this is an important feature to have inside a UI toolking.&lt;/p&gt;

&lt;p&gt;In contrast, the MaterialTheme interface can be improved and allowed different formats of configuration, by file propriety or JSON, and so on.&lt;/p&gt;

&lt;p&gt;This is particularly powerful when the user wants to import some theme from external resources like the Intellij themes or others.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example of Usage
&lt;/h1&gt;

&lt;p&gt;Change theme is super easy and doesn't require you to make any change inside the repository, you can have inside the static block the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static {
    try {
      // UIManager.setLookAndFeel(new MaterialLookAndFeel(new MaterialLiteTheme()));
// by including the https://github.com/material-ui-swing/DarkStackOverflowTheme
     UIManager.setLookAndFeel(new MaterialLookAndFeel(new DarkStackOverflowTheme())); mouse hover
    } catch (UnsupportedLookAndFeelException e) {
      e.printStackTrace();
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;After many years I start to share my experiment started on material-ui-swing to implement a custom theme, and implement an alternative library to modernize Swing application.&lt;/p&gt;

&lt;p&gt;If you like my work considered to sponsor me on &lt;a href="https://github.com/sponsors/vincenzopalazzo" rel="noopener noreferrer"&gt;Github sponsor page&lt;/a&gt; and follow me on Github &lt;a href="https://github.com/vincenzopalazzo" rel="noopener noreferrer"&gt;@vincenzopalazzo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>swing</category>
      <category>material</category>
      <category>programming</category>
    </item>
    <item>
      <title>Run a cln node with clightning4j tools on a tiny VPS</title>
      <dc:creator>Vincenzo Palazzo</dc:creator>
      <pubDate>Sat, 13 Aug 2022 13:46:26 +0000</pubDate>
      <link>https://dev.to/vincenzopalazzo/run-a-cln-node-with-clightning4j-tools-on-a-tiny-vps-1l35</link>
      <guid>https://dev.to/vincenzopalazzo/run-a-cln-node-with-clightning4j-tools-on-a-tiny-vps-1l35</guid>
      <description>&lt;p&gt;In this post, we will talk on how to set up a lightning node quickly using clightning4j tools.&lt;br&gt;
For this we will use a free AWS virtual machine but the same can be used with DigitalOcean where you can use my invite link to have $100 for free (for a couple of months of core lightning free).&lt;br&gt;
Other than that, you need to install on your virtual machine, docker, and docker-compose&lt;br&gt;
We will try to do it step by step below.&lt;/p&gt;


&lt;h2&gt;
  
  
  Introduction to clightning4j tools
&lt;/h2&gt;

&lt;p&gt;clightning4j is a collection of tools to make integration of core lightning and running one node easier. One of the most important plugins is btcli4j which is a backend plugin that supports rest and pruning mode for bitcoin, so you can run your node in a lightweight environment and very quickly.&lt;br&gt;
In addition, it offers a Java library JRPClightning to interact with core lightning and also develop a plugin for core lightning.&lt;br&gt;
This collection of tools is just a way to implement ideas born more than 2 years ago, but the intention is to move the more successful idea into a more modern language like Dart, Rust, and Go. So, yeah I make a lot of mistakes but I also learned a lot in the process :)&lt;/p&gt;


&lt;h2&gt;
  
  
  Hands-on the configuration
&lt;/h2&gt;

&lt;p&gt;For this article, I will choose to go with the AWS virtual machine where I installed Debian, and you can start to follow the guide from this page. However, this guide will be independent of the services and will be dependent only on the Debian operative system&lt;br&gt;
When you have your machine up and running choose your best method to connect to the virtual machine, I will use ssh, and the first two commands that I run every time at the first login are the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the process will finish we need to install docker and docker-compose. We will start to install docker with the official guide and we will run the following commands for Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, we add the GPG signature&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; sudo mkdir -p /etc/apt/keyrings
&amp;gt;&amp;gt; curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and after&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ok, you don't see anything right? This is normal 👩🏾‍🔬&lt;br&gt;
Let's run the last commands, which are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; sudo apt-get update
&amp;gt;&amp;gt; sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the completion of the process, we need to see if all is ok, and we run the hello-world in docker, with the following command&lt;br&gt;
sudo docker run hello-world&lt;br&gt;
Done, we have docker installed, you should also have the docker compose command available&lt;/p&gt;


&lt;h2&gt;
  
  
  Configuring clightning4j node
&lt;/h2&gt;

&lt;p&gt;The easier way to start it is to visit the GitHub repository clightning-node and take one of the examples that are present in the example directory,&lt;br&gt;
we will use the &lt;a href="https://raw.githubusercontent.com/clightning4j/clightning4j-node/main/examples/grpc-docker-compose.yml"&gt;grpc-docker-compose.yml&lt;/a&gt;, now we run the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; mkdir cln &amp;amp;&amp;amp; cd cln
&amp;gt;&amp;gt; wget https://raw.githubusercontent.com/clightning4j/clightning4j-node/main/examples/grpc-docker-compose.yml
&amp;gt;&amp;gt; sudo docker compose up --build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and when you have your node up un running, open a new console and run the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt; sudo docker compose run -T cln_test lightning-cli --testnet getinfo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the output would be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "id": "028fe59bd7bbe3982699535e7e43b305c69099fbdd9902b1af5875a121fdb9a3dc",
   "alias": "lndart-testnet",
   "color": "028fe5",
   "num_peers": 6,
   "num_pending_channels": 0,
   "num_active_channels": 8,
   "num_inactive_channels": 0,
   "address": [
      {
         "type": "ipv4",
         "address": "52.55.124.1",
         "port": 19735
      },
      {
         "type": "torv3",
         "address": "s5esrtw7l4uix5idxoa3lcdrihmchsk2evrtelnp6peke4rqfdjp54id.onion",
         "port": 19735
      }
   ],
   "binding": [
      {
         "type": "ipv4",
         "address": "172.31.95.0",
         "port": 19735
      }
   ],
   "version": "v0.12.0rc1",
   "blockheight": 2314748,
   "network": "testnet",
   "fees_collected_msat": 0,
   "lightning-dir": "/home/clightning4j/.lightning/testnet",
   "our_features": {
      "init": "088080080269a2",
      "node": "888080080269a2",
      "channel": "",
      "invoice": "02000000024100"
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulation, you ran your first clightning4j-node in a very tiny virtual machine, and you can start to play with all the cool stuff that core lightning has.&lt;/p&gt;

&lt;p&gt;Ah, you have also all your private data on the /cln/data dir so you will be able to move your data to another machine when you finish playing with the docker image.&lt;br&gt;
Conclusion&lt;/p&gt;

&lt;p&gt;The docker image is released in sync with core lightning (quite in sync) and the idea is to migrate all the stacks to a more performance one by removing JVM and using more of Rust and Golang. However, the system works quite well also integrates with Kotlin, so it is good to test if this will be just a side project or can be useful for someone.&lt;/p&gt;




&lt;h2&gt;
  
  
  Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;3BQ8qbn8hLdmBKEjt1Hj1Z6SiDsnjJurfU&lt;/li&gt;
&lt;li&gt;&lt;a href="https://liberapay.com/vincenzopalazzo"&gt;liberapay.com/vincenzopalazzo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/sponsors/vincenzopalazzo"&gt;Github support
&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.buymeacoffee.com/vincenzopalazzo"&gt;buymeacoffee&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Lightning donation on &lt;a href="mailto:vincenzopalazzo@lntxbot.com"&gt;vincenzopalazzo@lntxbot.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition, there is also a bolt 12 offer on my website &lt;a href="https://bruce.lnmetrics.info/donation"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or, simply connect to my ln node to grow my network :) &lt;br&gt;
&lt;a href="https://bruce.lnmetrics.info"&gt;https://bruce.lnmetrics.info&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find me on Github Vincenzo Palazzo&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CtVZ5_II--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/egao0ai5c8bkb8nzpqnp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CtVZ5_II--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/egao0ai5c8bkb8nzpqnp.png" alt="Image description" width="880" height="324"&gt;&lt;/a&gt;&lt;br&gt;
This work is sponsored by a Brink grant&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Vlang as a scripting language for docker image entry point</title>
      <dc:creator>Vincenzo Palazzo</dc:creator>
      <pubDate>Mon, 09 May 2022 05:32:52 +0000</pubDate>
      <link>https://dev.to/vincenzopalazzo/vlang-as-a-scripting-language-for-docker-image-entry-point-9kh</link>
      <guid>https://dev.to/vincenzopalazzo/vlang-as-a-scripting-language-for-docker-image-entry-point-9kh</guid>
      <description>&lt;p&gt;In this small blog post, I will describe how to use the V language (&lt;a href="https://vlang.io/"&gt;https://vlang.io/&lt;/a&gt;) as a scripting language to configure the entry point of your docker configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is V language?
&lt;/h2&gt;

&lt;p&gt;V language is a Simple language for building maintainable programs and also if a user friendling language with a syntax similar to the Go lang language, but with some additional features like mutability and generics.&lt;/p&gt;

&lt;p&gt;In addition, the v standard library contains some methods for writing a shell script in a comfortable when for people that are born in the new era and find the original shell language like bash completely messy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker image entry point
&lt;/h2&gt;

&lt;p&gt;The common usage of docker image is to isolate the environment and make a reproducible environment for an application.&lt;/p&gt;

&lt;p&gt;However, there are applications, like command-line applications that required interaction with the docker daemon to share the command with the container and return the result of the container directly to the user.&lt;/p&gt;

&lt;p&gt;This type of operation is usually done by a shell script runner by docker each time that the container is invoked. However, if the command line application is complex like Bitcoin Core, or Core lightning the bash script starts to be very complex and full of strange commands to check equality between strings to check what type of operation in the docker image the script needs to run.&lt;/p&gt;

&lt;p&gt;In addition, if managing the persistent status of docker the bash script starts to be not manageable, as a not bash friendly person that needs to resolve this complex use case with the docker image, I decided to use the V language as script language, and build a very cool script that resolves my problems.&lt;/p&gt;

&lt;p&gt;In fact, the v compiler installed in the docker image is very minimal, and usually doesn't require external dependencies, so the impact is very minimal, and the API to run the os command is very user-friendly.&lt;/p&gt;

&lt;p&gt;I build my docker image available at the following link and the pattern used in this case was to build a simple &lt;code&gt;entrypoint.sh&lt;/code&gt; file, that looks like the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt;
v run /opt/conf_env.vsh &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where the &lt;code&gt;conf_env.vsh&lt;/code&gt; looks like the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// V script to manage the envoirment lightning env
//
// author: https://github.com/vincenzopalazzo
import os

fn run_tor() {
    if os.exists('/home/clightning4j/.tor') {
        os.execute_or_panic('rm -r /home/clightning4j/.tor')
    }
    println(os.execute_or_panic('tor --runasdaemon 1').output)
    curl_res := os.execute_or_panic('curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs')
    println(curl_res.output)
    os.execute_or_panic('chown -R clightning4j /home/clightning4j/.tor')
}

fn build_ln_directory() string {
    ln_dir := os.environ()['CLIGHTNING_DATA']
    if !os.exists(ln_dir) {
        os.mkdir(ln_dir) or { panic('dir at path $ln_dir not created') }
        os.execute_or_panic('cp /opt/config $ln_dir/config')
        os.execute_or_panic('mkdir $ln_dir/plugins')
        os.execute_or_panic('cp /opt/*.sh $ln_dir/plugins/')
        os.execute_or_panic('chown -R clightning4j $ln_dir')
    }
    run_tor()
    return ln_dir
}

mut args_str := ''
for idx in 1 .. os.args.len {
    arg := os.args[idx]
    args_str += arg + ' '
}

if args_str.contains('lightning-cli') || !args_str.contains('--') {
    println(os.execute_or_panic(args_str).output)
} else {
    ln_dir := build_ln_directory()
    os.execute_or_panic('lightningd --lightning-dir=$ln_dir $args_str')
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Closing Thoughts
&lt;/h2&gt;

&lt;p&gt;If you are trying V language in with any other type of use case, please share the information with us, we are super happy to know how you are using the language. &lt;/p&gt;

&lt;p&gt;If you have any particular questions, leave a comment and follow me on Github &lt;a href="https://github.com/vincenzopalazzo"&gt;https://github.com/vincenzopalazzo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vlang</category>
      <category>docker</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
