Linux User Group of Mauritius Promoting open source software in our beautiful island

22Feb/200

Anatomy of a generic function in Rust

Posted by Ish Sookun

Consider the following function in Rust:

fn additems<T: Add<Output = T>>(i: T, j: T) -> T {
    i + j
}

It can handle different input types and thus it's called a generic function. The generic data type is represented by the capital letter T in this example. T is an arbitrary placeholder. It could be have been another letter, X, Y or V, but  when using T it can be easier to remeber that it refers to a "type".

I don't usually write code but I do enjoy reading and here the syntax of the function definition can be daunting at first. Let's have a look at a simpler version.

fn additems(i: i32, j: i32) -> i32 {
    i + j
}

We define a function called additems that accepts two arguments, each of 32-bit signed integer type and the function returns a value of the same type. If 64-bit integers or float values are passed on to the function it will throw a mismatched types error.

error[E0308]: mismatched types
  --> src/main.rs:13:24
   |
13 |     let sum = additems(5.0,6.0);
   |                        ^^^ expected `i32`, found floating-point number

error[E0308]: mismatched types
  --> src/main.rs:13:28
   |
13 |     let sum = additems(5.0,6.0);
   |                            ^^^ expected `i32`, found floating-point number

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`

By using generics we can make the function additems accept both float and integer values. Following an example from doc.rust-lang.org one would tend to try specifying the generic type T as <T> and start using it.

fn additems<T>(i: T, j: T) -> T { ... }

Alas, the compiler would complain about binary operation not possible on type B.

error[E0369]: binary operation `+` cannot be applied to type `T`
 --> src/main.rs:9:7
  |
9 |     i + j
  |     - ^ - T
  |     |
  |     T
  |
  = note: `T` might need a bound for `std::ops::Add`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0369`.
error: could not compile `namaste`.

The compiler is helpful enough to hint that we need to implement the std::ops::Add trait. Adding the following line use std::ops::Add; brings the Add trait into scope.

(More about these traits can be found in the Rust documentation about the overloadable operators module.)

The T type is then bound by the Add trait as <T: Add<Output = T>> and the complete block becomes:

use std::ops::Add;

fn main() {
   let sum = additems(5,6);
   println!("sum: {}", sum);
}

fn additems<T: Add<Output = T>>(i: T, j: T) -> T {
    i + j
}

The function additems can now accept two integers or two float values and do an addition operation on them.

Filed under: Rust No Comments
15Feb/200

oSLO Conference 🐧

Posted by Ish Sookun

oSLO is short for openSUSE + LibreOffice.

The two projects are celebrating their 15ᵗʰ and 10ᵗʰ anniversary respectively in 2020. To mark the occasion, openSUSE and LibreOffice projects are organizing a joint conference from 13ᵗʰ to 16ᵗʰ October 2020 in Nuremberg, Germany. The conference will take place at Z-bau (Frankenstraße 200). It is the same location where last year's openSUSE Conference was held.

openSUSE and LibreOffice conferences are meant to bring like minded people together to discuss about topics relative to the projects. People can learn, teach and share their passion about the projects.

Last September, openSUSE announced a logo design competition for this co-conference with LibreOffice. Early this month the winner of the competition was announced. Kukuh Syafaat from Indonesia won the hearts of the co-conference organizing team.

Logo design by Kukuh Syafaat for oSLO Conference, Nuremberg.

The conference is free to attend. Mark you calendar & join the fun!

Call for Papers

The organizing team is currently accepting proposals for sessions. The deadline for submission is 21 July 2020.

Tagged as: No Comments
2Feb/200

openSUSE Board election 2019-2020 result

Posted by Ish Sookun

The openSUSE Board election 2019-2020 reached an end on the night of 31 January 23h59 CET after running for about two weeks.

Four candidates ran in this election and the result is as follows:

Simon is re-elected and gets to serve for another term while Sarah replaces outgoing board member Gertjan Lettink.

281 out of 500 eligible members voted in this election.

Filed under: openSUSE No Comments
26Jan/200

LibreOffice dark icons

Posted by Ish Sookun

Every application has a dark mode now or will surely have a dark theme in the near future.

I am running openSUSE Tumbleweed with KDE Plasma and Materia Manjaro Dark theme. It's almost like the Breeze Dark theme of openSUSE/KDE but with slightly more greenish elements. Whether using dark themes in GNOME or KDE I am usually left with a not so pleasing toolbar in LibreOffice.

Until today, I didn't bother much about it. Then, I thought of changing that and to my surprise it was just a few clicks way.

Tools > Options

