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

21May/160

DevConMru 2016, day 2 – Linux Installfest

Posted by Ish

It was Saturday morning and I found myself rushing to be at Flying Dodo just in time. Oh, to be precise «not in time» but like 15 mins later than I expected to be, that 09h45. The night before I got busy preparing the box of openSUSE goodies, sorted the stickers, pamphlets, DVDs and cheat sheets. Little I knew that folks would like those so much. I would tweet as I got the pack ready.





Shelly and I were the first geeks to reach Flying Dodo. While I would setup my laptop with the projector, she prepared the tables with the stickers and cheat sheets.

Developers Conference, Linux Installfest

The first few geeks came shortly afterwards. Ronny and Ajay from the Linux User Group of Mauritius came along with their gear. Oh, this little gang from the University of Mauritius hopped in and yes we were under attack. We also received the visit of folks from the PHP Mauritius User Group.



The morning session was great. Ajay, Pritvi, Ronny and Avish helped people getting their laptop Tux’ed either with Ubuntu or with openSUSE. Meanwhile I got to run an interactive session with the university folks with a command-line walk-through.


There was a question about email headers. I showed email headers from my Gmail account and also from Thunderbird. We talked a little bit about IETF RFC 2822 and together we looked at some of those colon-separated field values. Ajay gave us a simple yet clear explanation on SPF and DKIM. We did a ‘dig’ on a couple few domains to read the TXT records. Ajay explained about hard-fail and soft-fail in the SPF records and how they affect delivery of email.


I tried answering other questions that popped up; covering various topics like SSH, file permissions, etc, and we had real fun during that interactive session.


Jeshan joined us later after his AWS Lambda presentation at Voilà Hotel and offered a little support to Ashmita who tried installing openSUSE (dual boot) on her laptop. Mission was successful! It was great to meet Bernard who got an Ubuntu dual-boot on his laptop and Nirvan Mahadooa who wanted to meet the Linux geeks. I really hope we can continue the geek chat at a later time folks.


Some of us stayed till dinner-time at Flying Dodo sharing «samousa», pizza and beer. Oh, Shelly and I had non-alcoholic drinks. :D

Developers Conference day 2

The post DevConMru 2016, day 2 – Linux Installfest appeared first on HACKLOG.

Tagged as: No Comments
22Mar/160

Customizing the GNOME Shell

Posted by Ish

A couple of weeks back I was customizing the GNOME Shell on my openSUSE Tumbleweed laptop by tinkering with the CSS files of the desktop theme. A colleague of mine who peeked onto my screen at that moment, as he needed to show me something, nudged at the ugly rounded-corner buttons he saw on the taskbar. To be precise that was the “window list” that he saw, an extension that can be installed from gnome.org.

I told him it only requires editing the Cascading Style Sheet (CSS) of the extension, which could be found at /usr/share/gnome-shell/extensions/window-list@gnome-shell-extensions.gcampax.github.com, to adapt it to the desktop theme and make it more appealing. In fact, it did not take long to realize that removing the border-radius and the box-shadow actually blended the button better with the theme.

GNOME 3 - GNOME Shell, window list

.window-button > StWidget {
  -st-natural-width: 18.75em;
  max-width: 18.75em;
  color: #bbb;
  background-color: #393f3f;
  /* border-radius: 1px; */
  padding: 3px 6px 1px;
  /* box-shadow: inset 1px 1px 4px rgba(255,255,255,0.5); */
  text-shadow: 1px 1px 4px rgba(0,0,0,0.8);
}

He then pointed to title bar of the Firefox window and said “see, this thickness of the title bar makes it waste space.”

I looked at the window and replied “yeah, indeed but those should be configurable in some CSS file lying around.”

I then got back to work. Today, however, I looked at the title bar again and thought of reducing it’s size. A few hacks have been proposed by people who wished to achieve the same. The best proposal I saw was configuring through the gtk.css file rather than editing the individual theme files. If you do not find the gtk.css file, then create one ~/.config/gtk-3.0/gtk.css.

.header-bar.default-decoration {
    padding-top: 3px;
    padding-bottom: 3px;
}

.header-bar.default-decoration .button.titlebutton {
    padding-top: 2px;
    padding-bottom: 2px;
}

Adjust the padding value to get the desired result. The above gave me a slimmer title bar that would not waste space as before.

GNOME 3, GNOME Shell, window title bar

