[Tip] Connect to multiple databases on the Fly with Lumen

Its not always an easy way to connect to different database if the configuration files does not include any information about it, in older version it was even a tricky one, especially if you have a bit of relationship that you want to use.

Don’t understand from my words that you cant do that, but it was not a direct use of setConnection , from my memory, the setConnection function used to force the connection on the current model only not the children nor any other one that it has a relationship with, when the info for this connection was not part of the database config file.

Things has changed and now in Lumen 5.5 (I didn’t try it with older version), as now you can use the function on to enforce the connection on the Model and any relationship it needs. like the following:

Create a base Model and create a function within called mergeConnections:

Continue reading

Filed under: Code, Laravel, PHP

This is why I can’t be a mentor

Not everyone can be a mentor or a teacher, some of us have this naturally, some don’t have it at all, am from those who don’t have it at all.

There are many reasons, why I can’t be a mentor, and why I can’t be a mentor, one of the main reasons is my temper, I can get angry fast, and most of the people will found my hard words as an insult to them as if I don’t appreciate the work they do or even the experience they have, so lets me tell you for example what I can’t understand nor able to work with.

1- If you are going to tell me that you are a developer, let’s say a Mac user who use Mac to develop iOS apps, I can’t accept from you that you don’t know how to use the terminal, or at least you don’t know the most common command line commands.

2- If you told me that you are a Laravel Developer, but you don’t know what is the Collections class, nor how to use or what functionality it has.

3- If you told me that you are a PHP developer, but you can’t setup Vagrant on your computer.

4- If you told me that you are an old Mac user, but you don’t know how to deal with the Terminal, nor how to solve permission denied error.

So yes, at this point, I’ll start to shout and start with the sentence are you a developer?

I can’t help it, if you are a developer, then you should respect this word, and try to be good at it. Most of those who called developers out there have earned this title by working hard on learning so you are not an exception.

Filed under: Other

Should we keep working 24/7

In the past few months, and the last year, everyone around me (and most of them from the EU/US) talked about how you should not be working 24/7 and that you should always take a break, have fun and enjoy the life after work.

I don’t blame them, I mean it’s not easy to work 24/7, it’s not easy to run after your dream all the time, or at least try to improve your life and the life of those around you all the time, it’s not easy and won’t be. But those forget something, forget that the lifestyle you have in the EU/US is not the same that everyone around the world is having, for example, a recent article was talking about the hourly rates for the freelancers around the world, and am not talking about the whole world, am just going to talk about the one in my region, they said that the average is about $60/h (based on a sample from 130 persons from one country, Lebanon) so yes they have generalized 381Mpeople (based on Wikipedia: The population of the MENA region at its least extent is estimated to be around 381 million people.) with only 130 person, so am pretty sure that this info is not correct, at least in my personal experience, in 10y of my work I didn’t reach that hourly price at all.

Continue reading

Filed under: Business, Personal

Taking IELTS exam for the second time

Information! I did a small update to correct the number of words required for the exam
A few months ago, I tried my luck and went to take my first IELTS exam, without too much preparation nor studying, and am not justifying my results by this as it’s not the case.

On last Saturday I went to take my second try, am not so optimistic about it, to be honest, as one of the most important section which pushed me to take it again is to enhance my English writing, and yes the writing test is the hardest part ever for me.

In the writing section, you will have 60min to write 400 sentences words, not any sentence, they will give you two tasks, one to write a letter (at least 150 sentences words), and the second task is to write about a topic (at least 250 sentences words), in this 60 min, you will not have much time to:

  1. Think too much about the topics
  2. Count what you have written, to make sure you reached the required amount of sentences.

Also, you will need to be careful about grammar, spellings and punctuation. It won’t be that easy (at least for me) especially that from what I have noticed the IELTS exam will mostly depend on the Old English not the  modern one, you will have to know a lot of words (and I don’t know much, as am comfortable with the Technical Terms more than the day today terms).

Am not so sure that I did a good exam, so am preparing myself to accept the fact that I’ll have to do it again if needed :D.

Filed under: Personal

How to run Kong servers with SystemD

Kong is one of my favourite projects, I do like it and keep pushing my current company and most of who I know to use it. So today I’ll talk about installing version 0.10.x and how to run it automatically via SystemD on Ubuntu 16.04.

Let’s talk about installing Kong, basically, we have two steps:

First, installing Kong (this taken from the docs):

This will install Kong correctly on your server successfully.

Continue reading

Filed under: Business, Code, Linux, Nginx