Skip to content

Instantly share code, notes, and snippets.

@rubenrubiob
rubenrubiob / gist:1e59a0f1a63b99aac92aa7b610b7c3d6
Created July 26, 2023 08:44
Iterate over a CSV and replace with sed with escaping values
#!/bin/bash
file_with_replaces="some-csv-file"
folder_to_look_into="folder/to/look/into"
filename_extension="*.txt"
while IFS=" | " read -r search_for replace_to
do
# From: https://stackoverflow.com/a/2705678
escaped_search_for=$(printf '%s\n' "$search_for" | sed -e 's/[\/&]/\\&/g')
@rubenrubiob
rubenrubiob / 24-days-in-december.md
Last active December 12, 2020 09:07
Collaboration for 24daysindecember.net

Code quality

Up to this day, PHP still has bad fame. When you are starting working professionally, that might give you a bit of impostor syndrome, because you think that you are not good enough to use a «good programming language» as other people you know. You think that you will become a good programmer once you are able to learn and work with a «professional programming language» such as Python, Java or Go, and stop playing around with toys for children like PHP.

However, as days, weeks, months and years pass by, step by step you are becoming more experienced —that is, if you have the right attitude, the appropriate gaze. One month, you start using a framework that ease your work. Another day you get a grasp on how good and helpful Composer is. Then you start worrying about testing, architecture, design patterns, code readability, SOLID practices...

I think it is sometime in that stage that you start to realize that good or bad code does not have much to do with the programming language or the tools y

@rubenrubiob
rubenrubiob / php-barcelona-2019-cfp.md
Last active December 17, 2019 17:36
Applying hexagonal architecture to a 10 year old monolith

Hexagonal architecture is a pattern of design that aims for a separation of concerns. It produces a decoupled system, where business rules are independent of the framework, UI or the database used.

There are two big benefits of using it. First, it is possible to test our business rules without the need of any UI, database or webserver. Second, it is possible to change any concrete implementation without affecting the core of our application, making framework updates easy.

In this talk, we will see the ongoing application of hexagonal architecture to

@rubenrubiob
rubenrubiob / django-serverpilot.md
Last active January 29, 2020 14:35
Guide to serve Django apps in a Serverpilot server

Configure Django project in a Serverpilot server

Install dependencies (as root)

  1. Install packages from repositories:

    # apt install python-pip python-MySQLdb python-dev libmysqlclient-dev supervisor
  2. Install virtualenv using pip: