Breaking free of the constraints of the Qt data model

I decided to drop the Qt data model altogether in a project. There are certain circumstances that may call for this, and I will outline my reasoning below.

Introduction

Qt has view components that make it easy to tie into a local data model, even from a SQLite source. The widget handles all of the basic functionality for you—for a QListView, this will yield a component that automatically draws, highlights and edits data. This takes a lot of the burden off of you when building a cross-platform product where you’d normally have to manage data, drawing, layout, and native events like flicking to scroll on touch screens. There’s a lot of accessible customization, especially if you’re going the QML route. The drawing is even hardware accelerated where available.

If you want to make a custom component you have to handle each event, drawing and low-level logic for the component manually. You’ll generally need an extraordinary reason to not use the widgets.

Customization

If you have a particularly complex set of data that needs to be displayed there are alternatives to the standard list view; QTableView can display tabular data, QTreeView for hierarchical data sets. For any of these, the items’ paint methods can be overridden to customize the look.

Under nuclear conditions, you can use the non-databound widgets like QListWidget and use its setItemWidget method to convert any list item into a widget of your choosing, including a custom one containing its own child widgets.

The Exceptions

The reasons to not use the Qt model-view ecosystem in a Qt-based application may be pretty obvious in some cases. At some point you’ll cross the very fuzzy threshold of “yes this needs to be completely custom,” and here is a very good combination of reasons why:

  • You have to custom draw every list item,
  • There are multiple or irregularly-shaped hotspots on list items for mouse tracking,
  • There are multiple fields that need to be edited within each list item,
  • There will be a profound number of list items which will trigger many resize events if using custom widgets for your list items,
  • Your data model and view may need to be changed frequently,
  • Your data is asynchronously updated, and you need to ensure scrolling and selection is consistent,
  • Your data is relational or needs to referenced with hashes, and
  • You would have to override a majority of the built-in data model’s methods in order to work with a view anyway.

Qt can of course handle all of these cases so if you’re already neck-deep in using a QListView it wouldn’t make sense to refactor that and write a widget from scratch. However in my case adhering to the Qt convention would take more work for myself, since I need to override all the default functionality anyway.

Ubuntu 14.04 Memory Issues Disappear on Intel CPU

The system I was futzing with last week has an 4-core AMD APU. However I found a desktop with similar specifications, albeit in a 4-core Intel CPU package and it has less trouble with memory management and responsiveness. This could of course be a bug with some module or other hardware, but I’m beginning to notice that low-end laptops that use a combined CPU with GPU package will yield a less responsive experience especially when memory is stressed. Has anyone else noticed this?

10632446_307329906116798_922852833_n

tmux configuration

If you spend about 20 minutes reading the manual and configuring tmux (and tmux sessions for each of your projects) it’ll save you 20 minutes every day that you use the command line.

tmux attach_035

Ubuntu 14.04’s constant memory struggles

Looking at htop I notice that most of my memory is sucked up in graphics-intensive desktop applications (surprise). Here are the big memory killers I’m going to address:

  1. Browser* – 1.2GiB
  2. compiz – 225MiB
  3. X – 175MiB
  4. spotify – 113MiB

*I’ve recently switched to Opera Developer for performance reasons.

4 gibibytes of RAM depleted within an hour of using Ubuntu

The window manager & graphics server take up 400 MiB of RAM combined just by themselves. Reducing the use of windowed applications kills two birds with one stone: less load on the window and composition manager and lower # of SO’s in memory interfacing with X.

The alternative command line work flow

  • tmux – Rather than opening multiple terminal windows. I use Guake as an omni-present terminal.
  • gcalcli – Instead of leaving the Google Calendar tab open. ccal and pal are good alternatives.
  • despotify – Replaces the resource-hungry Linux Spotify client.
  • vim/emacs – RedNotebook is a great lightweight desktop journaling application, but I still find it preferable to maintain a personal journal using vim.
  • mutt with offlineimap – Mutt and offlineimap for email make a great team. Backing up and archiving all your email using this configuration can be automated with one or two line scripts. Side note: Linus himself uses pine for email.
  • bitlbee & weechat – Bitlbee acts as an IRC server, fully managing all of your chat accounts including Google talk (hangouts), Facebook and Twitter. weechat is then used to connect to your bitlbee server. I found this combination yields the smallest returns on performance but it is an important part of my work flow.
  • elinks – Lightweight cli browser.
  • sc – Great for doing simple spreadsheets and calculations without having to load LibreOffice.