The post Customizing the GNOME Shell appeared first on HACKLOG.

Tagged as: No Comments
20Mar/160

Build a personal wiki using Vim

Posted by Ish

I used to have random notes in text files scattered on the disk. Then I tried being an organized person by using things like Google Docs… but, after some time I would find myself coming back to the simple text editor when in need of quick notes. On my openSUSE laptop I would either fire up Gedit or if the terminal is already open I’d use Vim.

A few days ago while searching for some packages in the openSUSE repo, I came across the vim-plugin-vimwiki package for Vim. It turned out to be a handy plugin for the Vim text editor.

sudo zypper in vim-plugin-vimwiki

At next launch of Vim, type ww and press “enter” to start the wiki.

gVim text editor

Screenshot of gVim

A folder named “vimwiki” will be created in the home directory of the user. For example for the user “ish”, the following message will appear upon typing ww:

Vimwiki: Make new directory: /home/ish/vimwiki
 [Y]es/[n]o?

A first blank file named “index.wiki” will be created in the “vimwiki” directory. The wiki has support for links, which are created using double brackets, e.g [[Hello Wiki]]. The text between the brackets become click-able and the file “~/vimwiki/Hello Wiki.wiki” is created.

Vim Wiki links

One can navigate through the pages by pressing “enter” while the cursor is on the “link text” and using the backspace button to go to the previous page.

What about existing text files?

The existing text files can be renamed with a .wiki extension and moved to the vimwiki directory. Then use the double brackets to link to that file.

I find the Vim Wiki being a simple & effective solution to take quick (re-usable) notes in an organized manner. Surely other solutions exist but at the moment I’d stick to Vim Wiki.

The post Build a personal wiki using Vim appeared first on HACKLOG.

Tagged as: No Comments
24Dec/150

Find user IP address with Cloudflare & Nginx

Posted by Ish

A content delivery network (CDN) is a distributed network of servers that delivers content, typically webpages, to users based on their geographic location. A CDN would serve you from a less distant location on the network.

CloudFlare provides such a CDN service. A friend recommended me to use CloudFlare around a year or so, and I do not regret accepting.

Find user IP address with Cloudflare & Nginx

CloudFlare Global Network, Source: cloudflare.com

I noticed considerable performance gain when I switched to CloudFlare.

PING hacklog.mu (104.28.11.229) 56(84) bytes of data.
64 bytes from 104.28.11.229: icmp_seq=1 ttl=51 time=114 ms
64 bytes from 104.28.11.229: icmp_seq=2 ttl=51 time=115 ms
64 bytes from 104.28.11.229: icmp_seq=3 ttl=51 time=113 ms
64 bytes from 104.28.11.229: icmp_seq=4 ttl=51 time=113 ms
64 bytes from 104.28.11.229: icmp_seq=5 ttl=51 time=114 ms

--- hacklog.mu ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 113.856/114.509/115.854/0.847 ms

CloudFlare bundles other features, among which the Firewall allows you to set rules for rogue visitors.

Get the user’s IP address with Nginx

CloudFlare proxies requests to your webserver and as such, your webserver log would record CloudFlare’s IP addresses. In order to obtain the user’s IP address in a request, you would need to activate the True-Client-IP Header from CloudFlare’s administration panel. However, that requires an Enterprise plan. It is not available in the free service.

There is one workaround using the ngx_http_realip_module in Nginx. It allows a change of the client address to one that is specified in the header field. CloudFlare specifies the same in the CF-Connecting-IP field. The technical story can be summed up as follows in the http context of Nginx:

http {

    set_real_ip_from 103.21.244.0/22;
    set_real_ip_from 103.22.200.0/22;
    set_real_ip_from 103.31.4.0/22;
    set_real_ip_from 104.16.0.0/12;
    set_real_ip_from 108.162.192.0/18;
    set_real_ip_from 141.101.64.0/18;
    set_real_ip_from 162.158.0.0/15;
    set_real_ip_from 172.64.0.0/13;
    set_real_ip_from 173.245.48.0/20;
    set_real_ip_from 188.114.96.0/20;
    set_real_ip_from 190.93.240.0/20;
    set_real_ip_from 197.234.240.0/22;
    set_real_ip_from 198.41.128.0/17;
    set_real_ip_from 199.27.128.0/21;
    real_ip_header   CF-Connecting-IP;

    ...
}

The IP addresses specified are those of CloudFlare and they can be obtained here. I suggest checking the page from time to time for updates or you might even monitor changes on the page (^^,) …


Ubuntu & openSUSE come bundled with ngx_http_realip_module. If Nginx is complaining about an unknown directive in your distribution, then you most likely need to compile Nginx with the --with-http_realip_module parameter.

The post Find user IP address with Cloudflare & Nginx appeared first on HACKLOG.

Tagged as: No Comments
19Dec/150

MaxCDN sponsors GNU Bash logo redesign

Posted by Ish

bash-orgOn 16 December 2015, Chet Ramey, the maintainer of GNU Bash announced an excited piece of news, that of new logo proposals for GNU Bash. The iconic Bash logo seen on the left was taken from tiswww.case.edu/php/chet/bash/bashtop.html.

Depending on the number of votes from the community, one of the below designs could soon sport GNU Bash.

new-bash-logo

Bash, which is a short form of writing Bourne Again Shell, is a Unix shell that comes bundled in Linux distributions and OS X. Released in 1989, GNU Bash was welcomed as a free software replacement for the Bourne shell.

Unfolding the story behind the Bash logo designs

maxcdn-logoI had this chat with Justin Dorfman, a fellow designer at MaxCDN, who had the idea of the GNU Bash logo redesign. As Justin explains, MaxCDN encourages its staff to contribute to Open Source in various ways.

Now, Justin is a huge fan of Bash, he adores stickers and realizing that GNU Bash doesn’t have an attractive logo, he wrote to Chet Ramey in September asking whether he would be okay with MaxCDN sponsoring a logo redesign. Chet showed the green light and Justin also obtained approval for resources from MaxCDN.

Justin says ProspectOne, the company behind jsDelivr and another freelancer were hired for the task. When the proposals were sent to Chet, he chose three designs by ProspectOne but could not further decide which one to select. Therefore they decided to let the final choice be that of the community and Chet sent the announcement on the bug-bash mailing list.

On the first day ~200 votes were recorded. A user by the name ‘anlar’ then posted about voting for the new bash logo on Reddit, which garnered 160 comments. At the time of writing this post over 12,000 votes were recorded, with logo no. 2 earning 79.3% of the votes.

gnu-bash-votes-10k

I thank Justin who provided me an insight of the story behind the new Bash logo. Below are some of the designs that were among the initial proposals.

BASH-new-logo-2015-v5
BASH-new-logo-2015-v6

Is the final GNU Bash logo decided yet? Nah. You still have time to vote for your favorite. Please visit the page, and cast your vote now.

The post MaxCDN sponsors GNU Bash logo redesign appeared first on HACKLOG.

Tagged as: No Comments
28Nov/150

Customize the shell prompt

Posted by Ish

During the week I confused the hostname of a friend’s machine to be his username. He has a MacBook Pro and the shell prompt in OS X displays like:

Hostname:CurrentDirectory User$

My openSUSE laptop has the following prompt and I like it this way:

ish@coffee-bar:~>

He then asked me how to customize the shell prompt. Now, the shell prompt consists of a set of characters that appear every time the shell is ready to accept a command; like we see above. In order to customize the shell prompt with information that we want to display we need to provide some special characters to the PS1 variable (PS stands for ‘prompt string’). Additional input can be provided through PS2, PS3 etc but that’s outside the scope of this post.

We can set the prompt temporarily trying various combinations of special characters by executing something like export PS1="[t w] $ " to see a prompt like [14:52:48 ~] $.

customize-shell-prompt

As we can see above different sets of special characters can be used to customize the shell prompt accordingly. The table below shows various special characters that can be used to further customize the shell prompt.

