Showing posts with label Publications. Show all posts
Showing posts with label Publications. Show all posts

12/01/2025

[Android] Sprescia app for run activity tracking

No it is not Christmas today, but here is another free, no ads, no trackers, no data collection, minimalistic app to track your run activity!

Built for Android 14+ using help from ChatGPT and icons from SVG Repo this app writes to a local Rooom DB in 1 table: run

Run view allows you to add, edit, delete run details and calculates average speed for each entry, comparing it with the previous one, giving you a quick view of your training progression. You can also export and import data to/from csv for quick backup and restore logic.

Daily stats view allows you to see daily run data and compare it to previous runs using key metrics: steps, average speed, distance, time.

Monthly stats view provides the same capability but averages the data grouping per month instead.

You can find the Sprescia project on my GitHub



[Android] MaiCar app for car expense management (refuels and maintenance)

Finally a free, no ads, no trackers, no data collection, minimalistic app to track your car expenses!

Built for Android 14+ using help from ChatGPT and icons from SVG Repo this app writes to a local Rooom DB in 2 tables: fuel and maintenance

Fuel view allows you to add, edit, delete refuel details (partial and full tank) and calculates efficiency for each entry, comparing it with the previous one, giving you a quick view of your trip efficiency progression.

Maintenance view allows you to add, edit, delete maintenance details for multiple maintenance types, it also allows you to filter the view on a specific maintenance type to quickly find a specific item.

Both views allow you to export and import data to/from csv for quick backup and restore logic.

You can find the MaiCar project on my GitHub




26/09/2024

[Java] Using annotation processing (and validating it) to execute logic at runtime

Sample project showcasing how to use annotations to perform runtime logic to log changes in object values.

Remember it is a SAMPLE, so obviously (lazy me) most null-safe checks and so are not included and obviously some logic is a showcase, should be replaced with a real business scenario to implement.

In this SAMPLE, we tag fields to be included in a diff logic to then print to output when those fields values change by comparing two instances of the same object.

Logic can obviously be made much more complex including collections and maps and whatnot (Java Generics are your friends there).

Also worth mentioning JaVers can do most of it for you, unless you have fancy business requirements that force you to write custom code..


Key points:

- How to create an annotation

- How to create an annotation processor to validate the annotation parameters at compile time

- How to register an annotation processor

- How to configure a multi-module Maven project to use a custom annotation processor (also, in the pom of the root project ensure the module containing the processor is built BEFORE everything else)

- How to test an annotation processor by generating classes at runtime and trigger compilation tasks agains them. Includes verifying compilation warnings are properly triggered as expected.

- How to use reflection to get fields annotated with a given annotation (and then execute whatever logic on them)

- How to use reflection to invoke methods (including static methods)


The full project is available on my GitHub repo with commented code: https://github.com/steghio/diff-annotation-processing

26/09/2021

[Unity] Fury Farm

A sample 3D shooter game made with Unity.

Get the code from the repo or play online.

The animals have gone mad, defend your farm from their rage.

Controls:

AD - move left/right

SPACE - shoot

R - restart level

Q - quit

Interesting notes:

  • FindObjectOfType<OBJECT_NAME>(); get an object in a script without binding it in input
  • "this" is actually gameObject within a script
  • InvokeRepeating("METHOD_NAME", START_DELAY, REPEAT_RATE); added to an Awake or Start method, will ensure the given method is called repeatedly according to configuration
  • Random.Range(MIN, MAX) gives a random float between MIN and MAX both inclusive
  • WebGL default screen size is 960x600, the game default aspect is "Free Aspect" (top left of Game tab), change in File->Build Settings->Player Settings the resolution for WebGL to match a different one and set the Game aspect to the same to test how would it look like on the user screen
  • Cooldown logic can be added by tracking a float variable and updating it with -Time.deltaTime every frame, then checking if its value is less than some threshold to allow the player to execute the action again

24/09/2021

[Unity] Fury Skies

A sample 3D plane flying project made with Unity.

Get the code from the repo or play online.

Much anticipated sequel to the exciting Fury Roads, it's time to elevate your rage to the skies.

Controls:

WS - pitch (up/down)

SPACE - turbo

X - invert pitch controls (down/up)

R - restart level

Q - quit

