Pairing over Tmux

Tmux is an awesome tool. One of its greatest uses is that is allows us to pair if you share the session. Anyway the setup is always a little bit complicated if you want to do it really right. Let’s see what we can do.

Read More

My toolbelt in August 2014

I have a decided to publish from time to time my current toolset. I'm
trying to honor my tools and spend some time polishing the tools I use
more often and I'll keel this blog posts as a place to keep some
random thoughts about this.

Read More

Adding a simple save and reload in emacs

I'm starting to like emacs. It's really simple to extend it with new commands.

One simple use case is to save a file and reload the browser. It is very useful when editing a web page or some source for a web application. I've done this for Chrome but it will for sure be easy to adapt this solution for emacs.

First of all install chrome-cli. This allows us to control chrome from the command line. Then, the rest is just piece of cake. In your .emacs file you can add the following code:

This will add a save_and_reload command that you can try with M-x save-and-reload.

I also added a keybinding with the following

So I can save and reload with C-x C-r. Awesome.

Happy coding!

Ack, searching in source code

Ack is a command line tool specialized in searching into source code. I've giving it a look this days since I'm switching to emacs and I need to polish some of the tools I'm using. Since I'm pretty happy with this, I wanted to share a small post to show how the tool works.

For basic usage you can just type from your shell:

and it will browse all clojure code starting your current folder looking for the text core. It supports a lot of languages also such as Ruby or Python.

The first thing I'm surprised with is how awesomely fast it is. It is blazingly fast, to be honest.

There are of course plugins for vim and emacs. I'm using this plugin for emacs.

If you do clojurescript you'll see that by default only .clj files are traversed while
searching. You can edit your ~/.ackrc and add the following line to support cljs

You can also exclude programming languages when searching

Another common problem you might face is that often we have folders where we don't want to search. In my case, leiningen generates some clojurescript files in target folder.

To avoid this we can again use ~/.ackrc

Lastly, I dare you to run

Have fun!

Happy new programming year

Another year passes by and we are back again with the same old ceremony of new year's resolutions. But first of all a little bit of retrospective.

Retro

Last year was quite awesome given the fact that I was parent for the second time and my spare time was dramatically reduced. Madrid Software Craftsmanship is doing awesome and there are more people there each day. I'm very happy to share some time with some awesome developers that show up there. Also this year I spent some time teaching at Ironhack bootcamp. That was an awesome experience that I will repeat if I'm given the chance to. Also I coded a lot, paired a lot and improved a lot. Not bad.

I failed also at some last year's resolutions. I did not manage to get a product launched due to several reasons. I'll carry on that resolution for the next year. Anyway I'll rephrase that. I'll try to get the first customer for a product I've built. That's better πŸ˜‰

New year's resolutions

For next year I'd like to improve the following areas:

Ship it!

As I told before, I'd like to get some product out there. I've started coding something but it's far from professional. Also I have some toys working out there but those are not what I meant with product. That's why I'll rephrase to getting my first paid customer for a product. That's the bar I'm aiming for.

Coding

On this year I expect to write some more Clojure. I'm getting deeply interested by its concept of simplicity. It's getting some traction right now and its not hard to see why. Anyway I'm far to be proficient in the language right now. That's why I'll try to write some pet projects on it. Also this year I'll try to go to some Clojure conference in Europe. I'll consider this done if I can write a reasonably complex application with this.

Also I'd like to get some knowledge in machine learning and data visualization. Anyway, I find very hard to get the time to get some more skill on those. They look too demanding for me this time. I'll consider this done if I manage to have a pet project that uses some of this skills.

I'll also try to keep Software Craftsmanship Madrid open for next year. Last year we've managed to make 11 meetings so I expect more for next year.

Graphic design

I'll be attending to some courses on typography this year. I'm slowly developing some taste on this but, since this always such a low priority thing it is a shame that I can't invest enough time to learn some more. I'll consider this done only by reading 3 books on the subject.

The blog

If I manage to keep it open for another year I'll be more than happy πŸ˜› Anyway I'll aim for 12 posts a year with enough quality (not like this one). Bonus points for improving a little bit the awful visuals and get a building pipeline at last.

