Configuring gnome properties programmatically

After installing a new distribution in my computer, I usually want to make some tweaks to gnome. In this post I’m going to explain how to do these tweaks from the command line, so they can be scripted.

gsettings

Gsettings is a command-line tools that allows us to modify gnome settings. To modify a setting we can use the set command. The format is like the following:

1
gsettings set SCHEMA[:PATH] KEY VALUE
Read More

Hide snap folder in Ubuntu

Ubuntu recently introduced snaps. Snaps are a new way of packaging applications in a way that there will be no dependency conflicts (because all dependencies are included). The only problem is that Ubuntu will create a snap folder in your home folder that you will most likely never need to access.

If you, like me, find this folder annoying, you can hide it from Nautilus:

1
2
cd ~
echo snap >> ~/.hidden

This makes the folder invisible in Nautilus, but it will still be visible in other places (The terminal, for example).

Read More

How to configure Firefox programmatically

I reinstalled Ubuntu on my personal computer recently and I noticed that there are some things I don’t like about the default distribution. One of the things I noticed is that Firefox keeps asking me if I want it to remember my passwords, which I don’t.

I know that I can go to settings and disable this feature, but I wanted to learn how to do it programmatically, so in the future I can just run a script and have Firefox work the way I want.

Preferences

There is documentation explaining how preferences work for mozilla projects, but it’s a little hard to understand how to exactly do what I wanted to do.

Read More

Virtual functions in C++

If you are not familiar with Inheritance, I recommend you read my short article about inheritance first.

One of the features of Object Oriented Programming is Polymorphism. Virtual functions in C++ allow developers to achieve run-time polymorphism by overwriting methods of a base class.

In my article about inheritance, I showed how we can create classes that inherit from a base (or parent) class. Something similar to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
class Greeter {
 public:
  void talk() {
    std::cout << "hello" << std::endl;
  }
};

class SpanishGreeter : public Greeter {
 public:
  void talk() {
    std::cout << "hola" << std::endl;
  }
};
Read More

Inheritance in C++

Inheritance is a feature of Object Oriented Programming that allows programmers to create classes based on other classes. A class that inherits from another class will have the same behavior as the parent class unless it is overwritten.

Let’s say we have a class:

1
2
3
4
5
6
7
8
9
class Greeter {
 public:
  void talk() {
    std::cout << greeting_ << std::endl;
  }

 protected:
  std::string greeting_ = "hello";
};
Read More

Enums in C++

Enumerations are useful when we want to have a custom type, that can only have a limited number of values. For example:

1
2
3
4
5
enum Mode {
  EASY,
  MEDIUM,
  HARD
};

We can create variables of type enum that can only have one of the previously defined values:

1
Mode userMode = EASY;
Read More

C-style arrays vs std::array

In this post I’m going to talk about the advantages of using std::array vs a c-style array whenever it is possible to do so.

C-style arrays

Let’s start by remembering what a c-style array is.

In C and C++ we can create an array of ints like this:

1
int arr[3];
Read More

Creating a C++ package with Conan

In the past I wrote an article that explains how to consume packages using Conan. In this article I’m going to explain how we can create our own packages with Conan.

I’m going to create a simple cpp library and make a conan package out of it.

Sample package

The first step is to create a folder for the library:

1
2
mkdir MyLib
cd MyLib
Read More

Variadic templates / functions in C++

A variadic function is a function that can take a variable number of arguments.

I have used variadic functions in previous posts, but I have not explained how they work. This post will cover that.

C-style variadic functions

C++ supports the C-like syntax for writing variadic fuctions.

Let’s say we want to write a function that adds numbers together. If we wanted to write a function that adds two numbers, we could do it easily:

1
2
3
int add(int a, int b) {
  return a + b;
}
Read More