Set the icon style to "Breeze (dark)" and it's done.

Et voilà! :)

Filed under: KDE, LibreOffice No Comments
25Jan/200

Kopano: Unknown MAPI Error

Posted by Ish Sookun

If you're thrown an Unknown MAPI Error: MAPI_E_NOT_FOUND when logging with a newly created account on Kopano, it is mostly because the user does not have a store. The kopano-server log doesn't help much to identify this neither does the webapp which only throws the MAPI error.

It is most likely to occur when using an external user database such as LDAP. The users database is synced successfully with LDAP, creating the new user but the store is not created and attached to the account.

In the case if the user was not synced the kopano-server log would have a proper message indicating that it failed to authenticate using the LDAP plugin.

Jan 25 18:26:35 kopano-1 kopano-server[28463]: Authentication by plugin failed for user "bajirao.singham": Trying to authenticate failed: Failure connecting any of the LDAP servers; username = bajirao.singham

If the user could not authenticate then the webapp would display a "logon failure" message while asking to verify credentials. It would not display the MAPI error.

Checking the user details with kopano-admin does however hint at the missing store.

$ kopano-admin --details bajirao.singham
User object id:         00000000AC21A95040D3EE48B319FBA75330442501006001
WARNING: Unable to get user store entry id. User possibly has no store.

User store id:          
Username:               bajirao.singham
Fullname:               Bajirao Singham
Emailaddress:           bajirao.singham@xxx.xxxxxx.xxx
Active:                 yes
Administrator:          no
Address book:           Visible
Auto-accept meeting req:no
Mapped properties:
        0x8C6D0102                      48 bytes
        PR_GIVEN_NAME                   Bajirao
        PR_BUSINESS_TELEPHONE_NUMBER    +2301234567
        0x3A0C001E                      en_US
        PR_SURNAME                      Singham
        PR_TITLE                        Police Officer
        PR_MOBILE_TELEPHONE_NUMBER      +23051234567
        PR_LOCALITY                     Shivgarh
        PR_POSTAL_CODE                  457001
        PR_EC_ENABLED_FEATURES          mobile; outlook; webapp
        PR_EC_DISABLED_FEATURES         imap; pop3
Unable to show object quota information: missing or invalid argument (0x80070057)
Groups (1):
        Police Force

Create a store using the kopano-admin tool.

$ kopano-admin --create-store bajirao.singham

The store will be created and hooked to the bajirao.singham user account in the above example. Login with the account should then be successful.

Filed under: Email, Kopano No Comments
17Jan/200

AFRINIC WHOIS database tampered?

Posted by Ish Sookun

In a recent official communiqué, AFRINIC, the Regional Internet Registry (RIR) for Africa, wished its members and the community a happy new year while giving updates about some changes in the different committees.

In the same email, AFRINIC CEO, Eddy Kayihura, informed the community that following allegations of fraudulent manipulation of the AFRINIC WHOIS database, the matter has been referred to the Central Criminal Investigation Division (CCID) of the Mauritius Police Force for further investigation. Also, due to the serious nature of the allegation, an employee of AFRINIC, whose name has been cited in the allegation, has been immediately dismissed on grounds of very serious professional misconduct.

AFRINIC is working to "restore" the WHOIS database accuracy, as per the email.

Tagged as: No Comments
29Dec/190

An unnamed cyclone🌀

Posted by Ish Sookun

I woke up this morning to learn that the Mauritius Meteo Office has issued a cyclone warning Class I. But the cyclone has no name. On the social networks people find this weird too. It is the first time that the Meteo Office has issued a "cyclone warning" for an unnamed cyclone.

At this morning, the satellite image published on the Meteo office website would call this unnamed cyclone Tropical Disturbance 'C'. That explains it. The 'system' hasn't intensified enough to be categorized as a tropical cyclone. The latest cyclone bulletin issued at 10h10 calls this 'system' a tropical depression.

Image source: Mauritius Meteorological Services

The satellite image shows that the Tropical Depression 'C' was situated at about 350 km to the north-east of Mauritius. As per the forecast of the Met Office, there is a chance that it will further intensify into a tropical storm.

We will find more in the next cyclone bulletin which will be issued at 16h10.

Meanwhile, there is intermittent rain in Providence with strong gusts of wind at certain times.

