[Thiago Cafe] Programming is fun!

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember

OpenCV Mat without copying and weird memory ownership

(Posted 2025-04-30 06:29:52)

Recently I found an interesting OpenCV behaviour.

OpenCV cv::Mat is built to be easy to use. It will allocate, free and reallocate it's own internal data. That's fine for most of the uses, but what if you are sensitive to extra memory allocations?

As you might expect, C++ developers very often track the memory ownership of any allocated piece of memory, especially when copying memory is not an option.

To use cv::Mat without copying the buffer, you can use this class constructor that does not own the memory:

Read More »

Using flutter with native resources on apple silicon processors

(Posted 2024-12-20 05:23:23)

If you are building a flutter application for apple processors using Silicon processors (M1+) and dealing with native packages for things such as playing a sound, you maybe encountered this error:

Read More »

Adding your rust project to brew

(Posted 2024-09-04 02:06:39)

This is a body example Please remove it and replace with your content

Read More »

Book recommendation - Rust

(Posted 2024-08-15 04:34:07)

I received a post from a friend of mine of a guy who developed games in rust and who also developed a small game engine in rust ranting about the language and about the borrow checker.

I sympathize with the guy - up to a certain point - as I had a similar experience

Read More »

Deserialising binary data in Rust

(Posted 2024-08-14 17:11:15)

One common way to deal with serialised data in C++ is to map to a struct, but in Rust with memory ownership and some smart memory optimizations, it is a little more complicated.

For example, let's say a producer in C++ serialises this message:

struct book_msg {  
    uint8_t major_version, // byte 0: message major version  
    uint8_t minor_version, // byte 1: message minor version  
    uint8_t msg_type,      // byte 2: message type  
    uint8_t title[20]      // byte 3-23: title of the book  
}
// ....
auto msg = create_msg();
comm.send(&msg, sizeof(book_msg));

How can we deserialise that in Rust?

Read More »

RSS feed added to Thiago Cafe!

(Posted 2024-08-03 00:22:16)

A Rust developer on twitter posted:

"It would be nice to reed updates to your blog in an RSS feed."

Indeed that is a great idea and I implemented on Texted 0.3.6!

Now you can subscribe to this blog using your preferred RSS client using the url https://thiagocafe.com/rss

Happy reading!

Read More »

Quick tip: Type of tokio spawn return

(Posted 2024-06-03 19:03:45)

When I was implementing the metrics task using tokio, I wanted to save the result JoinHandle in a struct and I saw the type being displayed by the IDE: JoinHandle<?>

What does it mean?

Read More »

Another way to deserialise DateTime in Rust

(Posted 2024-06-02 20:53:59)

In a previous post, I wanted to deserialise a date from a Toml file and implemented the Deserialize trait for a type NaiveDate. When I was implementing metrics, I had to do it again, but implement serialise and deserialise for NaiveDate and I found another way, possibly simpler, to serialise and deserialise NaiveDate.

First: add derive support to your Cargo.toml

Read More »

Installing a Nerd Font in Ubuntu

(Posted 2024-05-07 21:45:41)

This is a simple step-by-step guide to install nerd fonts in Ubuntu

Downloading

Download the font you want from Nerd Fonts website https://www.nerdfonts.com/font-downloads

Read More »

How to deserialise DateTime from toml configuration

(Posted 2024-04-25 17:07:56)

When implementing a new configuration parameter for Texted, I needed something to represent the date the blog started.

When looking into the TOML website, I was fortunate to discover that it has a data type for dates, so I could create the new parameter

blog_start_date = 2016-06-25

However, my fortune was gone as I found that the Toml crate does not support deserialising.

Read More »

Pages: 1 2 3 4

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember