Showing posts with label howto. Show all posts
Showing posts with label howto. Show all posts

18 December, 2023

 

 

To add a watermark to all of the images in a directory:

1. install imagemagick

sudo apt-get install imagemagick

2.  run the following script:

counter=1; total=$(ls my_files_dir/* | wc -l); for img in my_files_dir/*; do echo "Processing file $counter of $total: $img"; convert "$img" -gravity center -pointsize 35 -fill 'maroon' -draw "text 0,0 'my watermark text'" "$img"; ((counter++)); done

22 September, 2023

 If Android Studio is not showing previews for markdown files, do the following:

1. Go to menu Help -> Find Action(Ctrl+Shift+A) -> Choose Boot Time Java for the IDE -> and select JetBrains Runtime with JCEF


2. Restart the IDE:



3. Now the preview should be working:





04 August, 2023

What am I using as a reference when creating a new Android project from scratch:

    My primary reference is the source code for the Kodeko course "Real-World Android by Tutorials" (https://www.kodeco.com/books/real-world-android-by-tutorials, https://github.com/kodecocodes/adva-materials/tree/editions/2.0). This course follows a CLEAN Architecture approach and maintains a clear separation of layers. The course was last updated in August 2022 and relies on XML Views and RXJava, so I’m rewriting the code using Jetpack Compose and Kotlin Flows. I also make adjustments to naming conventions and packaging. My newly created project will have one module only but some packages might be moved to their own modules later if needed.

    For the Jetpack Compose part I use another Kodeko course, Jetpack Compose by Tutorials. Again, they use Material 2 and I am rewriting some parts using Material 3.

    As a companion to the above the book ‘Clean Architecture for Android’ by Eran Boudjnah has very nice diagrams, especially in the first part of the book.

    There's another notable source from 2021 - one of the famous CommonsWare’s books Exploring Android. It is quite simple in the sense that it doesn't have any domain layer, but it provides an excellent example of a Reactive Architecture implementation in Android. Unfortunately Mark Murphy is no longer updating CommonsWare books.

    These sources are my go-to references when starting a new Android project. The official docs from Google go without saying, of course.

21 March, 2018

How to unblock all IPs banned by fail2ban on a Digital Ocean Ubuntu 16.04 droplet

1. find the location of the fail2ban database file:

sudo fail2ban-client get dbfile  
 
 Current database file is:
`- /var/lib/fail2ban/fail2ban.sqlite3

2. stop the fail2ban service:

sudo service fail2ban stop

3. delete the fail2ban database file:

sudo rm /var/lib/fail2ban/fail2ban.sqlite3

4. start the fail2ban service:

sudo service fail2ban start

5. check the list of all packet filter rules in the Linux kernel:


sudo iptables -L

23 August, 2017

Deploying a Spring application as a Linux service behind nginx (Ubuntu Server 16.04)


1. Create, build and run locally the application

The application to deploy is a JPA Data with REST from the official spring docs. But, instead of the system wide gradle mentioned in the Spring documentation we'll be using the ./gradlew wrapper since this is the recommended way of doing things. The gradle wrapper is usually committed to the source control.

20 January, 2017

Android enums are out of fashion (again)

Back in 2011 Google removed from its Performance Tips the advice to avoid enums. Today I've been rewriting an older app and wanted to add a feature that allows you to change the EditTexts' size using a PreferenceFragmentCompat at runtime. It would have a low, medium and big setting and the sizes would be resolution independent. A low, medium and big trio is asking for an enum and apparently enums were already ok with Android SDK.

But then I decided yet to check this again.
And it turns out that nowadays using an @IntDef is the kosher way of doing things.