Tag: Rust
Linked List With Rust
Linked lists are part of the most basic data structures in Computer Science. They have several advantages over arrays (Skiena, 2020):
- Overflow never occurs, unless the memory is actually full
- Insertion and deletion are simpler
- With large records, moving pointers is easier and faster
These structures use pointers to connect all the pieces in the list by giving a memory address to each item.
As a beginner in Rust, implementing a singly linked list is an opportunity to learn about dynamic memory and ownership. A crucial concept in dynamic memory is the heap: we don’t know the amount of items in the list, so this structure cannot exist in the stack memory. As each item has at most one pointer referring to it, we have unique ownership.
Tag: Boost
Using Boost.Log Part 2
The source code can be found here
As discussed in Part 1, BOOST_LOG_TRIVIAL is a quick way to have a logger in a console with a predetermined formatting. Our goal is to customize the message structure and colors.
Create a console sink
The first step is to use a new macro called BOOST_LOG_SEV that receives a custom logger lg and the severity.
namespace src = boost::log::sources;
...
int main() {
init();
src::severity_logger<trivial::severity_level> lg;
BOOST_LOG_SEV(lg, trivial::trace) << "A trace severity message";
BOOST_LOG_SEV(lg, trivial::debug) << "A debug severity message";
BOOST_LOG_SEV(lg, trivial::info) << "An informational severity message";
BOOST_LOG_SEV(lg, trivial::warning) << "A warning severity message";
BOOST_LOG_SEV(lg, trivial::error) << "An error severity message";
BOOST_LOG_SEV(lg, trivial::fatal) << "A fatal severity message";
return 0;
}
[2024-12-14 00:12:15.390463] [0x00007e195fcdf740] [debug] A debug severity message
[2024-12-14 00:12:15.390476] [0x00007e195fcdf740] [info] An informational severity message
[2024-12-14 00:12:15.390479] [0x00007e195fcdf740] [warning] A warning severity message
[2024-12-14 00:12:15.390481] [0x00007e195fcdf740] [error] An error severity message
[2024-12-14 00:12:15.390482] [0x00007e195fcdf740] [fatal] A fatal severity message
Formatting
As you can appreciate, the formatting with BOOST_LOG_SEV is the same as BOOST_LOG_TRIVIAL because Boost uses the same default sink. How do we modify the default message structure? Let’s create a custom sink that outputs to console, replacing the init method:
Tag: C++
Using Boost.Log Part 2
The source code can be found here
As discussed in Part 1, BOOST_LOG_TRIVIAL is a quick way to have a logger in a console with a predetermined formatting. Our goal is to customize the message structure and colors.
Create a console sink
The first step is to use a new macro called BOOST_LOG_SEV that receives a custom logger lg and the severity.
namespace src = boost::log::sources;
...
int main() {
init();
src::severity_logger<trivial::severity_level> lg;
BOOST_LOG_SEV(lg, trivial::trace) << "A trace severity message";
BOOST_LOG_SEV(lg, trivial::debug) << "A debug severity message";
BOOST_LOG_SEV(lg, trivial::info) << "An informational severity message";
BOOST_LOG_SEV(lg, trivial::warning) << "A warning severity message";
BOOST_LOG_SEV(lg, trivial::error) << "An error severity message";
BOOST_LOG_SEV(lg, trivial::fatal) << "A fatal severity message";
return 0;
}
[2024-12-14 00:12:15.390463] [0x00007e195fcdf740] [debug] A debug severity message
[2024-12-14 00:12:15.390476] [0x00007e195fcdf740] [info] An informational severity message
[2024-12-14 00:12:15.390479] [0x00007e195fcdf740] [warning] A warning severity message
[2024-12-14 00:12:15.390481] [0x00007e195fcdf740] [error] An error severity message
[2024-12-14 00:12:15.390482] [0x00007e195fcdf740] [fatal] A fatal severity message
Formatting
As you can appreciate, the formatting with BOOST_LOG_SEV is the same as BOOST_LOG_TRIVIAL because Boost uses the same default sink. How do we modify the default message structure? Let’s create a custom sink that outputs to console, replacing the init method:
Tag: Astronomy
My First Photo of Orion
Orion Nebula (Messier 42) is an awesome gift from the universe. It has a distance of 1400 light-years (meaning that the images we take today are from the nebula of 1400 years ago).
Today the sky was clear so I took my first photo:
Orion Nebula, exposure time of 5 seconds, 2000 ISO
It was an interesting experience, because I learnt that exposure time impact a lot due to the Earth’s rotation and that’s why you see the effect of the stars bloated. Next time I must use a lower exposure time and increase ISO.
Tag: Fpga
Xilinx USB JTAG cable installation
Assuming you have installed Xilinx ISE, this article will guide you on installing Cable Drivers for Xilinx USB JTAB Programmers. If you have problems, please check that you have not done any mistake on the primary installation.
Digilent Xilinx USB JTAG cable
Installation environment
- Fedora 23 (64 bits)
- Linux Kernel 4.2.5
- Xilinx ISE Design Suite 14.7 for Linux
Digilent Adept Runtime x86/x64
Digilent Adept Runtime package is available at Digilent website.
Tag: Linux
Xilinx USB JTAG cable installation
Assuming you have installed Xilinx ISE, this article will guide you on installing Cable Drivers for Xilinx USB JTAB Programmers. If you have problems, please check that you have not done any mistake on the primary installation.
Digilent Xilinx USB JTAG cable
Installation environment
- Fedora 23 (64 bits)
- Linux Kernel 4.2.5
- Xilinx ISE Design Suite 14.7 for Linux
Digilent Adept Runtime x86/x64
Digilent Adept Runtime package is available at Digilent website.