Lineage of a Ruby Class

The other day I was writing some code in which I needed to know if a specific class was a descendant of another class. I've done a similar thing with Ruby objects in the past, but never with classes, and I think I'll start from there. If we want to know if a Ruby object's class is a descendant of the Vehicle class, we can simply ask it if it is a Vehicle [Read More]

Why do I stream?

Recently I started a Twitch channel where I've streaming different things, like learning or re-learning technologies. My intention for the channel is to provide some value by recording myself learning and/or programming. I don't have many views and followers so far. This is probably due to a couple of reasons: I haven't really cultivated an audience I'm really new to streaming I don't promote the channel enough I don't have a fixed schedule And, probably the biggest, I'm not a great entertainer. [Read More]

Moving my blog to Hugo

If you're one of the 8 people that's visited my blog since it's creation, you probably noticed that it has changed. That's because I'm using Hugo how. Hugo is a static site generator written in Go (language I've never used in my life). The main thin that drove me to try it out is that it allows writing posts and pages directly using org-mode (among other formats such as Markdown as well). [Read More]

Smarter rails server command

Some time ago I added the following line to my .zshrc (and .bashrc as well): alias rs='rails server -b' This gave me an easy to use and easy to remember way to start my rails server when working on a Ruby on Rails project. I have several of these two-word aliases spread across my configuration files and I love them. But recently I started working on a project that uses Foreman to run the server and several other niceties. [Read More]

Call a function interactively from another function in Emacs

The Silver surfer (ag) Linux tool is the fastest way to find where a word or phrase appears in the files on a directory. I've been using ag in two ways from inside Emacs. The ag-mode package, that asks me to input a search term and the root directory where I want it to search and then it performs the search. Via projectile, that allows me to search on a whole project without the extra step of inserting the root dir. [Read More]

Defining keybindings on the fly in Emacs

This is not a trick nor a hidden capability in Emacs, but it's something I never thought of using until about a mont ago. In our Emacs configuration, we can define keybindings either global (for use everywhere) or local (for use inside the current buffer) and we do it using global-set-key. I've mentioned this multiple times in this blog. Here's an example of how you'd use it (global-set-key (kbd "H-s") 'save-buffer) But I recently came to the realization that global-set-key is an interactive function, which means that you can invoke it as any command in Emacs, via M-x (or similar). [Read More]

Naming my macros in Emacs

I love using macros in Emacs, they help me speed up several tasks in a regular basis. Writing a macro is a relative easy thing to do and a topic for another article. What I want to talk about today is how and why you could name a macro. If you don't know what a macro is, the concept is simple, it's a sequence of actions that can be recorded and reused later. [Read More]

Splitting a Ruby Array in equal parts

I'm working on a personal project that involves calendars. One of the features I wanted was to be able to print a calendar like this: | Mon | Tue | Wed | Thu | Fri | Sat | Sun | |-----+-----+-----+-----+-----+-----+-----| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | 8 | 9 | 10 | 11 | 12 | 13 | 14 | | 15 | 16 | 17 | 18 | 19 | 20 | 21 | | 22 | 23 | 24 | 25 | 26 | 27 | 28 | For that I needed to split a 28-ish Array into 4 or 5 rows (weeks). [Read More]

Re-indent the entire buffer in Emacs

One of the tasks I leave entirely to my editor is indentation. I don't like at all to indent by hand, except for the current line, but once I have two lines out of place, I tell Emacs to handle it for me. For that reason I've written this simple command (defun fdx/reindent-buffer () "Indent the current buffer." (interactive) (delete-trailing-whitespace) (indent-region (point-min) (point-max)) (untabify (point-min) (point-max))) This will select the whole buffer and apply the correct indentation, cleaning white-spaces in the process. [Read More]


Today I was bored and my playful mind presented me with an idea I'm starting to use org-capture for lots of things, what if I create a capture entry for new capture entries? and that's what I did. It took me some time and didn't end up quite perfect, but good and useful enough. Assumptions We'll be using a plain type and use a non-org file as the target, so we are going to have to navigate and edit the file using elisp, and this assumes a specific structure. [Read More]