Takeaway

There was an order of magnitude gains in memory usage here. I can run all of these at once and the system’s overall response is still much snappier. If you’re comfortable using the command line I will always suggest test-driving CLI alternatives for your favorite applications.

Recovering ecryptfs-encrypted home files from a LUKS encrypted drive in Ubuntu

I did this in Ubuntu 14.04.

This is a bit of a niche situation and it took a really long time so this guide is incomplete. If you run into the situation and need extra help just comment below and I’ll try to give some guidance.

Restoring with rsync

Restoring with rsync

Recently I ran into problems trying to update to the 14.10 release. I lost my video drivers, x11 fallback drivers, and window manager.

Rather than mess with all that I swapped out my laptop’s drive with a fresh one, enabled logical volume management (which the Ubuntu installation disk says is easier to manage) and then installed Ubuntu 14.04 on the new drive. The old one is now a bodged external drive, but it took some finagling to get it to mount.

The first problem I ran into is both of these drives are now boot drives and the logical volume names are both the same. As much as you try, you cannot mount the logical volumes simultaneously without renaming them. Also when you do run sudo lvscan it will show both conflicting logical volume names (ubuntu-vg/root).

I removed my primary boot drive–that’s the important part–then rebooted into a Ubuntu live disc. You should always make a live disk for convenience. Finally I ran lvrename to change the logical volume name of my external. Once I was done with that I rebooted to my primary drive again.

Bingo! Now when I use the disks utility I can mount both logical volumes. You can’t mount it from nautilus, but don’t bother with it. Next is the harder part: You have to mount your home folder that is encrypted with ecryptfs. Look at the post by idallen for a script to mount your private folders at a new mount point. You will have to make modifications to the script. I also manually set the USER variable in the beginning of the script so that I could sudo the script. Make sure you’re pointing to a place on the old drive where your .Private folder is. AND BE CAREFUL WITH THIS. I made the mistake of creating some recursive directory structures in my destination through symbolic links and I could have just as easily deleted the encrypted home folders the same way.

Once the home folder is mounted, you can rsync -r the contents to a new folder. Do not use cp!

That is all. Like I said, if you run into issues let me know in the comments and I’ll try to help.

October Atomic update

I’ve worked on Atomic for months and months now. I’m closing in on an MVPHowever. HOWEVER: I’ve coded an entire working TO-DO manager and I cannot stand to use it. Yes, I know other people can so I will continue to polish it and then release it.

There’s a simple reason why though. To-do lists have to stay out of your way by being minimalist, but if they are too minimalist they will hinder you further. Take these assertions:

  • Pen and paper is very minimalist: pen and paper are always available to you.
  • If you want a to-do list, a pen and scratch paper works great!
  • If you want something with archives and deadlines, a notebook or planner system works great!
  • If you need to share a lot, web can be considered, but eh you can also take pictures of your notes and pass them along.

Ok it starts to get yucky:

  • If  you want to keep track of links, store photos and documents, or collaborate with large teams a web task management system is better.
  • If you need to manually sort these tasks before a deadline approaches (priorities shift all the time!) you’re way screwed. Get ready to drag and drop a lot of crap.
  • If you want to type notes inline with your tasks to work out other stuff you need to do, wow, maybe you should use evernote or something? Clicking back and forth between similar tasks to compare notes will just drive you insane.
  • And what happens if one task turns into a bunch of other smaller tasks?
  • What if the one task should actually be a whole project that someone on your team needs to take time for?
  • We didn’t really have time to go through these little details in the planning phase. Hm.
  • Your big tasks really should be split into smaller chunks. Good luck!
  • If you want to collaborate AND feel free using your task list online there’s really nothing you can use.

The whole problem about atomic is that it treats tasks like–well Atomic units. But tasks behave more like quantum particles; they’re discrete reminders that larger things exist, but when you begin to examine them they start to change and take shape.

