Programming Rambling

mrzard's ramblings in the wild

Becoming a Dadveloper

| Comments

So… this is awkward… It’s been almost two years without any new content on this blog. I will do something useful in this 4 hour flight from Helsinki to Barcelona, and I will try to write some things about what has been going on with me for those two years.

2015-2016 at Billy Mobile were intense and exciting years . I had the immense luck to start working with some amazing people like Diego Frisón, Joan Viladrosa, Roger Rafanell, Aday Robaina, Ivan Bruque, Davide Ferrari, Enric Sardina, Ginés Ortiz, Oriol Blanc, Marc Rubia, David Llorente, Sam Lissner, Jonatan Fernández or Alex Serra, as well as keep working with other great people like Oriol Orellana or Horacio Herrera, whom I have talked about in the past. And that is only counting people on the Tech Team at Billy. They are all top notch talent, and only great things are ahead of them.

With Joan’s leadership, the PHP-MySQL-Redis-ElasticSearch Billy adserver prototype was ported to Java-Kafka-HBase-Spark-Redis-HDFS which made a lot more sense as to deal with the concurrency and speed needed. He even introduced some very cool and cutting edge technology like Apache Kylin. At the same time all of these cool changes were happening, I started realizing that my daughter needed for me to devote more time to her. And I also started realizing that I needed to devote more time to her. The fine people at Billy Mobile tried to work out a semi-remote schedule with me, but it was not the best fit to have one of the Tech Leads away for a big part of the day, which shifted a lot of work onto Joan’s shoulders, and ended up making obvious that a change had to be made. So after having the luck of being contacted by DealDash, it was a golden opportunity for me and I decided to say goodbye to Billy. I will always be grateful for their support and effort to help me out, and for the chance to work and learn with so many amazing people.

DealDash offered me the opportunity to get back into a developer position and also start working remotely. The company is based in Helsinki, and the remote philosophy allows me to do these kinds of things:

  • Take a couple of hours off to bring Ada to the park, or dancing, or to the toy library. Then either wake up early and work before the daily meeting, or do it before going to bed at night.

  • Stop worrying about the added commute time to and from the office, specially if I also happened to have to bring Ada to the doctor’s. That used to mean almost a “lost” day when I was working in the office, now it’s just a minor adjustment and no work is lost.

  • When I sit to work I just check Slack and the GitHub issues to see what progress has been made so I can pick up like I were there when it happened.

  • If Ada’s mom needs to go to the doctor or run any errands, it’s a lot easier for her as she can just leave Ada with me. I just pick up smaller stuff or bring her to a cafe that has toys where she can play in a new environment while I keep working.

I think I break most of the ‘rules’ of working remotely, as other than fixed meetings (Grooming, Retrospectives, Sprint Planning, Daily standup), I tend to bend my hours to whichever happens that day. It’s working out for me, and at the same time I can see that it’s not for everyone. But there is a method to my chaos.

At DealDash I have found another amazing team and while I am still learning a lot about the business of penny auctions, we have already started on the path of improving and refactoring a lot of functionality. I have been with them for a little bit over 4 months now and I already have had the chance to try some new things (for me) like Docker, provisioning machines with Salt, some NodeJS, using Gherkin to describe the behavior of functionalities and couple that with unit and/or functional tests and also pick up Symfony again.

DealDash is also teaching me a great deal on how to make a remote team work, how to keep your team in touch with your users’ needs and how to encourage and foster an open communication style where everyone knows their voices matter.

So what more can I ask for? I am working with once again on an amazing team, on interesting problems, I am learning new stuff AND I have all the time I need to devote to my daughter: right now I am heading back to Barcelona from the first team offsite with DealDash, which I had to cut short because Ada had an accident. And they were again supportive and understanding.

So this is my new life. I have become a dadveloper.

And I could not be happier.

ElasticSearch: Enable Mlockall in CentOS 7

| Comments

I have recently been wrestling with ElasticSearch/Elastic and how to finally enable mlockall under CentOS 7. You usually will get the “Unable to lock JVM memory (ENOMEM). This can result in part of the JVM being swapped out. Increase RLIMIT_MEMLOCK (ulimit)`.”

These are all the places I made changes to get it to work. Now, I don’t know if some of these steps are skippable (my guess is some of them are), but I got it working i nthe end, and my nodes are now happily showing `mlockall: true“

  • Make sure bootstrap.mlockall: true is uncommented in /etc/elasticsearch/elasticsearch.yml or the appropiate config file for your configuration.

  • Edit /etc/security/limits.conf and add these lines (or edit them if applicable). You usually will want to add them at the very end of the file.

