Skip to main content

the avatar of Nathan Wolf

the avatar of Sebastian Kügler

Different indentation styles per filetype

For my hacking, I love to use the KDevelop IDE. Once in a while, I find myself working on a project that has different indentation styles depending on the filetype — in this case, C++ files, Makefiles, etc. use tabs, JavaScript and HTML files use 2 spaces. I haven’t found this to be straight-forward from KDevelop’s configuration dialog (though I just learnt that it does seem to be possible). I did find myself having to fix indentation before committing (annoying!) and even having to fix up the indentation of code committed by myself (embarrassing!). As that’s both stupid and repetitive work, it’s something I wanted to avoid. Here’s how it’s done using EditorConfig files:

  1. put a file called .editorconfig in the project’s root directory
  2. specify a default style and then a specialization for certain filetypes
  3. restart KDevelop

Here’s what my .editorconfig file looks like:


# EditorConfig is awesome: https://EditorConfig.org

# for the top-most EditorConfig file, set...
# root = true

# In general, tabs shown 2 spaces wide
[*]
indent_style = tab
indent_size = 2

# Matches multiple files with brace expansion notation
[*.{js,html}]
indent_style = space
indent_size = 2

This does the job nicely and has the following advantages:

  • It doesn’t affect my other projects, so I don’t have to run around in the configuration to switch when task-switching. (Editorconfigs cascade, so will be looked up up in the filesystem tree for fallback styles.
  • It works across different editors supporting the editorconfig standards, so not just KWrite, Kate, KDevelop, but also for entirely different products.
  • It allows me to spend less time on formalities and more time on actual coding (or diving).

(Thanks to Reddit.)

the avatar of Klaas Freitag

Change in Professional Life

This November was very exciting for me so far, as I was starting a new job at a company called Heidolph. I left SUSE after working there for another two years. My role there that was pretty far away from interesting technical work, which I missed more and more, so I decided to grab the opportunity to join in a new adventure.

Heidolph is a mature German engineering company building premium laboratory equipment. It is based in Schwabach, Germany. For me it is the first time that I am working in company that doesn’t do only software. At Heidolph, software is just one building block besides mechanical and electronic parts and tons of special know how. That is a very different situation and a lot to learn for me, but in a small, co-located team of great engineers, I am able to catch up fast in this interesting area.

We build software for the next generation Heidolph devices based on Linux and C++/Qt. Both technologies are in the center of my interest, over the years it has become more than clear for me that I want to continue with that and deepen my knowledge even more.

Since the meaning of open source has changed a lot since I started to contribute to free software and KDE in particular, it was a noticeable but not difficult step for me to take and move away from a self-proclaimed open source company towards a company that is using open source technologies as one part of their tooling and is interested in learning about the processes we do in open source to build great products. An exciting move for me where I will learn a lot but also benefit from my experience. This of course that does not mean that I will stop to contribute to open source projects.

We are still building up the team and look for a Software Quality Engineer. If you are interested in working with us in an exciting environment, you might wanna get in touch.

the avatar of Nathan Wolf

the avatar of Federico Mena-Quintero

Propagating Errors

Lately, I have been converting the code in librsvg that handles XML from C to Rust. For many technical reasons, the library still uses libxml2, GNOME's historic XML parsing library, but some of the callbacks to handle XML events like start_element, end_element, characters, are now implemented in Rust. This has meant that I'm running into all the cases where the original C code in librsvg failed to handle errors properly; Rust really makes it obvious when that happens.

In this post I want to talk a bit about propagating errors. You call a function, it returns an error, and then what?

What can fail?

It turns out that this question is highly context-dependent. Let's say a program is starting up and tries to read a configuration file. What could go wrong?

  • The file doesn't exist. Maybe it is the very first time the program is run, and so there isn't a configuration file at all? Can the program provide a default configuration in this case? Or does it absolutely need a pre-written configuration file to be somewhere?

  • The file can't be parsed. Should the program warn the user and exit, or should it revert to a default configuration (should it overwrite the file with valid, default values)? Can the program warn the user, or is it a user-less program that at best can just shout into the void of a server-side log file?

  • The file can be parsed, but the values are invalid. Same questions as the case above.

  • Etcetera.

At each stage, the code will probably see very low-level errors ("file not found", "I/O error", "parsing failed", "value is out of range"). What the code decides to do, or what it is able to do at any particular stage, depends both on the semantics you want from the program, and from the code structure itself.

Structuring the problem

This is an easy, but very coarse way of handling things:

gboolean
read_configuration (const char *config_file_name)
{
    /* open the file */

    /* parse it */

    /* set global variables to the configuration values */

    /* return true if success, or false if failure */
}

What is bad about this? Let's see:

  • The calling code just gets a success/failure condition. In the case of failure, it doesn't get to know why things failed.

  • If the function sets global variables with configuration values as they get read... and something goes wrong and the function returns an error... the caller ends up possibly in an inconsistent state, with a set of configuration variables that are only halfway-set.

  • If the function finds parse errors, well, do you really want to call UI code from inside it? The caller might be a better place to make that decision.

A slightly better structure

Let's add an enumeration to indicate the possible errors, and a structure of configuration values.

enum ConfigError {
    ConfigFileDoesntExist,
    ParseError, // config file has bad syntax or something
    ValueError, // config file has an invalid value
}

struct ConfigValues {
    // a bunch of fields here with the program's configuration
}

fn read_configuration(filename: &Path) -> Result<ConfigValues, ConfigError> {
    // open the file, or return Err(ConfigError::ConfigFileDoesntExist)

    // parse the file; or return Err(ConfigError::ParseError)

    // validate the values, or return Err(ConfigError::ValueError)

    // if everything succeeds, return Ok(ConfigValues)
}

This is better, in that the caller decides what to do with the validated ConfigValues: maybe it can just copy them to the program's global variables for configuration.

However, this scheme doesn't give the caller all the information it would like to present a really good error message. For example, the caller will get to know if there is a parse error, but it doesn't know specifically what failed during parsing. Similarly, it will just get to know if there was an invalid value, but not which one.

Ah, so the problem is fractal

We could have new structs to represent the little errors, and then make them part of the original error enum:

struct ParseError {
    line: usize,
    column: usize,
    error_reason: String,
}

struct ValueError {
    config_key: String,
    error_reason: String,
}

enum ConfigError {
    ConfigFileDoesntExist,
    ParseError(ParseError), // we put those structs in here
    ValueError(ValueError),
}

Is that enough? It depends.

The ParseError and ValueError structs have individual error_reason fields, which are strings. Presumably, one could have a ParseError with error_reason = "unexpected token", or a ValueError with error_reason = "cannot be a negative number".

One problem with this is that if the low-level errors come with error messages in English, then the caller has to know how to localize them to the user's language. Also, if they don't have a machine-readable error code, then the calling code may not have enough information to decide what do do with the error.

Let's say we had a ParseErrorKind enum with variants like UnexpectedToken, EndOfFile, etc. This is fine; it lets the calling code know the reason for the error. Also, there can be a gimme_localized_error_message() method for that particular type of error.

enum ParseErrorKind {
    UnexpectedToken,
    EndOfFile,
    MissingComma,
    // ... etc.
}

struct ParseError {
    line: usize,
    column: usize,
    kind: ParseErrorKind,
}

How can we expand this? Maybe the ParseErrorKind::UnexpectedToken variant wants to contain data that indicates which token it got that was wrong, so it would be UnexpectedToken(String) or something similar.

But is that useful to the calling code? For our example program, which is reading a configuration file... it probably only needs to know if it could parse the file, but maybe it doesn't really need any additional details on the reason for the parse error, other than having something useful to present to the user. Whether it is appropriate to burden the user with the actual details... does the app expect to make it the user's job to fix broken configuration files? Yes for a web server, where the user is a sysadmin; probably not for a random end-user graphical app, where people shouldn't need to write configuration files by hand in the first place (should those have a "Details" section in the error message window? I don't know!).