Variable Description
t Prints the current time in hours, minutes and seconds.
@ Prints the current time in 12-hour am/pm format.
$ Displays the user prompt ($) or root prompt (#), depending on which user you are.
h Prints the hostname of the computer running the shell.
H Prints the full hostname (e.g localhost.localdomain).
u Prints the current username.
w Displays the full path of the current working directory
W Displays only the current working directory base name (e.g /var/log/nginx will be shown as ‘nginx’ only).

To make the shell prompt customization permanent, the value of PS1 can be added to the .bashrc file in the user’s home directory (e.g /home/username/.bashrc).

The post Customize the shell prompt appeared first on HACKLOG.

Tagged as: No Comments
18Oct/150

Extend battery life on Linux with PowerTop

Posted by Ish

One of the greatest fun spoilers when loading your favorite Linux distribution on your new laptop is battery life.

Yes, the battery life that goes upto 4 hours with Microsoft Windows could easily drain down to 2.5 hours with a classic Ubuntu installation. A major argument will be that Linux distributions do not come with optimized under-the-hood power settings. We should not forget that most Linux distributions aim to support a majority of computer hardware out of the box. We are surely happy that we do not need to struggle with hardware incompatibility issues, driver versions etc, as it could be the case with a Windows installation. However, the downside is that the Linux kernel could be bloated with “stuffs” not required for your laptop.

In a recent past there was a tool called Jupiter that allowed some handy power consumption optimizations. The project is now discontinued.

Some claim that TLP which was originally designed for ThinkPads, could optimize power consumption on other brands. I had no such luck with an Acer Aspire notebook.

Recently, I tried PowerTop, a power-management utility by Intel that enables a series of powersaving modes in userspace, kernel and hardware. PowerTop can also monitor and identify applications with a high power demand. I’ve used PowerTop to extend the battery life of my ThinkPad from 3.5 hours to 6 hours; a whopping 2.5 hours gain.

Powertop can be installed from the Ubuntu software repository.

sudo apt-get install powertop

At first run, you need to calibrate it so as it gathers as much information about your machine.

sudo powertop --calibrate

This could take up some minutes and the screen would flicker and even turn off for a while. Do not panic, just let it run and go grab a coffee.

Once done, PowerTop will load with an “overview” of your running applications, their power consumption and battery life estimation. Press the “tab” button to navigate through. The “tunables” tab lists a series of settings that have been applied to your system.

powertop-tunables

After the calibration, PowerTop will have a list of measurements that it could use to tune your system every time you launch it. Therefore, next time you may launch PowerTop as follows:

sudo powertop --auto-tune

Ideally, you could also start PowerTop when the laptop boots. Just add the following in the /etc/rc.local file before the exit 0:

# Loading power-saving schemes
powertop --auto-tune

On that note, happy power saving :)

The post Extend battery life on Linux with PowerTop appeared first on HACKLOG.

Tagged as: No Comments
11Oct/150

Node.js smart server by Yog Lokhesh Ujhoodha

Posted by Ish

The Linux User Group of Mauritius organized a Node.js presentation yesterday at the University of Mauritius. Logan announced the same weeks ago and the prez was done by fellow Yog Lokhesh Ujhoodha.

The night before I had a “Happy Hour” party with colleagues and consequently Saturday morning left me drowsy. I reached the University of Mauritius before noon and was damn hungry. I was looking for room 2.12 when I met Yog, Logan and Humeira who were chatting near in the corridor. Others were having a casual talk in a smaller room while waiting for another class to be free. We needed the projector and a little bit of electricity to power Logan’s laptop :) The fellow has been doing a nice job by supplying gear for broadcasting the meetups on YouTube and allowing remote participation through Google Hangout. Kudos for that!

Thanks to Veer who was heading for the cafeteria, I asked him to bring me some food too. That saved my life :)

The prez started around 12h30 with a dozen participants in the class and several others through Google Hangout.

yog-nodejs-prez

Node.js presentation by Yog Lokhesh Ujhoodha

lugm-usual-suspects-at-nodejs-prez

LUGM usual suspects :)

Yog introduced Node.js and cleared the myth whether ‘Node.js’ is a webserver. It’s a runtime that executes JavaScript on the server-side using Google’s V8 open source JavaScript engine. I particularly liked the flow of his prez in the sense that he described a problem and what followed was how he would tackle it. Along the way, he gave an overview of web server architectures laying emphasis on multi-threaded vs event-driven; while taking Apache and Nginx as examples.

Yog explained through his code, how he identifies the number of CPU cores in a machine and proceeds with forking of child processes.

var cluster = require('cluster');
var numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
    // fork workers
    var proc = Array();
    for  (var i = 0; i < numCPUs; i++) {
        proc[i]=cluster.fork();
    }
}else{ //forked worker

}

Later on he would explain how he runs the child process on a specific CPU core and thus eliminates delays caused by CPU switching [etc..] which he explained initially when describing webserver architectures. Those who missed the meetup can catch up on YouTube.

As and when Logan would switch to remote participants, Nitin and I grabbed the moment to discuss about his new blog tunnelix.com. I also showed Humeira the Firefox OS running Orange Klif mobile.

While others left after the presentation, some of us headed to Bagatelle Mall for a chill-out moment.

The post Node.js smart server by Yog Lokhesh Ujhoodha appeared first on HACKLOG.

Tagged as: No Comments
2Oct/150

LUGM at Infotech 2015

Posted by Ish

I had a brief visit to Infotech 2015 today. An important task was to deliver Logan the banner of the Linux User Group of Mauritius (LUGM). He’s been demo’ing some cool Arduino based robots since yesterday along with Christian Gunnoo. When I reached the Swami Vivekananda Int’l Convention Centre today, I first looked out for the LUGM fellows. I saw Mike & Jessica were there having a chat with the geeks. Cool, I jumped in the convo, greeted everyone and gave Logan the banner.

lugm-infotech-2015

Next to LUGM, there were fellows from the Middlesex University. They also had some cool Arduino projects to display.

On a sad note, the table arrangements got both LUGM and Middlesex University in a blind spot. They were on the same row as the National Computer Board outside the main hall. Nevertheless, I should commend the good work achieved by Logan & Christian to interact with young fellows who made it till there.

Next, I headed inside the main hall. I was looking for the stand of Amazon Web Services (AWS) but before that I got to meet Louis from ICT.io. I had a chat with him and another fellow I happened to meet there. In fact, they showed me where the AWS stand was and I hopped there.

I met Chris Perkins from AWS and we talked quite lengthily about the various cloud services. My main mission was to meet some technical guys and we could have a geek chat about how we’re building up the infrastructure for the next lexpress.mu. Yes! If that comes as a surprise, I now work for LSL Digital :)

aws-infotech-2015

Chris happens to be a Manager within AWS Cloud Support and we had a very interesting chat about operations, sysadmin skill set and all. Chris and his colleagues are in Mauritius to recruit for AWS South Africa. If you’re interested to put your genius in action and be part of the AWS family, you still got two days; put your laptop in the backpack and go meet Chris at Infotech 2015.

I then met Dinesh, an ex-colleague from Linkbynet :) We had a chat about the fun days when I was a Unix System Administrator at Linkbynet. We talked about the shortage of sysadmins and the gap that needs to be filled.

linkbynet-infotech-2015

I left around 13h30 and headed back to LSL Digital. I should be there, at Infotech 2015, tomorrow along with other LUGM members talking about Linux. Meet us at the LUGM stand :)

The post LUGM at Infotech 2015 appeared first on HACKLOG.

Tagged as: No Comments
26Sep/150

Introduction to Flask

Posted by Ish

On the 14th of September 2015, Avinash Meetoo replied to this email on the Linux User Group of Mauritius (LUGM) mailing list and showed interest in doing a presentation for the next LUGM meetup.

The meetup happened today in Curepipe. I was not able to attend it physically, but thanks to Logan who did the necessary for setting up a Google Hangout session, I joined around 13h00. Shortly after, Avinash started his presentation “Introduction to Flask”.

flask-intro-avinash-meetoo

He welcomed everyone who joined and gave a quick brief about the underlying infrastructure of webapps. I particularly liked the way he explained the model-view-controller (MVC) software design pattern; taking from there he talked about Python frameworks. The popular Django framework comes first, Avinash says. Django should be a powerful framework when a lot is needed for a project, like an interface for backend etc. However, if someone wants a pretty quick setup, say for example a prototype for demo’ing to customers or a small web application, there is this Python micro-framework called Flask that comes handy. Avinash explains why it’s called a “micro” framework; reason being it’s limitation to a subset of functions that full stack Python frameworks would offer. Nonetheless, the functions in Flask are pretty enough for setting up web applications.

flask-logo

Avinash mentioned how he uses Flask in his many projects at Knowledge Seven and how he designed his web application electionsmauritius.com. He and his wife, Christina, came up with an idea about a web application to help Mauritians vote intelligently, two weeks before the General Elections 2014. Avinash then put his genius in the making of the “Elections Mauritius” webapp.

During the presentation, Avinash showed a demo of a simple web application and unveiled the code behind his “Elections Mauritius” web application. The prez lasted for approximately 50 mins including the questions & answers at the end. Those who missed the Hangout session can still catch up on YouTube and once again, thank you Avinash :)


Flask logo used from flask.pocoo.org.

The post Introduction to Flask appeared first on HACKLOG.

Tagged as: No Comments