Tools

I've recently switched to sublime text from vim. I'm starting to feel happy with it. I'll try to stick with it for a year and see if I get proficient enough with it. I'll try to write a plugin to improve my workflow during this year.

Also I switched to Evernote to keep my things a little bit organized and I'm also happy with it. I'll try to improve my organizational skills by having all the things for a project in a single, internet accessible place.

Family

Last but not least I need to spend more time with my children. The more time passes the best they are.

Well... this may not look too ambitious for a full year but I'll do my best to stick with it. Wish me good luck!

My week at Ironhack

I had the immense luck of being a teacher this week on Ironhack. It was the first time I was going to teach a group of people so I was scared to death. My job was to teach some Ruby basics to a group of people with some experience on programming that had no knowledge of Ruby at all. In just four days they managed to write their own unit tests, do some TDD, apply SOLID principles and pair program a lot.

I was thinking on writing a blog post before the course ended but I couldn't. Each day was more intense that the previous one. Each day we wanted more than the day before. It was exhausting. Anyway each day was more rewarding than the previous one.

The people there are A-WE-SOME. There are 12 amazing guys/girl in the class that pour each drop of blood they have in order to learn as much as they can to reach the goal of building amazing software. They were truly inspiring to me. They are smart, proactive and passionate. I'll be back to work on Monday and I'll tell to the team I work with about the bunch of amazing people I met.

I'm sure that these guys will make something remarkable and I'll be there to say: "I was there while they were still starting".

Memories of mendicant university

This week I'll be teaching an introduction to Ruby at Ironhack. This brought some memories back to me...

For me it is being really hard even though this has not started yet. This is the first time I act as an "official" teacher to a group of people so I want to make an impact in the 4 days I'll be with them.

This makes me remember the times when I started learning Ruby. I had the luck of joining Ruby mendicant university while it was still open. I can't express how grateful I am to Tobias Pfeiffer for all the time he spent reviewing my code and telling me that I had to stop writing Ruby code the same way I wrote Java.

Now, one year after the shut down of Mendicant University, I still feel identified with their values and still try to honor the status of alumni of what once was an awesome place to learn how to write awesome code.

I want to bring some of the values I acquired there to the Ironhack students. Passion, honesty, humility... When I think of Gregory Brown, Andrea Singh or Jordan Byron I see the living examples of what I want to be to the guys at the course. If I can change their lives half as these guys changed mine my mission will be accomplished.

Just wish me good luck. I'll try to honor the memories of the mendicant university.

Map and reduce methods in Ruby

There are two methods in Ruby's Enumerable module that often people coming
from an object oriented background find confusing but are indeed very
useful: .map and .reduce.

They both are constructions taken from functional programming so they
both take a block as a parameter.

There are also .collect and .inject aliases for them. They are there
only to use whatever one the domain you are working thinks is best.

.map / .collect

Map takes a function and returns the array that has in each position
the result of applying that function to the corresponding element of the
original array.

map.png

This is a highly practical method. Imagine that, for example, you have
an array of people and you want to get an array of the names. It is
as easy as:

.reduce / .inject

Reduce is similar to map but instead of receiving a function that takes
only one parameter it receives a function that receives an accumulator and
the value. Instead of returning an array it just returns the accumulator.
We can say that this method reduces the array to a single value.

reduce.png

Imagine now that with our array of people we want to get the total number
of letters that all the names have. We can do:

Differences between symbols and strings in Ruby

You can think of a symbol as an immutable string. Since it can't change each time you ask for a symbol using :name syntax the ruby interpreter will return the same instance of the symbol.

First al all let's prove that.

As you can see each time we write: "Yay", we are getting a different
object. Although they contain the same characters and they are equal
they are different objects

But in the case of symbols

Also, strings can be changed

But symbols can't

This causes symbols to be often used as keys to hashes or to
be used as a substitute for enumerated types.

Bonus points:

You can freeze a string and cause it to be immutable with freeze method

You can also define 'constants'. Ruby compiler will consider any variable that is declared uppercased as a constant. It will raise a warning in case you change it. Anyway it will allow you to do so: