Impressões de migração do Windows para o Elementary OS (não-superusuários)

O título não é lá essas coisas, mas a ideia é bastante simples: decidi tentar migrar o workflow de computação dos meus pais para o Linux. Eles tipicamente utilizam Windows mas, com a exceção de um ou dois programas, todos os outros estão também disponíveis para o Linux.

Na primeira vez que tentei fazer isso, em meados de 2012 ou 2013, foi um fracasso. Em primeiro lugar, eu estava aprendendo sobre Linux e, em particular, sobre a enorme diversidade de distros que estavam disponíveis na época. Acabei optando pelo Ubuntu (…12.04 ou 12.10). Só que foi um desastre. Eu tinha o Ubuntu instalado no meu próprio Desktop, com a interface do Gnome 2 (heck, eu sequer sabia o nome da interface). Quando instalei o Ubuntu no PC dos meus pais, do nada apareceu outra interface. Depois eu descobriria que a interface em questão era o Unity, que eu (e eles) detestaram, mas eu fiquei bastante perdido para configurá-lo com o Gnome 2, com o qual eu estava acostumado.

Alguns programas eram esquisitos (para eles) — por exemplo, evolution como leitor de emails em vez do thunderbird / outlook. O dock na lateral esquerda também não era intuitivo. Nem mesmo o botão de desligar…enfim, esse setup chegou a durar algumas semanas, mas não deu certo, e acabaram voltando para o Windows. Enquanto isso, eu começaria a minha quest (parte da qual está documentada nesse blog) de testar dúzias de distros diferentes e formar novas opiniões.

Alguns anos depois, agora em 2017, decidi fazer uma nova tentativa. Há cerca de dois meses, instalei o Elementary OS e deletei o Windows (10) do PC deles (yeah, nada de dual boot, não dá pra fazer transformação de mentirinha: ou vai de uma vez só, ou não vai).

Algumas razões para escolher o Elementary OS em vez de zilhões de outras distros incluem:

  • não é o Ubuntu (yaaaaay!)
  • é beginner-friendly e user-friendly
  • o foco da distro está em usabilidade e design, e não em configurações ou linha de comando ou…
  • utiliza um package manager bastante standard (o apt). Aqui existem vantagens e desvantagens mas, nesse contexto, isso é uma vantagem, principalmente pela quantidade de pacotes já disponíveis no ecossistema deb;
  • o seu desktop environment padrão é o pantheon, que é realmente excelente, e bastante simples e polido para usuários novatos.
  • o plank (que é o seu dock) também é bastante refinado — já foi bem ruinzinho, mas hoje em dia está ótimo.

Baseado nessa lista, outras distros promissoras nessa categoria incluem o Linux Mint, o Zorin OS e o PC-BSD. Por que não o Zorin OS? Porque ninguém usa essa joça. Se fosse pra ser indie, então eu instalaria o Gentoo ou o Arch e faria uma customização massiva para deixá-los user-friendly, então tchau tchau pro Zorin.

O PC-BSD não foi considerado porque ele não é Linux, é um mero spin-off do FreeBSD, e os caras renomearam o projeto recentemente para TrueOS, eu não estou interessado em projetos que estão mudando de nome e FreeBSD para Desktop não é lá grande coisa.

Dito isso, o Linux Mint poderia ser uma segunda opção. O motivo de ter optado pelo Elementary OS é porque eu perdi a confiança no projeto ao longo dos anos (Linux Mint já foi uma das minhas distros principais), por uma série de motivos que não valem a pena ser mencionados aqui; enquanto que a minha confiança no Elementary OS só veio aumentando (eu cheguei a conhecer um dos fundadores no SCALE14x, você percebe que os caras têm uma enorme paixão pelo que fazem, é fantástico).

Vale dizer que o Elementary OS não é lá grande coisa, ele possui uma porção de bugzinhos, que são fáceis de ser notados à medida que você usa o sistema, mas ele é razoavelmente estável, suficientemente usável. Por exemplo, o pantheon-files, que é seu file manager padrão, possui um bug ridículo na ação de renomear pastas, ela só funciona se você apertar ENTER (clicar com o mouse fora da área de escrita implica em retornar ao nome original). Eu optei por instalar o Nautilus, que inclusive possui integração com o Dropbox, o que é um bônus.

O Geary, que agora é chamado de Pantheon Mail, também é buguento. Se você adicionar uma conta de email dele mas depois se arrepender e quiser deletá-la, você…errr, simplesmente não pode fazer isso. (de forma user-friendly, ao menos). Bom, o Thunderbird está aí para essas horas sombrias.

Existem vários bugzinhos nesse estilo, coisas que são inconvenientes e que claramente não deveriam estar ali, mas que estão. Aparentemente a comunidade está ciente disso, ao menos em alguns deles, então é provável que eles sejam consertados na release 1.0 (a release atual é a 0.4).

Se você superar os bugzinhos e não surtar com isso, podemos ir para a segunda etapa. Alguns tweaks e atitudes que se provaram boas incluem:

  • unattended-upgrades, apt-cron: para manter o sistema atualizado automaticamente;
  • redshift para manter a saúde dos olhos (ninguém liga pra esse negócio de espectro vermelho e azul, mas as pessoas realmente deveriam se importar mais com isso, especialmente nesses tempos atuais em que o uso de dispositivos eletrônicos é massivo);
  • dropbox para backups (infelizmente nenhum cliente do google drive está disponível gratuitamente para Linux, até hoje), com integração com o Nautilus;
  • VMWare Player para manter um Windows “de emergência” para os programas que não estão disponíveis para Linux;
  • zramswap e diminuição do valor de swappiness do kernel para dar uma aliviada no disco rígido. O valor default é 60; eu diminuí para ~20–30. É uma faixa de valores razoável para um desktop com 4GB de RAM;
  • preload para carregar programas mais rapidamente na inicialização;
  • indicator de velocidade de rede no wingpanel;
  • VLC como reprodutor padrão de vídeos;
  • não instalar o vim. Ele insiste em ser o visualizador de arquivos padrão para um monte de formatos. Até mesmo o pacote vim-nox atrapalha.
  • desabilitar serviços desnecessários no systemd (systemctl list-unit-files; systemctl disable <unit>). Sim, a release atual do elementary OS usa o systemd.

Também convém instalar pacotes relacionados a NTFS e V-FAT, para pen-drives. Acho que um dos pacotes se chama dosfstools ou algo similar.

Tenho rodado esse setup há dois meses e ele tem se mostrado bem estável e razoável. Estou satisfeito. E, o melhor de tudo: a manutenção é mínima, não precisa de anti-vírus, e é rápido. Trava muito pouco, se comparado com o Windows 10. Todos os pacotes estão sendo gerenciados pelo apt: não há nenhum software instalado localmente, por fora. Isso diminui drasticamente qualquer necessidade de manutenção. Todos os scripts que estão rodando automaticamente (que não foram mencionados aqui) estão sendo gerenciados pelo systemd (timers!) e/ou pelo anacron.

Alguns projetos futuros incluem:

  • gerenciar e configurar o sistema com o saltstack;
  • minerar bitcoin;
  • tentar utilizar o wine em vez do VMWare para os programas que não estão disponíveis para Linux;
  • adicionar um firewall ecochato;
  • backups automáticos (btrfs snapshots? Periodic rsync?).
Advertisements
Impressões de migração do Windows para o Elementary OS (não-superusuários)

Preparing the LaTeX environment for my undergrad thesis[3]

Context

I am a big fan of LaTeX since high school (thanks, OBMEP, for the gentle introduction and serendipity of this great tool[1]!). Since about ~9 years ago, I am constantly learning something new about it every day, saw its evolution over the years (thanks, TeX.SE, LuaTeX, and friends!), tried it in all major platforms (MikTeX on Windows, TeXLive on Linux and MacOS) and typeset it with almost all available text editors (Kile, TeXMaker, TeXStudio, TeXShop, Notepad++, Vim + latexsuite, Emacs + AUCTeX…)…

That was just to exemplify how much enthusiast I am about it and, as a side effect, how much opinionated I am.

I am about to write the biggest LaTeX project I’ve ever come across: my undergrad thesis[3]. This is big enough in my “LaTeX career” that made me completely rethink about how I usually interact with it:

Comments

Before going on…

  • This is not a tutorial. It is just the documentation of the ideas / conceptions and a proof-of-concept arrangement of the steps I did to set up a comfortable writing environment for myself. It may or may not work for you. You have been warned.
  • Microsoft Word is completely out of question.
  • Google Docs might be interesting as a temporary document for the purpose of “code reviews” (how do you call that in the writing world? “Document review”?).

Goals / Design Doc

  • A decent, off-line, LaTeX environment (sharelatex and overleaf are out of question).
  • Spell-checking.
  • Version control.
  • A cross-platform environment (it should work at least on Windows, Linux and MacOS). Honestly I don’t really care about Windows support, but it would be nice to be compatible with it too, at least a little bit.
    • Corollary: it should contain a Makefile (or support a similar build tool).
  • It should use a template specifically intended for an undergrad thesis.
  • Integration with an on-line CI server that automatically builds every commit, yielding the thesis PDF as its output.
  • Builds should be fast, preferably under 5 seconds.
  • LuaTeX support would be welcome.
  • It should use only macros and packages in an standard and typical LaTeX installation. Third-party packages should not be welcome, unless strictly necessary.
  • Bibliography management tool.
    • Bonus: graphical
  • No “typesetting hell” ==> I don’t want to run pdflatex 3 times manually.
  • Synctex support.
  • TODO support from within LaTeX.

Instance

  • Git for version control.
  • Bitbucket for private git hosting
  • TeXShop or VSCode as text editor. No vim in this context.
  • latexmk + make as build tool
  • BibTeX as bibliography management tool.
    • Plus JabRef as its GUI editor
  • Bitbucket Pipelines as CI tool.
  • LuaTeX (lualatex) as LaTeX typesetting engine (see this)
  • ChkTeX as linter / semantic checker
  • Docker for container isolation (whoa, a full ‘texlive-full’ installation (Ubuntu) takes a long time to complete!)
  • VSCode with the LaTeX Workshop extension does have synctex support
  • For TODO support, todonotes seems to be really nice.
  • Coppetex as the base template for my document.

Post-analysis

As you see, I decided to completely renew my environment and to use everything I learned over these years to make it “on steroids”.

This is by no means required in my college; its expectation bar is kinda low for this task, with lots of people just using Microsoft Word [citation needed]. Here is my opinionated vision: big mistake. We are in 2017, LaTeX is not as hard to use as in the <2000s.

However, I also realize that the {Sys,Dev}Ops approach I am taking to write my LaTeX thesis is way too unnecessary and it contains lots of “bells and whistles” and idiosyncrasies related to the thinks I currently like to do. That said, I strived to keep it KISS and I’m really proud of its result.

I will probably release my [environment] / [template repo] publicly on GitHub once I am done. Now I should focus on writing, actually writing.

I might also create a tutorial (as a complement to this post) once I am done, conditionally to the number of people interested on this. Let me know if you’re interested. Something such as “What do you need to know to write your undergrad thesis in LaTeX – KISS version”.

References

Footnotes

  • [1]: LaTeX is not just a tool. It is a thought and writing philosophy. It is almost a religion, just like Unix / Linux, and…systemd[2], of course.
  • [2]: I should probably start a new article in Wikipedia. Just like Godwin’s Law, there should also be a “Perrotta’s Law”:

“As an online discussion or article grows longer, the probability of a paragraph mentioning systemd approaches.”

  • [3]: I really don’t care how people call each of the documents, depending on its level. Whether it is “monografia” (monograph?), dissertation or thesis, whatever. I call everything “thesis”. Therefore, despite not being a doctor, I will write a thesis, period.
Preparing the LaTeX environment for my undergrad thesis[3]

Russian / Ukrainian music

Recently I’ve fallen in love with a set of Russian and Ukrainian music, mostly pop, dance, R&B and hip-hop. This post aims to contain a small (but updated on-the-fly) index of artists, duos and bands with the purpose of representativeness and to provide the reader a good starting point to know what I’m talking about.

Note: last.fm, YouTube and Spotify are good resources to find out more information about them. VK also seems to be a pretty popular Russian social network, and discogs contains a good catalogue / index (Discogs is to artists and tracks what Goodreads is to authors and books).

Note: the order of the following list does not necessarily imply preference, although Nyusha is definitely my preferred one.

Index

  1. Нюша / Nyusha: last.fm
  2. Тамерлан И Алена / Tamerlan & Alena : last.fm
  3. Полина Гагарина / Polina Gagarina: last.fm
  4. Artik & Asti: last.fm
  5. Elvira T: last.fm
  6. Потап И Настя Каменских / Potap and Nastya Kamenskih last.fm
  7. Алсу / Alsou: last.fm

Trivia

  • Akinator managed to find out, after ~60 questions, that I was thinking on Nyusha.

Screen Shot 2017-05-07 at 01.01.22.png

  • Nyusha participates in the Russian version of The Voice Kids.
  • Polina Gagarina participates in the Russian version of The Voice.
Russian / Ukrainian music

Journalog #3: eudyptula – challenge #1

This is not really a challenge; I’ve done it before. Anyways, now I have the insight about what’s happening behind-the-scenes, and also it’s very easy to recreate the environment and obtain the tools I need to do it.

The first challenge is very simple, as rephrased in my own words:

Write a hello world linux kernel module for your current kernel (supposedly 2.6+), which writes “Hello World!” to your kernel debug log level, upon its initialization.

Tools and programs you’ll need: vim, make, insmod, lsmod, rmmod. And, later on, mutt or sendmail or similar to send your work to little.

Overview

It’s better to start with the Makefile. Add at least two targets to it: all and clean. Refactoring variables (for example, paths) is also nice, if you see yourself repeating the same strings in both targets.

Later, you will create a hello.c file which should be very simple in nature. It should have two functions, one for initialization and one for cleanup for the time the module is unloaded. It will probably also have a couple of standard macros for modules.

Testing your work should also be very straightforward: (i) make, (ii) insmod hello.ko, (iii) rmmod hello. And see your log messages with dmesg | tail.

After everything is done, you can use mutt to send your sources to little, either interactively (hint: use ‘a’ to add attachments) or with a single command:

mutt -s "<id> challenge 1" -a hello.c -a Makefile little@eudyptula-challenge.org < <message>

where <message> is a file corresponding to the body or your email.

 

Journalog #3: eudyptula – challenge #1

Journalog #2: cryptopal

Little is dead. Probably. Whatever. My shitty mutt setup won’t have enough patience to wait for its reply, so I am moving on to another challenge.

But before, here is a quick pause to talk about setting up email clients: who cares??? Once upon a time, a few mistakes and years ago, I would find pretty awesome to have a decent mutt/alpine setup. Nowadays, this is pretty much useless, unless you also talk to other people with the same setup. For example, it is probably a paradise to use mutt to send emails to LKLM or to cool wizards like Eric Raymond or Richard Stallman, or even to the next g{uy,irl} replying to your comment on Hacker News. For now, I think Inbox is becoming more and more awesome. Disclaimer: this is not an ad, it’s just a personal recommendation from a guy that never lets its inbox have more than fifty unread emails (it all comes down to the whole debate between the oldieeee spam-fuck-off-from-my-mailbox and oh-your-email-is-super-relevant-cmon-lets-talk).

–> Cryptopals <–. Don’t expect me to duplicate information here, click in the link and see it by yourself. It’s basically a set of challenges about cryptography, in the same style of the eudyptula challenge. Theoretically, you don’t need any (prior) crypto experience to start with.

I would really like to learn Rust and to use that knowledge to solve these challenges, or alternatively Clojure and next-gen-Python. However, I don’t have much commitment to do this at the moment; I’d rather give it a shot with my wannabe C/C++ code.

If all goes well, then possibly a series of posts will follow with comments on each of the challenges. If not, then…what? Nobody will notice it anyway; everybody is busy out there trying to catch pokemon and/or watching Friends. Kinda reasonable, depending on your point of view.

So…here comes the nerdy stuff.

Journal

I should stop using the word journal. But here’s how I approached the challenge (you can do it in 5 minutes with your tricky Ruby/Python/Perl; you don’t need to read my poor adventures in C/C++. But it’s all about the experience; I’d rather spend one week in a single problem but get mostly everything out of it and document my thought process, rather than…(?)…blah):

Challenge 1, set 1: convert hex to base64. OK. Hex, not integer/ascii/char/byte. I struggled to get that. It’s actually kinda simple, but most converters you will find out there (including the base64 program available on OS X and on several linux distros) will assume your input is in ASCII.

So, no no no. Don’t you even dare to do a shitty system(“base64 <blablabla>”) call.

The first thing I did was to actually read how to convert from <blah> to base64. The process is really simple to understand (hint: Wikipedia), especially after you try it yourself with two or three examples. It does not really matter whether your input is in decimal/ASCII or hex; but hex is easier to manipulate.

Things that help:

  • bitwise operat{ors,ions} (especially <<, >> and &).
  • several helper functions (bonus: to do it in a functional language, it should be probably very elegant if it is well coded and idiomatic)

I decided to code and run everything within CRUX with vim and without any plugins, even my .vimrc file. Plain/vanilla stuff.

