Back to business

So I’m finally back from my one week break. I’m somewhat disappointed with my lack of exercising these days, and much of it boils down to my sciatica interfering when I start working out. That aside, it’s been a roller coaster of emotions.


For starters I moved my laptop to use elementaryOS, and so far I have no regrets. It’s been a delightful experience. I think the next iteration of it is around the corner (maybe?) with the next Ubuntu LTS and it’s going to be a hell of an upgrade. What I worry at the moment is the lack of updates in Spotify I hope that when Ubuntu LTS kicks in they finally update their client to use a recent version of libgcrypt.

As for my application. I’ve been pondering for a while what to do with the user interface as it’s been a very stressful task of bringing something good to the table. My fault lies within the need “to be original”… sadly original these days is incredibly hard so I’m going to focus on bringing a sane and solid experience even if the design in the end reeks of “boring”. It really stresses me as while part of me want to provide something really solid I can’t come up with a good interface without sacrificing something. Well, tomorrow I’ll be sitting once again sketching a new and predictable design.

I’m no designer though… so all I can do is just try.

Looking back: OpenSUSE 42.1 with latest KDE packages

I’ve been killing some time with other Linux distributions. As far as I can tell one of my favorite Desktop Environments is still struggling out there. plasmashell crashes everywhere, right now the right side of the panel is a mess with icons overlapping on each other. It makes me a sad penguin!

I think… in 2015 I just stopped caring about the current progress of KDE… as much as it hurts to say. Amusingly–for some–I’m looking forward to see the next iteration of elementary OS or maybe Linux Mint Cinnamon. The next iteration of Ubuntu LTS is around the corner needless to say, so I’m guessing that both elementary OS and Linux Mint will be ready when the time comes.

I am looking forward to that at least. I am glad that I chose to test over in a virtual box before installing this on my laptop, else I would have been pretty upset.

As for OpenSUSE 42.1 (Leap) I got no complains whatsoever. It seems relatively stable, excluding the KDE problem as that’s a problem that lies with upstream, not OpenSUSE team. I got Spotify working in less than 10 minutes, sufficed to say I’m impressed on that since last time I had to hop through a lot of obstacles just to get it working.

Well, I hope 2016 is a fruitful one for Linux users. I also hope that KDE finally stabilizes this year.

Chasing the butterflies in GDB

You know when you are chasing bugs it can take a lot of time and energy. While I’m still fatigued I ran into a small design problem, a decision I wrote without really thinking how QNetworkReply would react thus I ran into a lot of crashes. See, crashes you at least have info to work with as the GDB would stop and deliver the frames that you will later check.

When it comes to CPU hog though, everything becomes a chase. Sometimes you either require gut feeling, or a lot of poking through the threads to see if a thread is stuck in a loop. Sadly, due to my limited experience with GDB I just can’t say “hey, alert me if you are busting a nut over there”.

Before I go on, the reason I ran into this specific problem was because I’m taking advantage of QObject parent/child relation. At the same time I’ve been moving away from pointers or anything heap related unless I really require them, which so far I haven’t had the need. This also means less memory management for me. So, if a QObject that is a parent dies, it takes the children along with it, which is incredibly ideal for me.

See, these butterflies I’m talking about aren’t real. I made the mistake of doing a test with data that is 10 years old, with address that I have to poll with QNAM. There’s a lot of redirection/error handling that needs to be in place–which I have taken care of–so I noticed that a thread (apparently a HTTP Thread by NAM) was hogging a core for itself, then after 30 seconds to a minute it would stop/terminate. My first thought was to poke the parsers, since last time I ran into a loop problem as they weren’t able to handle a instruction so it went into a loop. I think, maybe some wouldn’t call it CPU hog as to be honest said CPU hog stopped.

I got fed up; it was a dead end. If there’s a problem with my source code, I can’t detect it. I’m flushing QNetworkReplies as safely as I can, aborting them as safely as I can. So… time to go with a fresh test case. I’m using recent URLs of updated sites and have noticed that there’s no CPU hog anymore. Granted, I still have to keep testing.

I feel like I wasted a day though. A dead end with no clue. It’s a bit frustrating as all these speculations of a memory/cpu hog problem wasn’t real, or maybe it is and I haven’t really scratched the surface of it. On the bright side I cleaned up an class and its behavior is more predictable than before.

On a side note, I feel like I’m doing premature optimization and I should really stop. There has to be a legitimate issue before I jump into these types of searches.

Easy steps to move away from GMail

2016-01-12 (1)

So if you are like me, paranoid and all then by now you have been wondering “how to move away from gmail”. There are e-mail services like Fastmail (check my sidebar) that offers to import from gmail, but it can only be done once else you might fall into duplication hell. Today I’m going to go over what I did:

Starting fresh

Wait, what? You deleted all your e-mails? No, of course not. I have a decade worth of e-mail and I can’t be bothered to go through all that data. First step is to go to Google Takeout and back up your data. Back up your mail data and download the archive when it’s done.

I did want to start fresh. There’s a catch on why though, I don’t need to keep track of my e-mails. There are people that do have to keep track of them maybe due to work.

Use a encryption tools like Veracrypt, Bitlocker, etc.

2016-01-12 (1)

While Bitlocker gets a bad rap for not being open source thus not being able to audit [insert childish “b-but it’s Micro$soft” comment]. What I’ve read from it personally I consider it safe as long as you don’t back up your recovery keys to Microsoft. If you have invested yourself in Windows please do yourself a favor and research more about Bitlocker, else you could also completely encrypt your physical volume with Veracrypt.

The point of using these tools is to create a container, size may vary due to your mbox file. I will continue explaining later in this post.

Choose your e-mail client

Personally there are many ways to access your mbox file. Heck if you wanted you could create a virtual pc (virtual box) with linux, all encrypted with your mbox file in it and read it through Thunderbird. So it would go like this (virtual image fixed size gets to a Veracrypt container, load the image whenever you want with Virtual Box).

That’s too complex, seriously. What I did was simple, I chose/downloaded Thunderbird from Portable-Apps and installed it in my C:/ to later move it to my Veracrypt container.

Install ImportExport Tools for Thunderbird

Installing portable Thunderbird was the first step. Now install the ImportExport tools because with that tool you can import your mbox file to Thunderbird. Note that this process while take minutes to complete if the mbox is too big.

Let it index

This also may take minutes or hours. Once you have finished importing your mbox, let Thunderbird finish indexing.

Calculate the size of your Thunderbird portable folder

2016-01-12 (2)

Once it has finished indexing, go to the installation folder of Thunderbird and calculate how big it is. Let’s assume that it’s 2GB, so go open up Veracrypt and create a container around 2.5GB or 3GB.

Move your thunderbird installation

Since this is a portable edition of Thunderbird you can just move the folder to the container. The point of this is that you can put your container in a USB and use it whenever you want.

Time to delete

2016-01-12 (4)

Please ensure that your container has all the data before deleting.

Delete all the data from your gmail account and the initial installation folder of thunderbird. We don’t want that data lying in your personal pc unencrypted do we?

Upload it to the cloud

You can upload it to Sync or Dropbox if you feel like. I prefer Sync because you can upload it and move it to the Vault that way it won’t be deleted by anyone.

Enjoy your privacy, and peace of mind. Congratulations your data is no longer on Gmail. Now with your data safeguarded on the cloud + encrypted, you can start using a fresh e-mail address. Do keep in mind that instead of using your real address, you can create aliases like if you sign up to Facebook or Pinterest you could say [alias]+[folder] where as alias is linked to your real account, and +folder is where you want the e-mail to go.

So consider the possibility of a site getting hacked, and said site uses a weak hashing algorithm (heck, it could even be in plaintext). Using an alias will buy you time to change your e-mail password if it turns out that you used the same password in both accounts. The hackers will have to go through lengths to actually find your real account. Plus, they also can’t log in to your Paypal as the e-mail they got is an alias, taking in account that you also use different passwords. So yea, you get to buy time on all accounts. If you liked this, do consider Fastmail services check my sidebar.

The weird case of proxy model

Rest in peace, David Bowie


So basically I spent the day working with Qt’s proxy model. I didn’t get anything done, literally. I ran into a really weird problem, the proxy model I was working on wasn’t propagating methods like data. I added them both in the source code and header, nada, nothing! I’m baffled with this behavior, my class inherited QSortFilterProxyModel and as the documentation states methods like data are virtual, thus I can override them. Sadly, I wasn’t near anywhere that.

I know the proxy model was working. Why? It rendered the rows equally to the model’s rowCount. So, I’m baffled indeed. Whatever it inherited it certainly wasn’t QSortFilterProxyModel, my guess is that it called directly the abstract method…

But why data… god knows. I know I tried to override a few methods, and to my surprise I couldn’t get anything working with index, and parent.

Hopefully tomorrow I’ll have better results…

sweet baby jesus, fixing typo

The weird case of foreign languages

I have noticed over the months I have been working on my app that managing foreign languages like Japanese, Chinese, Korean, etc takes a memory hit to the point that it spikes up the memory usage–as one would expect. Sure, I expect more memory usage… but we are talking about a spike from 60mb (normal usage) to 80-100mb usage per entry–thus I was forced to call garbage collector manually as I couldn’t wait for the QML/JavaScript engine to do the clean up when there’s “inactivity”.

So, I was worried and added initial linux support to my app (never been planned to be released under linux) and found out that languages such as Japanese walks a fine line of 40mb memory usage. The garbage collector works twice as fast as well. For example, in Windows I’d call garbage collector and it doesn’t do it that fast. In linux? Blazing fast. It’s not much about the speedness of how fast it takes to free the memory, it’s the usage. I’m talking that Windows still takes 60-80mb+ (and up) while the linux build keeps walking the 40-50mb line.

Now, initially I suspected a memory leak, but that wasn’t the case. The Windows build just takes that much memory, and it worries me. Part of what keeps me at ease is that since this will be an android application; I can expect the same behavior that I get here in my linux mint in Android. Memory will be freed and the usage will be kept at minimum.

Granted: Pure naked eye seeing memory usage is not enough to suggest there’s a memory leak or that there’s a memory mismanagement, that’s the job of a profiler After running valgrind a few times I couldn’t find any memory leak just petty warnings, so I proceeded to guard against it, well, it wasn’t much about guarding as I honestly needed to free the objects that are no longer needed after X time. Plus, I also rationalized the usage that Windows is just being Windows… maybe Qt is pulling something that requires big allocations in Windows, but not in Linux for whatever reason. I do think that it has something to do with the font mechanism in general… but who knows at this point.

Spotting a minty taste

My family threw a party, but due to age, and humidity’s tag team partner, dust, it has decimated a lot of the music CDs over time. Plus my family track of music hasn’t been updated for decades so I was at my wits end since I refused to be exposed to more christmas music… seriously over the year it just…. gets unbearable, to know I have the potential to be grinch, huh.

Well, I came with the idea of connecting my Linux Mint powered laptop to the audio system but I didn’t have the cables to do so either. Luckily there was a stereo jack to 2RCA cable in my room–that I didn’t even know about–so basically the result became this:


Linux Mint, being a derivative of Ubuntu LTS release, I didn’t have to follow my own guide of fixing Spotify in Ubuntu Vivid… which makes me wonder if Spotify finally fixed their build. I’m a happy Spotify user, and I’d like to use the client in linux, not the weird web interface. Heck, you know, you might as well release the web client for linux.

I’ll elaborate:

I installed Fastmail’s Android application to access my mail weeks ago, and I noticed that their client is actually the web application embedded with a browser so all it does is API calls to the main servers and store whatever offline data it needs to.

It’s an option, only if providing the client to linux is hard for them. [avoid ranting about mostly clueless users who think cross-platforming is easy] (it’s almost a taboo to rant about users, it seems. Well, mostly counterproductive.)

In conclusion, Spotify is incredibly awesome. I’ve discovered a lot of artists thanks to it. Recently I have found that their Discover section is getting better and better, meaning we get to discover even more musicians that might be your cup of tea. There is a need for applications/services like Spotify for linux. Especially to premium users, we can sync our playlists and keep programming without a worry, or maybe sync music to your phone and go to exercise.

Another take at const-correctness and “optimizing” code.

Most of what I did today was cleaning code… or refactoring code. I wasn’t happy with the current codebase as in there were a lot of copies of strings being made instead of simply making references and that’s what made it so unsatisfying as I was duplicating codes of data.

One of the aspects of my application is that most of the time I don’t need to modify data thus using const & comes handy most of the time plus it helps the compiler as much as it helps me if I make a wrong assignment if(cookies = cream). It took me like 2 hours to fully refactor the codebase … I wouldn’t even call it refactoring at this stage as nothing needed to be moved away.

After I was done with the task I sat down, scratching my head wondering why do I have so many unneeded objects in the heap. Well, the wonders of both C and C++ is having the ability to write your allocators and how you literally manage memory. Objects in the heap–mostly created by new–can be harder to keep track and free in a large codebase, thankfully shared pointers, scoped pointers have been introduced, and yet, people like me still use naked pointers–sorry, at least give me points for doing my homework.

Interestingly while I’d dare say with my naked eye I’ll say that the app launches faster. However Qt isn’t that forgiving as having QML Engine running can cost you 40-50mb of ram, just starting. It’s actually a tiny price to pay compared to what you get with Qt in exchange. I’m sure I could lower the memory usage but… who knows…

Either way… I must say I’m proud of myself, with the progress I have done so far. To the mere veteran, or armchair programmer it may not mean much; but to me means a lot as I have stayed truth to my goal of learning C++.

Reading list of 2016-01-07


I thought I would start sharing some articles where I have found them to be insightful, thought-provoking, maybe controversial or funny. Don’t mistake “reading list” as “book reading list” that is! I do have some books in my to read list. 🙁

I read plenty of articles from Vox and other news sources on a daily basis, so here’s this week links.

I went on vacation alone. Why do people think that means I’m disturbed? by Catherine Andrews

This is the most common response — so common it seems to be mostly automatic. You’ll be chitchatting with somebody and mention that you’re taking off to the beach for a few days. Out of politeness they’ll ask who you’re going with, and you’ll tell them, “Just me!” Then it happens. Their eyes skitter everywhere. “Oh … wow … that’s so … cool!” they say — when in reality every twitching facial muscle is shouting, “Yeah, you definitely need to go on vacation. To a mental asylum. Why, oh, God, why would you ever go anywhere by yourself? You could get murdered! Worse, you might be bored! And you definitely are going to have to spend an extended amount of time alone with your thoughts — a fate worse than the random serial killer you’re sure to come across.”

Pretty darn on point. I’ve gone to the theaters alone and people look at me rather puzzled by it. Catherine really nails it down:

There can be a paralyzing sense of shame about doing activities alone that we’ve been told by society should be done with others — a shame that results from the assumption that anybody who sees you doing these things alone is judging or pitying you.

Which holds true in today’s society. As a person who enjoys doing plenty of activities alone I really recommend giving it a try.

Here’s Marvel’s new teaser trailer for Daredevil season 2 by Alex Abad-Santos

I have a little secret… well, not much of a secret. I didn’t enjoy Daredevil that much as many others have. I’m willing to give it a second run when the next season starts. That said, I’m looking forward to House of Cards new season.

I lost 100 pounds in a year. My “weight loss secret” is really dumb. by Alasdair Wilkins

(interestingly the article was written in the July 7, 2015 but somehow ended up in my feed reader in January… I guess the bump is real? Nevertheless, a great article)

The Hateful Eight, Quentin Tarantino’s new film, is a deeply interesting failure by Todd VanDerWerff

You know, this is an interesting time to release a film that many–who I dare say consciously practices political correctness as a lifestyle–find offensive, repulsive, or both. I didn’t particularly found the film to be thought-provoking, neither did I find it good or bad. I love Tarantino’s storytelling most of the time but in terms of plot it’s just a bag of mixed feelings altogether. Either way, I wasn’t offended nor disgusted… I do I agree with Todd VanDerWerff:

Pay attention to how the story works, though, and you’ll find that Daisy is granted almost no backstory beyond the bare minimum needed to set (or keep) the plot in motion. We know she’s a murderer — there’s at least a semi-convincing warrant for her arrest — but we don’t know anything about which murders she committed or why there’s a $10,000 bounty on her head.

While I don’t agree on the whole “society treatment of women” line (mostly because it’s far-fetched, and because Daisy is practically the only female that’s alive (not considering the three women Daisy’s gang members killed to get her out @ Minnie’s mostly because there wasn’t a modicum of development in any of them); the film is truly messy in terms of conveying the message to the audience. Personally, I was just indifferent to any of the characters in terms of connection or feeling anything for them as most of their conflicts were too brief, and to know it was just 3 hours long.

The fight isn’t over yet

So… after writing Onward, I say! I spent pretty much all day looking for answers. And I found them. Turns out how I was interacting with the database was sort of wrong, I need to tweak some things:


I was able to maintain a pretty responsive UI while the internals worked as hard as it can to make data available. Then I ran into a threading issue where quite frankly I had to rewrite the parser two times. Most of the rewrites were because I failed to understand how the stream parser worked rather than the source being faulty. Turns out that the threading issue was caused by a while never ending loop due to the parser never moving to the next element so it always gave me the same one.

All in all. I managed to solve the database issue, refactored the mechanism that gets the data and it’s oh so much better now; I managed to remove the complexity of it and now I just do a few conditional checks to see if everything’s okay.

The new parser seems pretty stable, rather… it’s probably the most stable parser I have written… so hopefully I won’t have to do any serious changes.

I think I can finally take a breather…