I love Gnome Shell, but was bothered by the amount of pixel wasted in its interface. The title bar of window is quite large, and the activity bar is always present. A maximized window still is unable to use a significant amount of pixels in the top of the screen.
This is a major pain on small screen, but even on bigger screen, MOAR pixels for my app is better. After all, the role of my desktop is to allow me to manage my apps in a convenient way. It has to be as discrete as possible.
Using a set of extensions, I was able to achieve the merging of the activity bar and the title bar for maximized window, but recently one of these extensions stopped working and the configuration of the whole stuff was quite complex and unappealing. So I created Pixel Saver, an extension that save brave pixels !
The goal is simple : merge the title bar and the activity bar when a window is maximized, in the most natural possible way.
To do so, Pixel Saver do not require any configuration, it fetches the configuration of your title bar and adapt itself accordingly. It is easier for the user, and produce a nice result. Activate the extension and it works !
|The title bar is completely gone and integrated to the activity bar.
The extension integrate title bar’s buttons in the activity bar, and change the title of the application menu to reflect the title of the maximized window. Really, nothing more need to be said.
That is Awesome ! I want to install it !
Follow the guide :
git clone https://github.com/deadalnix/pixel-saver.git
# copy to extensions directory
cp -r firstname.lastname@example.org ~/.local/share/gnome-shell/extensions
gnome-shell-extension-tool -e email@example.com
Easy ! I hope to get it soon into gnome extension’s website.
A bug report ? A pull request ? Go on the Pixel Saver github’s page !
Happy Pixel Saving !
A tagged union
Sometime you have some data that can be of type A or B. Very common use cases include decoding various file format or network protocols, communicate with memory mapped devices, some processing that can return an A or a B depending on its result, and many more.
To resolve that issue, it is common to use a union. A union is a aggregate where all members share the same memory. It is very handy, but use it wrongly and you end up badly messing up your memory. I’ll demonstrate in this article how to make this safe in D.
Developers want code that runs fast and users do too. However, it is easy to fall into the trap of early optimization; this story shows that even in non-trivial cases, modern compilers can do wonders. On the other hand, the myth of the “sufficiently smart compiler” is still very relevant. The best way is to look at what is actually generated for an example and that is what I’ll do in this article. Enter the SentinelInputRange.
OOP is known (or should be known) as a behavioral abstraction. It nicely solves a vast variety of problems, but enforces on the programmer an abstraction that doesn’t fit every problem. The fact is, you sometime need objects as data abstractions and not behavioral abstractions.
This is commonly the case for tools that manipulate code. A parser typically returns an AST that will be processed. The processing can be compilation, code formating, code analysis, and basically any other use related to source code manipulation.
Following regular OOP principles, manipulations have to be implemented by the AST node classes. This is a problem, because it prevents any 3rd party developer tool to reuse an existing parser and AST. The known solution is to use the Visitor pattern, which allows to dispatch in our code according to the AST node’s type.
The Visitor pattern has many known problems, to the point that many consider it an antipattern. A better solution using D has to be proposed.
Linux (as other UNIXes) allow you to register handlers for signals. Here we are interested in SIGSEGV. This signal is sent to your program when you try to use a memory location you shouldn’t. Typically, when deferencing null.
Language like Java send a NullPointerException, that can be caught and you can recover from it. However, in a system language, you usually get a cryptic « segmentation fault », you cannot recover from it and cannot have any information about it outside a debugger. Let’s see how we can fix this.
As C++ and D are system languages that support exceptions, we will use this mechanism to handle SIGSEGV. I’ll do it in D in this post, but the same is doable in C++. If you understand why it work, it shouldn’t be a problem.
Duplication is probably the #1 enemy of clean code. Its presence make the code harder to maintain, harder to evolve, more bug prone, harder to test and probably eat babies every morning. If almost any developer will agree on that fact, me can also notice that almost every codebase is crippled with repetitions in the code. How could we explain that ?
As ARM release its intention to go 64bits, we can be pretty much sure that almost every device will be 64bits soon, except the one on which it is unrealistic to run a garbage collector.
A garbage collector can be precise like in Java, or not, like D’s GC or Boehm’s GC for C++. It means that theses GC don’t know what it a pointer and what isn’t. Non precise GC cannot move data to compact the heap, and are also prone to false positive. On a theoretical perspective, switching from 32 bits to 64 bits should improve things, but what it is in practice ?
The D programming language is a very promising language. I propose here to do a quick review of some problems it is facing (or at least problems I’m facing when using it) and propose some solutions.
Immutability and constness in D2
I wanted to to a single, but writing it, it kept getting longer and longer. The point wasn’t to rant randomly, but also to make some proposal to improve things. So I did split it into smaller articles, and here the first one. We will discuss constness and immutability in D2.
I noticed that I was using a pattern of my own more and more. It is actually very usefull, for several reasons. It may have been used by other before me, but never saw a name for it.
This pattern can be used in any language that support first class function and hashtable, that is becoming more and more common (closure support was added in PHP as of version 5.3).
On many Internet websites, you’ll come across article explaining you HTML and PHP. But none of them teach you that the PHP tag should be considered as an HTML element, not as a PHP one. Worse, many example you’ll find does this mistake again and again. This article is PHP centered, but apply to other technologies like JSP or most templates systems, where code is mixed with logic.