1
2
3
elasticsearch - nofile 65535
elasticsearch - memlock unlimited
root - memlock unlimited
  • Edit /etc/sysconfig/elasticsearch. You will find these values commented, and possibly without values. Change them to these:
1
2
3
4
5
6
7
8
9
# ES_HEAP_SIZE; 30g for my nodes - look up a good value for yours
ES_HEAP_SIZE=30g

MAX_OPEN_FILES=65535
MAX_LOCKED_MEMORY=unlimited
...
# WORK_DIR: Make sure /tmp is not mounted as
# noexec OR put a regular directory here
WORK_DIR=/tmp/elasticsearch
  • Edit /usr/lib/systemd/system/elasticsearch.service and make sure LimitMEMLOCK is uncommented and set to infinity
1
2
3
4
# See MAX_LOCKED_MEMORY in sysconfig, use "infinity"
# when MAX_LOCKED_MEMORY=unlimited
# and using bootstrap.mlockall: true
LimitMEMLOCK=infinity
  • Edit /etc/init.d/elasticsearch and add su $ES_USER --shell /bin/bash -c "ulimit -l unlimited" before the actual start of ES, this is more or less how it looks in mine:
1
2
3
4
echo -n $"Starting $prog: "
# if not running, start it up here, usually something like "daemon $exec"
su $ES_USER --shell /bin/bash -c "ulimit -l unlimited"
daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR

After I had everything in place, I restared my nodes and now they all show mlockall: true when checked with curl http://localhost:9200/_nodes/process?pretty

Hope this helps someone!

Farewell 2014, Welcome 2015

| Comments

So we are closing another year… And I see this is just my fourth post of the year. Pretty bad, but at least is a good starting point, because it’s easy to improve on it.

This will be a long post, so let’s stop it here, and you can proceed to the full wall of text if you feel like it :)

2014 has been a ver eventful year for me. I started the year as the CTO of ChicPlace.com. I had already been there from October 2012, building a custom e-commerce platform over PrestaShop as a prototype. The idea worked pretty well, so, with the help of Denys Pasishnyi and Aldo Chiecchia, we set our sights into building a ‘real’ app in 2013. We started looking for someone dynamic who would help us deliver a full Symfony2 e-commerce website in little to no time. After some search we found Marc Morera and enlisted him. We worked our asses off (Aldo, Denys, Marc, Nadal Soler and myself) and we put out a complete solution in August 2013. From then on we tried to build the business and keep improving.

In 2014, ChicPlace was facing interesting challenges (growth, opening a branch in Latin America…), but we had already lost Marc due to budget cuts (luckily he stayed close, in the incubator) and I was growing tired of the non-technical dynamics in ChicPlace, so I in April I came to the conclusion that I had to move forward and wish my pals at ChicPlace good luck. Before I left, though, I was fortunate enough to be around for the birth of ElCodi which came into beign by giving steroids and improving a lot over the idea I had of building an e-commerce web app for the incubator. Marc took the idea to the next level by envisioning an e-commerce components system that is being built now, and not only for the incubator, but for everyone. ElCodi is OSS, and always happy to welcome contributors, so if you have the time, go take a look and help some very nice people out!

As I said, in April I announced that I would be leaving ChicPlace on May 30th, and started weighing my options. Came to the conclusion that there are some very nice projects out there. I had some interviews with SkyScanner, Schibsted and Adsmurai. Adsmurai is a very interesting project with an awesome team behind and I really wanted to be a part of it, but there were some personal issues I could not resolve and had to recommend them a great programmer (Jordi Creus) and keep looking myself. I am happy to say that Jordi is still with Adsmurai and it looks like they are growing very quickly! SkyScanner had a very long selection process, and while I made close to 10 hours of technical tests with them, and a Skype interview, they were still trying to piece the team together and took more than a month to give me feedback. I guess they were trying to make sure they were getting the right people, but the process became too long for me, for reasons I will detail now.

I was still in the processes with Schibsted and SkyScanner when I landed an interview with Billy Mobile through ex-teammate and Frontend Developer Horacio Herrera. I had a very nice chat with Alejandro Scandroli, Jordi Tamargo and Gemma Llobet and they made an offer that was very much aligned with what I was looking for both in a business and personally. So, with some doubts in my head about the ‘lost’ opportunities with Schibsted and SkyScanner, both established and strong companies, I took the MVAS IT Manager spot at Billy, yet another startup in my resume (since 2008 I’ve almost exclusively worked for startups, except for consulting and training).

