A better and prettier mysql/mariadb CLI client

The default, unconfigured CLI client you use with MySQl or MariaDB is kind of awful, no colors, pretty bad query editing capabilities, and the output is not paginated. Let’s improve the experience.

Client

Start by creating a configuration file ~/.my.cnf with the following content.

Automatically prompt a password for your user to avoid the --user option each time

Continue Reading →

Vim Kōans

Esta es la traducción al español del artículo “vim kōans” por Tom Ryder.

¿Qué es un Kōan?

El maestro Wq y el desarrollador de Windows

El maestro Wq se encontraba ayudado a algunos principiantes de Vim. Luego de sus enseñanzas sobre las virtudes de Vim, atendió preguntas de sus estudiantes. Un hombre joven levantó la mano.

Continue Reading →

The Python Paradox is backwards

Back in 2004, Paul Graham wrote a great short article called “The Python Paradox”, in which he basically states that: if you look for python programmers you will end up with the best, smartest programmers in general. The logic behind this is as follows:

Python is an esoteric language that universities and schools don’t teach, so people that know python are self thought, they know that their python skills wouldn’t get them a better job, and they do it because they just care enough; Considering that learning a new programming language isn’t necessarily a trivial task, and that python knowledge wouldn’t rank you higher for hiring, we can infer that it takes a truly passionate person, a hacker, to learn and use python.

It was conceived 12 years ago, but now almost every single school and university not only teaches python, but use it as the primary language, oftentimes as the only language!. Nowadays even some non-technical schools teach programming as a way of introducing their students to computing and logical thinking, which is good, but they all use python precisely because of its simplicity; They even tend to over simplify an already simple language so that their less clever students can catch it with ease.

Continue Reading →

Why I dislike Java

Everything is an object

No, not everything is an object. Java code is riddled with actions disguised as objects: Mutator, Traverser, Factory, Maker, Creator, Generator, Mediator. So you don’t mutate, traverse, make, create or generate anything in a straight forward way, instead you force into existence an object that can perform the required action. This is one of the primary sources of clumsiness and messiness in Java, it causes astonishment and improper behaviors that you are forced to get used to.

A reasonable language has OOP as a feature, to instead force it everywhere makes everything unnecessarily convoluted. As Steve Yegge puts it in his article: Execution in kingdom of nouns, verbs should not be second class citizens.

Continue Reading →

Why I dislike IDEs

Let’s start by taking off the discussion some important points:

  • Using an IDE and taking advantage of what it has to offer doesn’t mean you’re a bad programmer, and using a good text editor doesn’t mean you’re a good one.
  • I believe that relaying too much upon an IDE can potentially make you a bad programmer.
  • I believe that inescapably depending on an IDE means you’re probably a bad programmer.
Continue Reading →

Beautify your code with Astyle and Vim

Good code is about many things: good expressivity, good organization, ease of extensibility, maintainability, readability and so on. But we also prefer the code to be pretty, it makes it pleasant and overall more enjoyable to work with, though is not only for the sake of making it visually appealing. Working with style-consistent code makes it easier to navigate and read, our brains can dissect it with less overhead and our eyes can quickly jump to the right place. Pretty code also conveys that the people who wrote it actually care.

Some things to take care of are:

  • Tabs vs Spaces
  • Maximum line length
  • Indent style
  • Number of spaces per indentation level
  • Trailing white space
  • Blank lines at the end of the file
  • Inconsistent number of blink lines between code blocks
  • Blank space between function arguments
  • Space padding around operators
  • Use and position of brackets
  • Blank space between various syntactic characters
Continue Reading →

Cómo escribir un emulador de computadora

Esta es la traducción al español del artículo “Cómo escribir un emulador de computadora” por Marat Fayzullin

Escribí este documento luego de recibir varios correos electrónicos de personas a las que les gustaría escribir un emulador de una u otra computadora, pero que no saben por donde empezar. Las opiniones y consejos contenidos en este artículo son únicamente mios y no deberían ser tomados como verdad absoluta. El documento trata principalmente sobre los llamados emuladores “interpretes”, contrario a los “compiladores”, pues no tengo mucha experiencia con técnicas de recompilación. Se proporcionan un par de enlences donde se puede encontrar información sobre estas técnicas.

Si considera que hace falta algo en este documento, o desea hacer una corrección, siéntase libre de enviarme un email con sus comentarios. Sin embargo, NO respondo a solicitudes de imágenes ROM. Si conoce enlaces que pudiesen ser útiles aquí, avíseme, lo mismo aplica para preguntas frecuentes que no se encuentran en el documento.

Continue Reading →

Migrating GNU/Linux installation to an SSD

When your new SSD arrives you’re probably very exited and want to boost your system’s speed, but don’t quite feel like reinstalling your whole system on it, so let’s migrate it instead.

Note: I use Gentoo, but this is perfectly applicable to every distribution.

My current HDD partitioning scheme is like this:

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1            2048   2099199   2097152     1G 83 Swap
/dev/sda2  *      2099200 148899839 146800640    70G 83 Linux
/dev/sda3       148899840 358615039 209715200   100G 83 Linux
/dev/sda4       358615040 976773167 618158128 294.8G 83 Linux
Continue Reading →

Fight Flash Fraud (F3) - Auto-reset hardware

F3 is an amazing alternative to h2testw, that allows you to test a USB flash drive to find out if it has less capacity than it claims.

There are a lot of fake USB flash drives on Ebay and other stores. When you use them, they appear to be storing all your data, but when you try to retrieve it, much of it is just gone.

f3probe is part of F3, it will test the USB flash drive for you and tell you if it’s a fake and how much real memory does it have, but there’s a catch: it requires you to physically disconnect and reconnect the drive manually, which slows down the whole process and becomes tedious if you need to probe more than one drive. Here is the solution: a hardware that f3probe will use to automatically connect and reconnect you USB drive without human intervention.

Continue Reading →

Ratpoison, Task Warrior Control

This is the fourth post about the Ratpoison window manager.

When managing tasks there is no better interface than task warrior’s CLI, that’s for sure, but sometimes having a few-strokes-interface for listing the current tasks or adding a new simple one comes in handy.

Let’s use Ratpoison goodies for this.

Continue Reading →

Ratpoison, E.T. Phone home

This is the third post about the Ratpoison window manager.

This one is not about productivity improvement, nor a do-more-with-less feature, but a playful way to achieve a pretty common task: SSH to my home lab.

Remember that scene from E.T., “ET phone home”? Well… When I hit C-t E this pops up in my screen:

Continue Reading →

Ratpoison, Clipboard Stack

This is the second post about the Ratpoison window manager.

How many times have you found your self keeping snippets of text in a text editor just so you can use them later because your clipboard will be overwritten with a new selection?

Here is a neat solution using Ratpoison: a clipboard stack.

Using xclip, a simple shell script and the appropriate Ratpoison key bindings we can accomplish the following:

Continue Reading →

Ratpoison, Music Control

This is the first of a series of posts about the Ratpoison window manager.

Ratpoison’s ability to bind custom keys and run external scripts affords us some pretty neat flexibility. Let’s start with music and go further in future posts.

Some people use a graphical music players like Amarok or just play some Youtube videos, others prefer text players like MOC or CMUS, but we can reach the apex of flexibility by using a music daemon like MPD. Although you can reach out for a client like MPC, Ncmpcpp or Vimpc, you still need to interact with its interface, and that means briefly interrupting your workflow to control your music. We can do better.

Continue Reading →

Vim vs AWK

Vim is a text editor and Awk a text processing language, I wouldn’t blame you for believing that trying to compare them is bonkers, but trust me, I have something to compare here.

Case study: Vinfo

Vinfo is a Vim plugin that allows you to read Info documentation files right in a vim session by converting Info plain text files into Vim help-files, so you get nice syntax highlighting and convenient tags for jumping between the file contents. Let’s examine how it does its job.

Continue Reading →