PrintScreen - take a screenshot of that beauty in action

Alt+F4 - close your browser and go take a walk with your mask on

CapsLock - bring that rage to the comments section

 

Interesting notes:

  • GameObject component inheritance seems to behave differently from OOP inheritance, not all parent Components are inherited by the children (but are accessible via GetComponentInParent)
  • Time.deltaTime can be used in transforms to equalize values between different systems running at different framerates
  • FixedUpdate should be used to update physics related stuff (eg movement)
  • 3D is weird: X axis = depth, Y axis = height, Z axis = width. So movement forward is on Z axis. Camera is not considered in the default transforms. I understand this is because Z axis is the direction the player is facing, making "forward" a Z change rather than X.
  • Instantiate(PREFAB_PARTICLE_OBJECT, transform.position, Quaternion.identity).Play(); will spawn the particle effects in the current object position. Invoke this before destroying whatever you collided with and get an explosion animation.
  • 3D particles are weird, provide a material, shape and color or you get pink cubes even if you change the startColor
  • Input.GetAxis("Vertical") gives the current player input on Y axis (even in 3D)
  • 3D is weird part2: right side view of an object in coordinates 0,0,0 is a camera with Y axis rotation -90 and X axis delta of +10

23/09/2021

[Unity] Fury Roads

A sample 3D car driving project made with Unity.

Get the code from the repo or play online.

How to play is in readme or in game menu. Hit the barrier, avoid the boulder, be fast, release the rage.

Interesting notes:

  • AudioSource.PlayOneShot: use this passing an AudioClip as input to play a sound file once when triggered
  • Input.GetKeyDown(KeyCode): use this to determine whether the user pressed a particular key and avoid multiple triggers if the key was pressed over multiple frames
  • GameObject.SetActive: parent can trigger child objects active/inactive with this, eg to swap models for same object on a certain event
  • LateUpdate is invoked after Update, so if you have a follow camera, update position there to avoid jerky movement
  • transform.Translate: move object (slide)
  • transform.Rotate: move object (rotate)
  • Vector3 has many static predefined vectors available eg: forward, up, one, zero
  • Can tag objects and then check whether interaction happened with an object type looking at its tag eg: collision.gameObject.CompareTag(TAG) will be true if this object collided with TAG object
  • Time.timeScale set to 0 stops game time, but can still read player inputs
  • SceneManager requires import (using) UnityEngine.SceneManagement

03/06/2021

[Java] MrJack text based videogame

MrJack is a nice boardgame for two players, an inspector and a thief, that take alternating actions trying to win within 8 turns. A full game takes 30 minutes to one hour usually.

The game features an hexagonal board with different cell types and 8 character tokens, each with a unique ability.

Players must carefully plan each move since luck is not the main factor in their success.

You can find FAQ, rules and reviews about it on boardgamegeek.

I propose a videogame implementation which is text based and uses ASCII art to represent the board, prompting players for actions via command line.

The first version 1.0.0 is fully playable and can be run as a Java application. You can find the full description as well as the source code in mrjack repository on my Github.

The code is released under a CreativeCommons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.

I am NOT affiliated with HurricanGames and/or the creators of the board game and do NOT own copyrights to the game.

14/09/2020

Tesla Model 3 1000km test review

I was considering buying an electric car and Tesla is an obvious choice, so I decided to rent a Model 3 for a weekend and drove it about 1000km in order to evaluate it.

I am from Genova, Italy but live in Zurich, Switzerland so my use case is to find a car that allows me to enjoy a weekend/day trip in Switzerland and occasionally can comfortably bring me to Genova without increasing the total trip time too much (over 30 minutes) due to charging needs.

With a common ICE car, the fastest one way trip without any rest/fuel stop can be done in about 5-5.30 hours; on average it takes 6-6.30 due to queues (damn Gotthard) and rarely it is 7+ hours.

So what about an EV? Here is my review after a 960km round trip in two days.

27/05/2020

[C++] Graph adjacency list shortest path BFS

Here is a simple graph model using adjacency lists. The edges are undirected and we will also track edge weights, but ignore them at this time for the shortest path calculation between two given points (therefore we can use a simple BFS).

25/10/2019

[C++] Rock! Paper! Scissors! Fight!

This C++ exercise implements a full game of Rock, Paper, Scissors against an AI opponent. Check the Rock! Paper! Scissors! Fight! project on GitHub.

21/09/2019

[Android] Revive MyTracks app

MyTracks was the best GPS tracking application. Lightweight, simple to use, well integrated with Google Drive, no extra crap. Until the fire nation attacked Google decided to kill it hoping you would switch to that pile of manure that is Google fit.

As valid alternatives I could only find ViewRanger or Open GPS Tracker but they are just not as good in my opinion.

The way Google killed the app, was to revoke the API keys it used. Meaning that by swapping those keys out with ones you own, everything works as expected.

Interested? Then check out the revive MyTracks project on Github

22/03/2018

[Windows] Blood Bowl 2 offline league manager

If you are a fan of Blood Bowl and purchased either Blood Bowl 2 or Blood Bowl 2: Legendary Edition on PC, you might be - as many others - extremely disappointed at the lack of an offline (hotseat) league option.

This command line tool provides capability to edit - AT YOUR OWN RISK - the SQLite database where team and player information is stored so that, with a bit of paper tracking, you can update the stats after a friendly match.

This tool is not a cheat/trainer!, it only allows you to edit offline team data, much like the "Custom team" feature of the Legendary Edition, except that feature is only usable at team creation.
This tool is based on the rules found in the Blood Bowl Living Rulebook version 6 and might NOT reflect the actual rules implemented in the game - yet, since I saw some rule tables in the DB, and need to investigate further there..

This tool is an alpha version!, it works without hiccups - but its a barebone tool with some open todos and limitations and the user experience can be further improved, but it works as a starting point if you, like me, crave this feature! :)

You can find the BBManager project on my GitHub and download the compiled jar as well.

Please refer to the project README to find out how to use the tool.

03/02/2018

[Java] Minesweeper

Minesweeper. Do I need to say more?

The most interesting part is how to efficiently and randomly create the board.

There are many, many, many (and more) ways of doing so, I'll describe my idea here:
  • the board size for an average game will not be so big that I can't afford to store an additional O(N^2) piece of information. This is the key point, without this assumption, the rest is not applicable!
  • if I do store that piece of information, then I can acceptably randomize it in O(N)
  • since the random distribution is from 1 to board_size (all the valid spots for a mine, N^2 spots) but the board is actually a matrix and therefore has 2 indices, I need a way to convert from the random spot to the matrix spot reliably
  • if we have too many mines, it's best to randomly place empty spots instead
  • after the initial placement, we need a pass on the matrix to fill the remaining spots with the correct count of the neighbouring mines
The randomization can be done with a call to Collections.shuffle, while the conversion from board spot to the matrix spot can be done easily after some considerations. Consider this sample matrix:

1 2 3
4 5 6
7 8 9

Given any of those numbers, can you determine the exact matrix location? Meaning can you return a i and j that indicate where that number would be placed in the matrix? For example 1 would be 0,0 and 8 would be 2,1.

Yes, but rows and columns have to be treated differently AND, since we do care about randomness but not precision, we can even avoid adjusting the result to reflect the exact position - we can't get the same position twice anyway.

For columns we can simply use the modulus operator, this way the last column is 0 and not 2, but since we are going for random spots we don't care to correct it. Basically we are flipping the matrix over on the Y axis :)

For rows instead, we can simply use division and then round the values UP to get something in range 1 .. board_length which we convert to 0-based.

The method looks like this (can be reduced to fewer lines, but debugging is easier this way!):

 private int decodeCoordinate(int value, boolean is_column){  
     //column we can find with modulus  
     //last column is 0 if we do this calculation, but we are going for random spots so we don't care to correct it  
     if(is_column) return value % fieldLength;  
   
     //rows we can find with a normal division and then picking the ceiling of it, converting to 0-based!  
     double a = (double) value, b = (double) fieldLength;  
     int c = (int) Math.ceil(a / b);  
     return c - 1;  
   }  


You can check the implementation on my Gist alongside some test cases in MinesweeperJTests. I plan to pick this up again to finish it, so some parts are extra and do not yet tie in to the final code :)


14/05/2017

[Java] Xchange me, sir - Sample REST project to get xrates to EUR