At first, Billy was just what I expected. We were shooting from the hip, pushing code to the live servers like maniacs and generally doing tons of work to keep a working business model working. But as the weeks went by, we started to refine ourselves. We introduced the use of composer, some process that resembles a deployment tool, we started using the Symfony components, made a development VM ready with Vagrant, started using ElasticSearch and Symfony2 for some of the projects, started using Redis beyond GET / SET… So basically, while the core business in Billy was (and should be) technically easier than the challenges I had at ChicPlace, we were starting to make it look like a decent technical challenge too. So in this vein, in August we started looking for a developer to join me, as the amount of work surpassed the hours I could put in. The search was very difficult, and made me realize that there are a LOT of outdated developers out there. One thing is not knowing something, but to me, it’s very important that you know that you don’t know it. Let me explain it better. If I am looking for a junior developer, I don’t give a rat’s ass that you cannot explain to me Factory pattern. That’s in a book, you can go look at it anytime you need it. But it’s VERY important that you know it exists, and that you know that you can go look at it anytime you need it. Basically, I need you to be able to find an answer to my questions with 5 minutes and access to Google and StackOverflow. You won’t be able to do that if you do not know what you do not know.

I interviewed people with 4, 5, 6 years of experience that had no idea what Dependency Injection was. They had never used any of the ‘new features’ - I put that in quotes as some of these features are more than some years old - of PHP (no namespaces, no closures, no traits), they had never TRIED to use composer. But after a lot of searching we found Oriol Orellana, a senior developer who had a very good background and was a very good fit for us. We were lucky that he was open to join Billy and he has been with use since November. Oriol has brought with him a lot of order and process to the chaos put in place by beign in a one-man band. And I really hope we can build on that to keep making our technical processes and outputs better, and hopefully keep growing the team.

So, in the professional side, that brings us to December! It has been a very very good year for me professionally. There have been ups and lows, but I am very happy that I have the opportunity to keep working with awesome people and interesting problems.

On the personal side, it’s been pretty eventful too! Not only changing jobs, but I started 2014 with a very BIG news headline: My girlfriend was pregnant! She had a very nice pregnancy and delivered a healthy, beautiful and smiling baby girl on September 21st. Her name is Ada, and all the sleepless nights, the smelly diapers… are more than worth it. My girlfriend and I like challenges so, when Ada was about 5 weeks old we went to Sabadell to check a flat to rent… And we loved it. So my girlfriend organized the moving of a complete family by herself while I kept working and since December 1st we are living in Sabadell.

All in all, as always I have to be grateful to all of the awesome people I keep finding in my path. I am very fortunate to have the family I have, to be in the industry I am in and to have had the opportunities I have had. I hope 2015 is at least as awesome as 2014. And also hope I will be putting some more content here too!

Billy Is Hiring! Middleweight PHP Developer Needed

| Comments

As most of you know, since June 2nd I’ve taken the position of MVAS IT Manager at Billy Mobile.

Well, the family is growing, and I need a pair of hands on my side.

Right now we are using some Symfony components (HttpFoundation, DependencyInjection, Configuration, Router, EventDispatcher, Console and Templating) and we are creating a lot of libraries for our own use which we control with Composer / Satis. We also are going to possibly include node.js in some of our apps.

Your job will be connecting our apps with 3rd party APIs, creating new libraries that connect us to different services, thinking of how to improve our metrics and having fun while doing so. We have three different areas were you can make impact (mobile web apps, a very custom adserver and a REST-ish API for native mobile apps).

We are looking for:

  • A fun person to be around

  • All-around nice person

  • Middleweight PHP developer. You have some experience, but want to improve and / or take on new challenges. Or maybe you have a ton of experience, and you like this job posting!

  • Comfortable with MySQL (queries, indexes, joins…)

  • Comfortable with the Mediator pattern and design patterns in general

  • Comfortable with git and composer

  • Understands Dependency Injection

  • Can document code, or writes code so beautiful it’s auto-commented (if this is you please teach me).

  • Maybe has a bit (or a lot) of experience with testing.

  • Maybe has experience with key-value stores (Redis, Memcached or other), and NoSQL solutions (MongoDB, CouchDB, ElasticSearch or other…)

  • Strong english skills required - this a must, as we are an international company that need to communicate clearly in English with both coworkers and partners.

We are offering:

  • Good salary and company perks

  • An environment were prototyping, putting your ideas out there and trying new stuff is encouraged

  • Lots of growth opportunities

  • The chance to impact a working business model

  • Working with yours truly which is AWESOME

  • Free coffee and soft drinks

  • Great coworkers

Do you think you want this job? Then drop me an email at my name at billymob.com or apply on LinkedIn.

What I Have Learnt as a CTO

| Comments

When May comes to and end, I will end my one and a half years journey as a CTO for ChicPlace.com.

The reasons for my depature are diverse, and possibly this is not the best place to discuss them, but I am very grateful for the opportunity to grow and learn while developing a project that has the potential to be something special.

During this time I have gained a lot of experience managing teams, and learnt a lot about myself, specially when it comes to working with non-technical people, and how to manage expectations, deadlines and organisation when working in a very fast-paced and very improvisational startup.

I will write a list of things that I have learnt, in the form of:

  • List item.
    • How it has affected me personally.

Customize Form Prototype for Collections in Symfony2

| Comments

When working with complex forms, sometimes you will be in need of creating a collection field type to manage relations. When this is the case, you may find yourself in the need of tweaking how the ‘add’ form shows.

It’s pretty simple. In twig the protoype can be found under form.collection.vars.prototype and can be used as a regular form (i.e. if your form.collection member form has a ‘name’, it will also be available in form.collection.vars.protoype.name).

With this information now you can create a twig that recieves an ‘item’, which can be either a form.collection member or a prototype, and it will be rendered the same.

Finally, wherever you hold the collection html, you will have to output something like this:

1
data-prototype="{% filter escape %}{% include 'prototype.twig' with { 'item': form.collection.vars.prototype } %}{% endfilter %}"

And your prototype.twig should look like

1
2
3
{{ form_row(item.field0) }}
  {{ form_row(item.field1) }}
  {{ form_row(item.field2) }}

This way, you will have access to the prototype as if it were a regular form, and you can apply all the customization you want (you can user form_widget and the other functions, or access the vars directly, etc…)

Creating the helper twig is optional though, but handy because you have to use the escape filter to the twig so you can put it in the correct data-attribute.

Fluhsing Only Desired Entities With Doctrine

| Comments

Sometimes, you may be working with several entities at the same time. If this entities are managed by Doctrine, you may find yourself in the situation where you want to flush only some of them. If you want to do so, you can pass an array of entities to the flush(), so it only affects the entities you explicitly pass to the function.

This is very useful to avoid side-effects in some instances.

Loading Cross-domain Fonts From Firefox

| Comments

When requiring a font from an external CSS file (assets domain, CDN, etc), you may see that Firefox refuses to display the font. This is because Firefox, by default, disables cross-domain fonts. To solve this you have to add a header to the response with the font file. The header is Access-Control-Allow-Origin: *

In a typical nginx setup, this is achieved with this snippet:

nginx add header

nginx add header
1
2
3
location ~* \.(eot|ttf|woff)$ {
  add_header Access-Control-Allow-Origin *;
}   

Once you have that in place, the fonts will be loaded correctly from Firefox.

My Experience With Paymill

| Comments

I have been using Paymill at work for some time now, and this is what I think of it thus far:

PROS:

  • Easy to implement. As in dumb-proof easy.
  • Commission (2.95% + 0.28€) is reasonable against time of implementation.
  • No other fees. No setup fee, no base usage fee, nothing, only their commission.
  • They only charge for successful transactions.
  • Pays every 7 days, directly to your bank account.
  • Removes lots of man-hours in payment-gateway related stuff.
  • Removes the need to be PCI-compliant.
  • They have libraries for lots of languages and software packages.

CONS:

  • Test mode and live mode do not behave the same in some instances.
    • Have not checked recently, but at a point the test mode worked with a deprecated parameter that resulted in an error if used in live mode.
    • As of now, the amount sent to the bridge and the backend do NOT have to match in test mode for a successful transaction
  • Error messages are not that clear, although they have improved in that area.
    • 40000 RESPONSE_DATA: general problem with data or 40100 RESPONSE_DATA_CARD: problem with creditcard data are not very telling. I got a 40100 for a client who did not have 3D-Secure enabled.
  • Sometimes they take a long time to answer to support tickets.

BOTTOMLINE:

Paymill is a great tool and I recommend it if you need a payment gateway FAST and cannot / do not want to spend time going PCI-compliant. Only thing that worries me is the discrepancy in behaviour between test mode and live mode which makes it necessary to run some ‘live’ tests that would not be necessary otherwise. Anyway, once you have detected these little things you can work around them with your own tests and assertions.

MrZarD, Now on Octopress on GitHub Pages

| Comments

Due to Posterous closing soon I had to look for another place to host my (seldomly updated) blog. After 10 minutes, I saw GitHub Pages and then saw Octopress. The combination of both is awesome and really feels great for a developer instead of a classic web interface.

So, now you can find me here, at GitHub. Same content, same guy, same few updates!