Here is the first working version of my code. Warning: coded after 1am. I am going to improve it until the weekend; more on that later.

….ooooops. Damn, I have a CRUX under VMWare. How do you expect me to copy the code to this blog? I don’t have a X server, I don’t want to install VMWare extensions, I don’t want to take a screenshot of the code (eeergh).

CURLLLLLLLL: https://clbin.com/

I will fix it before going to the second set. And that’s it for {the ,to}day.

Journalog #2: cryptopal

Journalog #1: eudyptula

I have no idea if it’s still alive, but I want to participate in the eudyptula challenge again. Last time I did it was probably a little less than 2 years ago, and I was still playing with with Arch at the time.

I am using OS X this month, which screws the whole thing from the beginning. I have to use a virtual machine then. VMWare Fusion is already installed in my system, so whatever. I have to grab a Linux box now. Heck…something very lightweight, no-frills. First thing that comes to mind: CRUX. Yeah, it’s you baby.

ISO file is ~400MB in size. I said lightweight, not small. Installation process is cool.

Screen Shot 2016-07-12 at 9.08.22 PM5 min or so and everything is properly set up. Bootloader, fstab…nothing fancy. CRUX uses LILO (I forgot about that!), but this is a simulated BIOS system anyway (in VMWare), so TO /dev/null, mister GRUB2! And you then reach a few seconds of enlightenment, away from the 21st century. systemd? Xorg? What’s that? OK, there are some btrfs packages laying around. Still!! What? The folks at without-systemd.org (no hyperlink. Go figure.) have a point.

Serendipity: it turns out some people really take this seriously.

All set, rebooting. Let’s work!! I am going to do everything as root, I don’t care. Screw. It’s 2016, virtual machines do have snapshots, bae.

I need to send one plain text (non-HTML) email to start the challenge. That’s all. So I need to grab mutt. I don’t care about sendmail, mail, fetchmail, whatever; so I will need a TUI to do basic stuff. Yah, I know, mutt will use sendmail behind-the-scenes, whatever.

This leads me to…package management. How to install mutt? Heck, no apt-get, yum, pacman. I chose CRUX, now I pay for that, right?? Not really. CRUX has a very basic ports/package management system, I’d compare it to OpenBSD. Hopefully, mutt is going to be present there. It is. So…1 or 2 min reading its handbook and it turns out all I need is

ports -u && prt-get install mutt

Cool. Now here comes the PITA stuff. I have to get a very basic ~/.muttrc. Well, it would be a PITA if we were in the 2000s, but no one cares about man pages anymore(1). Stack Overflow and hippie blogs are the way to go. So a quick Googling here and there leads me to a basic IMAP + SMTP mutt setup with my email provider.

…er, no. Grrrrrr. Mutt does not recognize smtp. Whaaat?! It turns out the default mutt from CRUX is not compiled with smtp enabled. You gotta be kidding me. Okay, let’s compile it from source with the correct flags. I would usually probably take 20+ minutes to figure this out, but I think after all these years playing with linux distros I learned something. It took me less than 3 minutes to go to /usr/ports/opt/mutt and edit the Pkgfile over there, then run pkgmk and finally pkgadd -u to install it. I didn’t have any prior knowledge of this stuff, it was mostly a matter of Cmd-F’ing the handbook webpage and introspecting (=a fancy word for trial-and-error) the command line.

OK, mutt is now installed. WITH SUPPORT FOR EVERYTHING I NEED, damn it. Now…let’s log in. Cool, it works. Actually…my email provider (Google, yaaay) tells me I am logging in from an insecure app, and thus it blocks my login attempt. Aaaaaaaa….ok, I like this feature! But I temporarily disable it (note to self: re-enable it later, you security freak creature!).

Test #1: hello world email sent back to myself. OK, my phone rings. In fact, twice. Leave me alone, I am migrating my apps, I have more than one email client installed on it. You never did that?! Well…everything’s working, so I just send an email to little@eudyptyla.

And this is supposed to be a happy ending. For today. Except that…maybe this challenge does not even exist anymore. I hope it does, I really want to do it. Time is key.

Screen Shot 2016-07-12 at 9.35.04 PM.png

Bye.

(1) man anymore: this is my first footnote. For more information, see anymore(8).

Journalog #1: eudyptula

Community Ethos

I don’t know how to name this post. These are a couple of resources I think every user that participates in online communities should know about — or, at least, become aware of:

Community Ethos