Laur IVAN

Stream from a String Instead of CIN in C++

Posted by in Software

TL;DR: You can stream from a string instead of STDIN. Code is simple and is listed below. A project I did recently had a requirement to overload the >> operator use and STDIN to load data. The problem was not the overload itself, but the fact that testing would introduce a manual side. To get around that, I needed a way to stream data from a string instead of STDIN. The solution is presented below:

To use it, all you need to do is: Create a string:

It…read more

Simple Floating Point Equality Check in C++

Posted by in Software

TL;DR: Here you can see a handmade comparison function for floating point values. While working on a C++ project using templates, I had to perform an equality to see if two values are identical. While the == is OK for integer values, it is not really OK for floating point values. At that point, you have several options: Write inline code depending on instantiation (type conditions) Write a macro (I’m not fond of macros really) Write a (global) function I’m sure there are others… Solution I’ve chose to write a…read more

Build a Simple Makefile

Posted by in Software

TL;DR: If you don’t have anything better to do, create Makefiles by hand :) Gist here. The other day I went back to origins with building a small C++ project. With modern tools, all went OK. However, deployment was a bit of a problem, in the sense the host had an obsolete toolchain: Me: GCC 5.2.x, CMAKE 3.3 … Host: GCC 4.7.x, no CMAKE :( So, I had to build a makefile by hand! Following some best practices, I’ve devised a simple Makefile with following sections: A declaration section, where…read more

C Optimisation – 2005 style

Posted by in Software

TL;DR: This post is about an experience I had in 2004 and it’s part of my consolidating technical posts I wrote in time. It may or may not be relevant to today’s technologies. I was trying to optimize a bit of code and found out that 2 if() statements are quicker than a case with true/false. and an if/else case is WAY quicker!!! All with various optimisation levels (from nothing to O3 to O3 + architecture optimisations). Odd. one might believe that the switch/case statement would create a static jump…read more

iPhone

Posted by in Hardware

Note: This is a really old post transferred from Laurii for historical and consolidation purposes. Last week I’ve got an iPhone! :) 8G. Cute little toy… I’ve managed to compile the toolchain for linux last night and installed my first compiled app: the Terminal.app. I’m quite pleased with the results. Now I have the following tasks to do: Get visualidad.com up and running with the gnosis feature and search Get romanii.net front page design done and make it run the feeder. Write the grand iphone app I was thinking about…read more

DBus and Qt programming

Posted by in Software

For the past few days I’ve been trying to get more complex data sent via D-Bus. As one would say here in Ireland: Je’zus H. Christ Playing with python was easy. There are lots of examples on communicating complex data structures. But with Qt… It’s a bit more complex, because there are only a set of simple examples. A little experiment: If you find this post and ad below useful, please check the ad out :-)

Arrgh!

Posted by in Random, Software

Well, I’ve been writing a piece of code today and it took me 3 hours to realise that strcmp(txt, “message”) was giving me a segfault.. because it doesn’t accept implicit parameter. putting a:

works… My excuse today is that i feel very bad (have a horrible cold) and i’m staying @ home. First sick day in ages!!! — This is a really old post published originally on my blogspot blog A little experiment: If you find this post and ad below useful, please check the ad out :-)