Project description Xchange me, sir:

Implement a simple foreign exchange rate service that uses data provided by the European Central Bank. Provide a REST API to retrieve the exchange rate to EUR from any other currency provided by the ECB and allow querying current (https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml) and past (https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml) data. Use an asynchronous job to retrieve and update the xrates storing them locally in memory and have the REST API use the data in memory to return this information.

12/03/2017

[Python] BloggerBackup script to backup Blogger posts

This script allows users to quickly download posts from their Blogger blog in order to keep a backup copy. On Windows there is the amazing BloggerBackupUtility but sadly that's not available for Linux as well, hence this small project comes to life.

You can get the utility here or check out the source code here. To run it, you must have Python 3 installed.

Usage is:

 bloggerbackup --api-key <API key> --blog <blog URL> --backup-dir <backup directory> [--start-date <date>] [--end-date <date>] [--verbose]  

options:

   --help - prints this help  
   
   --api-key <api key> - mandatory API key used to issue queries  
   
   --blog <blog URL> - mandatory URL of the blog to operate on  
   
   --backup-dir <backup directory> - mandatory directory where to put the posts backup  
   
   --start-date <date> - optional, date from which to begin fetching posts in RFC 3339 format: yyyy-MM-ddTHH:mm:ss+HH:mm  
   
   --end-date <date> - optional, date where to stop fetching posts in RFC 3339 format: yyyy-MM-ddTHH:mm:ss+HH:mm  
   
   --verbose - optional, prints debug information while processing  

The script is extremely barebone and definitely improvable. Also, it requires you to setup an own API key in order to issue queries in the free tier. To do so, visit the Google credentials page.

20/12/2016

Facebook and Airbnb login bug, now you are someone else

Well, everyone nowadays is running around trying to spot and fix bugs for money and I just stumble upon someone else's information for free.

This is an unexpected Christmas gift given it happened close to this huge fail from VISA, which makes it possible to guess full credit card details in a frighteningly fast amount of time. So read that article first, and then image what could someone do if they had all your personal info, including partial credit card data.

01/11/2015

[Java Spring] Plan my Groove

Plan my Groove is a simple Java7+ application to expose a REST API to let users remotely execute Groovy scripts

It was tested on both JDK7 and JDK8 and as of now it exposes functionality to:


  • submit a job
  • list and search for jobs
  • retrieve the result of a job
  • delete a job


Where a job is a simple Groovy script. It's possible to submit multiple jobs simultaneously and also run them at the same time.

It relies heavily on the RepositoryRestResource functionality offered by the Spring framework to provide a set of RESTful services.

Find the source code at https://github.com/steghio/PlanMyGroove and for more information, read the documentation at https://github.com/steghio/PlanMyGroove/blob/master/plan_my_groove_manual.pdf

10/07/2015

[TIBCO] BusinessWorks 6 Compress Plugin for TAR and GZ

Happy to announce the availability of the 1.2.0.FINAL version of the TIBCO BW6 Compress palette. It supports ZIP, GZ and TAR formatsThis is developed in my free time and it's not endorsed, verified or supported by TIBCO in any way (yet?).

It uses Apache Common Compress library 1.9 with no modifications and it's packaged within the plugin.

Online docs are (temporarily) available at: http://digilander.libero.it/otacoconvention/archivi/TIBCO_BW6_Compress_plugin_doc/index.html and can also be accessed from BusinessStudio by selecting the activity and pressing F1 (requires internet connection).

I would urge anyone wanting to try this to take all necessary precautions even though the version number says FINAL

Check GitHub https://github.com/steghio/TIBCO_BW6_Compress_Plugin/
for the source code, sample project, Eclipse (BW6) installer. If you want to manipulate it, READ THE GUIDE first.

History: first release 1.0.0.FINAL

26/06/2015

[TIBCO] BusinessWorks 6 Compress Plugin for ZIP

UPDATE: check latest version 1.2.0.FINAL here

Happy to announce the availability of the 1.0.0.FINAL version of the TIBCO BW6 Compress palette. It includes Zip and Unzip activities. This is developed in my free time and it's not endorsed, verified or supported by TIBCO in any way (yet?).

It uses Apache Common Compress library 1.8.1 with no modifications and it's packaged within the plugin.