Here’s a solid example of something that I ended up doing yesterday:

  • I just wanted to install an application on my linux computer. Initial task: install application.
  • Oh, the build is outdated. I’ll have to compile from source. Task now becomes: compile and install application
  • That depends on other libraries. I’ll have to install those too. Task: install dependencies, compile and install application
  • Ok, all dependencies for my distribution are out of date too! Task: compile dependencies from source, install them, compile and install application
  • You think I’m even close to finish? Nope. Task: update core os libraries, fix circular dependencies, […]
  • Three hours later I’m reinstalling my OS from scratch and cursing.

Very quickly one simple task can turn into hundreds of smaller ones. I would’ve liked to document some parts of this process, but wrestling with a task manager at the same time would’ve been futile.

I’ll let your imagination run with that. I think Atomic has the potential to fill a much bigger gap while still synchronizing with online services such as Producteev.

New format coming soon

It takes too much time to keep up with long form post format I’ve maintained over the years. It’s also really boring.

BORING

Ok. Things I’m working on:

  1. New site (maybe)
  2. New posts (maybe)
  3. Atomic
  4. Probably 100 other things

Going to update in more detail with another post here shortly.

Ubuntu 14.04 LTS (trusty) peculiarities and how to fix them

A small guide to big frustrations.

Shutter (for screenshots) goes slow

This is a problem with your video driver. Run “Additional Drivers” from the unity dashboard and snag the non-generic video drivers. You’ll notice an overall speed boost for everything else too.

Additional Drivers

No swap file with LVM / Locking up in Ubuntu 14.04 LTS

This has to be one of the wackiest things with 14.04 LTS. Check htop or free. Do you even have any swap? If you chose to encrypt your home folder then probably not.  This guide explains how to set up a swap file. Give yourself a few GB (I have 8.) Otherwise if you run out of free memory processes will begin to halt. If you lock up entirely, remember REISUB. Important to note: swap files in the root file system are going to be unencrypted unless you are using full volume encryption. This gives you faster swap speed but leaves the swap vulnerable if someone gets physical access to the drive.

Ah, that's better.

Ah, that’s better.

Takes a long time to mount the swap partition (Press S to Skip…)

If you see this message every time you boot:

The disk drive for ubuntu–vg-swap is not ready yet or not present.

Continue to wait, or Press S to skip mounting or M for manual recovery

This is the same issue as above. Set up a swap file, and also comment 2 lines out of /etc/fstab:

vim /etc/fstab

vim /etc/fstab

Make sure you edit the 2 that start with /dev/mapper at the bottom, but leave the top ubuntu–vg-root volume alone! Unfortunately I’m guessing this is an issue with the guided Ubuntu setup for 14.04. I know the volumes are being created for swap and root but they never mount!

Visual Stutter, lag, slowness with full volume encryption

Unfortunately I resorted to completely nuking my installation and reinstalling without full volume encryption. It would be nice to know if there’s a solution to this aside from getting an SSD.

My personal experience here is that running without full encryption is so much faster that I’m not concerned with it.

 

Update 10/7/2014:

Print screen doesn’t work

I used Compiz Config Settings Manager (CCSM) to bind the printscreen key to Shutter. Unfortunately this introduces a small delay.

Replacing sendmail with postfix on Ubuntu Server 12.04

Sendmail runs as a daemon out of the box on Ubuntu so just installing postfix won’t change postfix to the default MTA. But if you simply uninstall the sendmail packages you will run into the issue of no longer being able to use the `mail` program. Even though you may not use it yourself it’s still required by some scripts to function correctly.

Here’s what I did to get everything working correctly on a headless install:


sudo apt-get install postfix
sudo apt-get remove sendmail-base sendmail-cf
sudo apt-get install bsd-mailx

After that, configure postfix to your liking, restart the postfix service, and finally adjust your firewall settings.

Ubuntu – Getting Password Prompts for Gmail after your Remove California (Calendar)

This is a very specific issue but hopefully it clears some aggravation.

Your calendars for California are still stored in:

~/.config/evolution

If you have evolution installed the calendars will sync. However if you’d prefer to get rid of them entirely you should comb through it and delete the offending calendars. (Beware: If you have local calendars you want to keep, don’t delete the entire folder.)

Here are some other common culprits that cause similar issues:

~/.config/goa-1.0
~/.config/desktop-couch