Updates

  • The tropical depression intensified to become a moderate tropical storm which has been named Calvinia. The same was communicated in the cyclone bulletin issued at 10h10.
  • Fourth cyclone bulletin was issued at 22h00 on Sunday 29 December 2019. Moderate tropical storm Calvinia was centered at about 190 km to the east of Cap Malheureux.
  • In the sixth cyclone bulletin issued at 09h00 on Monday 30 December 2019 a cyclone warning Class III was announced. This bulletin caused more chaos than the rain and winds did in certain regions. By 09h000 a lot of people had reached their workplace or were on the way to office. Upon the issuance of a Class III warning everyone has to return back home causing huge traffic jams and inconvenience on the roads.
  • Eighth cyclone bulletin issued at 16h00 on Monday 30 December 2019 indicated that severe tropical storm Calvinia remained stationary at about 90 km off the coast of Mahebourg.
  • Tenth cyclone bulletin issued by the Meteorological Services at 22h00 on Monday 30 December 2019 indicated that the severe tropical storm Calvinia had only looped on its position and moved closer to Mauritius. It was centered at 70 km to the south-east of Mahebourg.
  • The fourteenth and last cyclone bulletin was issued at 10h00 on Tuesday 31 December 2019 by the Meteorological Services. Calvinia was moving away from Mauritius and was situated at about 130 km to the south-east of Blue Bay. The cyclone warning was lifted.
Image source: Mauritius Meteorological Services
  • The sun is back in sky⛅ but there is still rain from time to time with strong gusts of wind. 🍃
  • Banks & shopping malls opened their doors as from half-day on this Tuesday 31 December 2019. People could do their last-minute shopping on new year's eve. 😊
Tagged as: No Comments
28Dec/190

openSUSE Board election 2019-2020

Posted by Ish Sookun

This year's openSUSE Election Committee is composed of Ariez Vachha, Edwin Zakaria and myself. Ariez joined the committee for the first time, while Edwin and I have worked together on the previous Board election. Weeks ago, after consulting the election rules and brainstorming a bit, we came up with an election schedule that spans over several weeks, starting in December 2019 until January 2020.

Image credit goes to openSUSE member Aris Winardi

Candidates

As the call for nominations and applications ended on 25 December, we had a list of four candidates for the two seats on the openSUSE Board. The candidates are:

The election campaign now begins. Members are encouraged to ping the candidates and ask them questions about their views and ideas that they'd like to bring on the the openSUSE Board.

Filed under: openSUSE No Comments
24Nov/190

Preps for the Developers Conference 2020…

Posted by Ish Sookun

Preparations for the Developers Conference 2020 have begun. The date, location and theme have been announced.

The next Developers Conference, simply dubbed DevCon 2020, will be held on 2 - 4 April at the Caudan Arts Centre in Port-Louis, Mauritius. This time the conference theme is Comics, which I am pretty sure requires no further explanation as to what to expect.

A few of our regular supporters have already joined as sponsors, while others have expressed their intention to back us financially in the coming days. The conference cannot happen without the help and support of the sponsors and the commitment to support the DevCon organizers every year is really appreciated. May the force be with you & your organizations prosper!

Developers Conference is an event by the community for the community. We should not forget this. Everyone's help is welcomed and appreciated. In fact, next year we're aiming big and the more backers we have the merrier!

If you believe there are organizations out there that can support us please share the conference brochure with them. The brochure explains about the conference, the different sponsorship tiers and ways in which an organization can help in making DevCon 2020 another great & awesome conference!

Meanwhile, you out there, if you've been to the Developers Conference before, then how about submitting a paper this time? Take the leap and do it!

24Nov/190

Change the page margins for a single page in a LaTeX document

Posted by Ish Sookun

I've looked for it myself and search results always return complicated hacks to achieve it. Adjusting the top, bottom or right and left margins (only) are not usually a straightforward task if you do not know the right package to use.

Like for example, this StackExchange (TeX) suggestion is definitely NOT recommended.

The reasons to have to modify the page margins in the middle of a document could vary; say if you need to display an almost "full-page" figure in a landscape layout, you'd surely be touching the margins and getting additional blank pages being created if you do not reduce those margins of the current page.

The simplest way I found of doing it is using the changepage package available from ctan.org. While the package provides several commands to adjust the page margins, text blocks or the entire page design, I find the below single line command extremely useful.

\changepage{〈text height〉}{〈text width〉}{〈even-side margin〉}{〈odd-side margin〉}{〈column sep.〉}{〈topmargin〉}{〈headheight〉}{〈headsep〉}{〈footskip〉

Thus, in one single line the entire page can be re-designed in the middle of your LaTeX document.

The changepage command takes nine arguments, which can either be blank or contain a value of a length. The length value is added to the current length. If a length value is not supplied then a zero value is assigned which is then added to the current length, therefore, resulting in no change. A negative value is used to reduce the current length.

Filed under: LaTeX No Comments