Maybe the low-level parsing/validation code can emit those detailed errors. But how can we propagate them to something more useful to the upper layers of the code?

Translation and propagation

Maybe our original read_configuration() function can translate the low-level errors into high-level ones:

fn read_configuration(filename: &Path) -> Result<ConfigValues, ConfigError> {
    // open file

    if cannot_open_file {
        return Err(ConfigError::ConfigFileDoesntExist);
    }

    let contents = read_the_file().map_err(|e| ... oops, maybe we need an IoError case, too)?;

    // parse file

    let parsed = parse(contents).map_err(|e| ... translate to a higher-level error)?

    // validate

    let validated = validate(parsed).map_err(|e| ... translate to a higher-level error)?;

    // yay!
    Ok(ConfigValues::from(validated))
}

Etcetera. It is up to each part of the code to decide what do do with lower-level errors. Can it recover from them? Should it fail the whole operation and return a higher-level error? Should it warn the user right there?

Language facilities

C makes it really easy to ignore errors, and pretty hard to present detailed errors like the above. One could mimic what Rust is actually doing with a collection of union and struct and enum, but this gets very awkward very fast.

Rust provides these facilities at the language level, and the idioms around Result and error handling are very nice to use. There are even crates like failure that go a long way towards automating error translation, propagation, and conversion to strings for presenting to users.

Infinite details

I've been recommending The Error Model to anyone who comes into a discussion of error handling in programming languages. It's a long, detailed, but very enlightening read on recoverable vs. unrecoverable errors, simple error codes vs. exceptions vs. monadic results, the performance/reliability/ease of use of each model... Definitely worth a read.

the avatar of Nathan Wolf

the avatar of Nathan Wolf
a silhouette of a person's head and shoulders, used as a default avatar

Ciano, una opción sencilla para convertir tus archivos multimedia





Ciano es una aplicación de conversión multimedia de escritorio que nos permite convertir videos, música e imágenes. Ciano utiliza las herramientas de conversión: FFmpeg e ImageMagick.

Centrado en la simplicidad, Ciano ofrece un nuevo enfoque para usar FFmpeg, sin la necesidad de escribir una sola línea de código. Además, cuenta con soporte para muchos codecs y contenedores como MPEG4, MPEG, FLV, AVI, OGG, GIF, VOB, MP3, WMA y muchos más.

 Instalar Ciano en openSUSE


Para instalar Ciano, accesa a https://software.opensuse.org/package/ciano y selecciona tu versión de openSUSE en la tecnología 1 Click Install

#HaveALotOfFun



a silhouette of a person's head and shoulders, used as a default avatar

openSUSE-Pakete für den Client und das Dateisystem von Keybase

Keybase gehört zu den Diensten, die zwar irgendwie wahnsinnig nützlich sind, denen der breite Erfolg bisher aber leider verwehrt wurde. Das Kernfeature besteht darin, dass es einen Weg bietet eine verschlüsselte Kommunikation mit Personen aufzubauen von denen man nur einen Social-Media-Account kennt. Durch das Verfahren, einen Beweis über die Eigentümerschaft des Schlüssels im Social-Media-Account zu hinterlegen, kann man diesen, anders als Schlüsseln welche man von einem PGP-Keyserver erhalten hat, recht gut Vertrauen. Leider bietet allerdings Keybase kein Installationspaket seiner Software für openSUSE an, so dass ich nun selber Pakete erstellt habe.

Die grundlegenden Funktionen von Keybase sind über das Kommandozeilenwerkzeug keybase verfügbar. Dieses wird vom Paket keybase-client bereitgestellt und lässt sich in Tumbleweed durch ein einfaches sudo zypper install keybase-client installieren. Für Leap 15.0 ist das Paket leider nur als Versuchspaket verfügbar, welches sich am besten per 1-Klick-Installation von software.opensuse.org installieren lässt.

Außerdem bietet Keybase noch zwei weitere nützliche Funktionen. Mit dem dazugehörigen Dateisystem lassen sich Daten verschlüsselt und signiert mit anderen Nutzer tauschen. Auch öffentlich lassen sich darüber Dateien anbieten. Diese erscheinen dann unter https://<nutzername>.keybase.pub, und sind natürlich nicht verschlüsselt sondern nur signiert. Hierfür wird das Paket kbfs benötigt. Ist diese installiert, kann man per systemctl --user start kbfs das Dateisystem starten, welches dann unter ${XDG_RUNTIME_DIR}/keybase/kbfs erscheint.

Die zweite nützliche Funktion ist es Git-Repositories verschlüsselt in Keybase abzulegen. Hierzu wird das Paket kbfs-git benötigt. Sobald diese installiert ist, und das Dateisystem aktiv, kann Git auf Repositories welche das Protokoll keybase nutzen zugreifen. Die Verwaltung erfolgt hierbei über das Kommando keybase git.

a silhouette of a person's head and shoulders, used as a default avatar

Excellent SMTP Relay & Blast Email Dashboard : Dari Ide Hingga Eksekusi

LATAR BELAKANG

Salah satu layanan utama di Excellent adalah layanan SMTP Relay. Layanan ini berfungsi sebagai server relay/penerus email dari klien yang ditujukan pada pihak eksternal. Pengguna layanan ini terdiri dari berbagai latar belakang, antara lain :

  1. Pengguna layanan Excellent Managed Services Mail Server. Untuk meningkatkan kualitas dan performa sistem, kami memisahkan layanan SMTP routing ke eksternal termasuk layanan anti spam agar spesifikasi sistem secara penuh digunakan untuk layanan email
  2. Klien yang IP public-nya terkena blacklist pihak tujuan
  3. Klien yang hanya punya IP dynamic
  4. Klien yang terkena limit pengiriman email oleh pihak ISP
  5. Klien yang capek karena email terkadang tidak sampai ditujuan dan tidak diketahui penyebabnya
  6. Klien yang sebel karena email yang dikirim malah masuk ke folder spam di pihak tujuan
  7. Klien yang ingin menyembunyikan posisi server mereka atas pertimbangan keamanan sistem. Port-port yang dibuka dibatasi hanya untuk IP tertentu, misalnya port incoming hanya diperbolehkan untuk email yang berasal dari layanan anti spam Excellent, port 25 outgoing diblock dan koneksi ke server SMTP Excellent diset menggunakan port yang tidak umum

Layanan SMTP Relay ini awalnya dimulai dari 1-2 server. Menggunakan server yang ditempatkan di co-location server. Awal-awal diimplementasikan, domain Excellent sendiri yang menjadi kelinci percobaan. Sebelum menjadi produk untuk dijual, kami harus memastikannya bisa berjalan sesuai harapan. Bagaimana mungkin kami menjual produk terkait email kalau email kami sendiri kerap bermasalah.

Layanan yang awalnya ditujukan untuk kepentingan internal ini terus dimonitor stabilitas dan performanya. Setelah cukup percaya diri, layanan ini kemudian mulai diimplementasikan disisi server managed services. Perlu berbagai langkah preventif dan korektif untuk memastikan bahwa IP public server selalu terjaga aman tanpa mengurangi fleksibilitas sistem. Jumlah server terus ditambah seiring dengan penambahan jumlah klien. Kami juga menyiapkan server pada posisi lokasi geografis berbeda sebagai antisipasi jika ada gangguan di lokasi tertentu.

INISIASI AWAL

Setelah berjalan beberapa lama, pada sesi brainstorming internal ada usulan untuk membuat dashboard smtp relay, dengan beberapa latar belakang pertimbangan, antara lain :

  1. Dengan dashboard smtp relay, klien bisa melakukan tracking log pengiriman email secara mandiri, tidak perlu melakukan request ke team support Excellent. Klien terpenuhi kebutuhannya dan disisi lain team support Excellent terlepas dari pekerjaan yang tidak memberikan nilai tambah
  2. Lebih mudah mengecek perkembangan kualitas layanan. Data-data klien tercatat lebih rapi, dilengkapi dengan detail nama perusahaan,  contact person, no kontak/HP/telp, alamat email dan lain-lain. Mudah juga melakukan broadcast pemberitahuan ke seluruh klien
  3. Pembuatan laporan bisa lebih mudah dilakukan. Mengetahui klien mana yang over usage, klien mana yang terkena lock karena melakukan spamming maupun klien yang terkena suspend karena overdue tagihan lebih mudah dikelompokkan
  4. Bisa membuat skema level layanan, misalnya klien level premium bisa melakukan attachment sekian MB namun klien level silver hanya bisa mengirim attachmen lebih kecil. Demikian juga untuk trafik email, bisa dicheck dengan mudah
  5. Lebih mudah diintegrasikan. Bisa dibuat standard knowledge base untuk proses setup disisi klien, termasuk nantinya dikembangkan untuk API aplikasi. Team juga bisa membuat script auto install untuk mempermudah setting disisi klien
  6. Klien bisa mengecek status pengiriman email per jam, per hari, per minggu hingga per bulan. Berapa email yang terkirim dan berapa yang gagal termasuk data user-user yang mengirim email terbanyak yang bisa menjadi informasi awal indikasi spamming (atau melakukan blast)
  7. Bisa dilengkapi dengan feature pengecekan SPF, DKIM, DMARC dan lain-lain yang bisa meningkatkan kualitas reputasi pengiriman email pihak klien

Untuk merealisasikan hal ini, ada 2 pilihan yang tersedia, yaitu merekrut team developer aplikasi atau meminta pihak vendor software membuatkannya untuk Excellent. Kedua pilihan memiliki kelebihan dan kekurangan masing-masing. Jika merekrut team developer, mungkin akan butuh waktu untuk pengembangan namun bisa lebih fleksibel dalam menentukan prioritas dan cakupan pekerjaan yang akan dilakukan, sedangkan jika diserahkan kepada pihak vendor, prosesnya diharapkan bisa lebih cepat namun tentu saja harus ditentukan Scope of Works-nya secara lebih detail.

Setelah mempertimbangkan kelebihan dan kekurangan masing-masing, kami memilih vendor software untuk membuatkannya. Kebetulan saya mengenal seorang rekan yang memiliki kapabilitas mengenai hal ini. Ia sering membaca tulisan saya di blog, kemudian tertarik untuk resign dari kantor dan membangun usaha dibidang software development. Setelah berjalan beberapa lama, overhead cost-nya tidak bisa ditutup dari pendapatan sehingga akhirnya ia kembali bekerja di sebuah perusahaan. Meski demikian ia terus keep contact dengan saya. Tahun lalu ia berdiskusi kembali dengan saya mengenai problem dikantornya, dimana sebagian besar uang perusahaan dipakai founder untuk mengembangkan usaha lain sampai-sampai usaha utama terseok-seok dan banyak team programmernya yang resign.

Mendengar hal itu, saya tawarkan padanya, bagaimana jika saya berinvestasi saja. Saya berinvestasi pada kualitas personal dia. Selain mencari order dari pihak eksternal, sekalian saja perusahaan yang baru ia bangun mendapat order dari Excellent. Jadi meski saya memiliki investasi di kedua perusahaan, hubungan ordernya murni professional. Ia setuju dan saya diberikan alokasi sekitar 40% saham. Dengan skema ini, pengembangan dashboard smtp relay Excellent dimulai.

EKSEKUSI IDE

Untuk mendapatkan gambaran mengenai aplikasi dashboard smtp relay yang akan dikembangkan, saya meminta team Excellent mengadakan pertemuan beberapa kali membahas skema dan featurenya. Ada banyak usulan dan saran termasuk diskusi teknis saat sesi ini. Misalnya jika script robot monitoring Excellent melakukan lock account klien yang terindikasi spamming, maka datanya harus bisa ditangkap oleh aplikasi dan diinformasikan ke pihak klien. Diskusi juga mencakup pembahasan mengenai skema aplikasi master-klien, yaitu berupa 1 dashboard untuk team Excellent sebagai admin dan 1 dashboard untuk pihak klien.

Setelah beberapa waktu, dibuatkan 1 buah mockup yang kemudian ditest dan divalidasi terus menerus. Semua kekurangan diperbaiki. Feature yang penting dilengkapi. Menu yang kurang jelas dikoreksi. Mungkin saat-saat seperti ini membuat team developer sebel karena requestnya jadi banyak. Apalagi ada juga request-request dari pihak klien yang ingin suatu laporan tertentu yang jika ditelusuri lebih jauh, muaranya bisa disiapkan via aplikasi.

Setelah dirasa mencapai level beta, aplikasi mulai difungsikan. Untuk kelinci percobaan, team membuat mail server dengan domain masing-masing dan digenerate account relay-nya via dashboard. Informasi yang terkirim via email dicheck ulang apakah narasinya sudah tepat. Apakah deskripsinya tidak membingungkan. Apakah display name sender-nya sudah benar. Pengecekan juga dilakukan di dua sisi dashboard. Disisi dashboard admin sudah benar, apakah disisi klien sudah benar juga.

Testing dilanjutkan dengan pengiriman email. Apakah lognya sudah terpusat. Apakah lognya bisa diparsing dengan benar. Bagaimana cara tahu suatu email dianggap bounced atau delivered. Disini team engineer Excellent yang masih muda berdiskusi dengan team software devs agar algoritma yang ada dan dijelaskan oleh team engineer bisa diterjemahkan ke logika programming.

Setelah fase beta selesai ditest, prosesnya dilanjut dengan memasukkan beberapa list klien prioritas kedalam dashboard smtp relay. Proses pengecekan diulangi dan hal-hal yang masih bermasalah terus diperbaiki sampai kami cukup puas untuk menerapkannya secara massal.

Yang pertama dimasukkan kedalam dashboard  adalah klien-klien yang murni langganan smtp relay. Setelah capek harus memasukkan data satu persatu, team engineer berdiskusi lagi dengan team software devs untuk menyediakan menu bulk import. Untuk menu disiapkan dan team engineer diminta membuat list klien dalam bentuk spreadsheet dengan format tertentu. Setelah semua dimasukkan, sistem dimonitoring kembali selama beberapa waktu.

Setelah sistem berjalan lancar, seluruh klien Excellent managed services dimasukkan kedalam database dashboard. Dengan demikian, secara resmi dashboard smtp relay Excellent diluncurkan.

Masukan-masukan dari pengguna layanan mulai muncul. Misalnya ada kebutuhan tambahan informasi subject agar proses tracking log lebih mudah dilakukan. Team engineer Excellent mengaktifkan feature ini disisi mail server, kemudian mencari cara untuk melakukan parsing datanya. Data yang sudah diparsing nantinya akan diolah oleh team software devs untuk diproses menjadi log tracking disisi aplikasi.

Saat ini dashboard smtp relay sudah berjalan selama beberapa waktu. Proses pengembangan dan monitoring aplikasi tetap dijalankan. Ibarat bayi baru lahir, team Excellent merawatnya secara hati-hati dan belajar melakukan scaling seiring dengan penambahan jumlah klien. Hidup team Excellent jadi lebih berwarna dengan adanya dashboar smtp relay 🙂

Jika tertarik mencobanya atau mengalami kendala pengiriman email atau berjuang mengatasi spam yang sering melakukan broadcast ke pihak eksternal, bisa kok melakukan trial aplikasi. Silakan meluncur ke sini : Layanan Excellent SMTP Relay