I'm Nahuel, and these are my work experiences, ideas and thoughts as a web developer working on the eCommerce industry.

Configure the Terminal to use MAMP's PHP

Configure the Terminal to use MAMP's PHP

By default, after installation, MAMP will make its PHP binaries "available on the browser" while the Terminal will keep on using the system's PHP with its own configuration.

The idea behind changing the Command-line to start using the PHP coming with MAMP and its configuration is to be able to switch rapidly between PHP versions and to have the configuration for PHP in only one place.

Out there you can find enough guides that helps you archive this because, frankly, there are plenty of methods to get this done. This next one is how I personally do it because it's easy to implement and it also covers something most of other guides won't which is configure the Terminal to also use the same php.ini MAMP uses.

Configuring the Command-line to use MAMP's PHP

You need to edit your Terminal's Profile in order to add the following to the end:

#export PATH=/Applications/MAMP/bin/php/php7.1.33/bin:$PATH
#export PATH=/Applications/MAMP/bin/php/php7.2.33/bin:$PATH
export PATH=/Applications/MAMP/bin/php/php7.3.21/bin:$PATH
#export PATH=/Applications/MAMP/bin/php/php7.4.9/bin:$PATH

As you can see I'm adding a different line per PHP version I want to potentially have available on the Command-line (PHP 7.1.33, PHP 7.2.33, etcetera) but having them all but one (PHP 7.3.21) commented with the # at the beginning.

Every time you switch the PHP version in MAMP you should come back to the Profile and leave uncomment the same version so the Terminal and MAMP match.

Your Command-line's Profile file depends on your shell. If you are using the default Terminal coming with macOS chances are the Profile will either be ~/.bash_profile or ~/.bashrc. Mines it's ~/.zshrc because I use Oh My Zsh.

Remember that everytime you change your Profile you need to "reload" it by doing source ~/.bash_profile (or whatever file you are using).

You can check if everything was applied as expected by executing php --ini and seeing the paths are pointing to MAMP.

Configuring the Command-line to use MAMP's php.ini

Here's something interesting about MAMP Pro: it generates, each time it starts, the final php.ini file it will be using during the execution as its content depends on the settings configured on the software’s UI.

For example, if you enable/disable Xdebug on MAMP by ticking/unticking the checkbox on the app, MAMP will regenerate the php.ini file with your configuration (this is basically how MAMP applies any setting change that you perform from the UI).

The final generated php.ini file is located at /Library/Application Support/appsolute/MAMP PRO/conf/php.ini.

We already configured the Terminal to use MAMP's PHP binaries but we also need to configure it to use the generated php.ini by going to /Applications/MAMP/bin/php/php7.3.21/conf (where the not auto generate php.ini file is located) and delete it (after a back up).

Then we need to create a symlink called php.ini for /Library/Application Support/appsolute/MAMP PRO/conf/php.ini (which is the auto generated one by MAMP) by doing:

ln -sf /Library/Application\ Support/appsolute/MAMP\ PRO/conf/php.ini php.ini

The conf folder should ended up looking like this:

Of course the example is for PHP 7.3.21 but you will need to repeat this for the folder of each PHP version you will be using on the Command-line.

This only applies to MAMP Pro as the non-Pro version doesn't generates any php.ini and if you want to change something you need to edit the original file yourself.

Lazyload post Feature Image from Unsplash in Ghost

Lazyload post Feature Image from Unsplash in Ghost

Unsplash is a great Ghost built-in integration that allows you to quickly add an image to your posts, and I personally use it every time to add the Feature Image to all my articles (the big one below the title, before the content).

Unfortunately, out of the box the image from Unsplash is really big (2000px wide) and impacts on the page speed of the site since the browser will download the image first then continue with the rest of the page.

There's no much we can do about the image size as we can't follow the "How to use responsive images in Ghost themes" official guide because that only applies to images you manually upload and not those coming from third-parties...

Dynamic image sizes are not compatible with externally hosted images. If you insert images from Unsplash or you store your image files on a third party storage adapter then the image url returned will be determined by the external source.

...but with a little bit of HTML and JavaScript we can lazy load them to prioritize the content over the image download.

Usually, the Feature Image in the Ghost theme will look something like:

<img src="{{feature_image}}" />

This is a classic img tag with the src containing the URL of the image. But we need to do some changes here first before moving to the JS side of this technique.

In the src we are going to put a placeholder image to avoid having a broken image while the rest of the page loads, we are going to move the actual image to the data-src attribute, and finally we'll add a new class to the element.

<img src="{{asset "images/placeholder.png"}}" data-src="{{feature_image}}" class="lazyload" />

The placeholder image should be a small image in terms of weight. I'm using an image with a solid colour of 183 bytes so I can "reserve" the space of the final Feature Image to avoid "jumps" in the browser while everything loads.

Finally, the JS is quite simple. We need to wait for the window to be loaded, get all the img elements with the lazyload class, and replace the src with what's on the data-src so we trigger the actual image download.

window.addEventListener('load', (event) => {
    let images = document.getElementsByClassName('lazyload');

    for (let i = 0; i < images.length; i++) {
        images[i].src = images[i].dataset.src;

With this in place we should see that the content is prioritized over the Unsplash image, and if we are using a placeholder we should see that first in the "Network" tab of our browser's DevTools, with the actual image loading later.

Having a successfully work from home lifestyle

Having a successfully work from home lifestyle

This is the new normal, get used to it and get ready, because what's now (somehow still) a benefit from a company will be a requirement in the not too distant future. I wouldn't be surprised if working from home becomes a skill on a job offer rather than a perk.

Imagine listing on your resume not only your English level but also your work from home seniority.

All the lockdowns imposed around the globe due to the Covid-19 situation forced companies into a WFH scheme where everybody went remote from day to night.

I think this is here to stay in a combination of remote working and office space, resulting on a true flexible work from home scheme, because this is not only better for the employee but also cheaper for a company (no more rent?).

No more bs against working from home thanks to a pandemic
Companies were forced to reorganize quickly to continue working with their employees from home: the bs around this was cut immediately, the scepticism towards having people working from their homes disappeared. It had too, there was no other option.

I had the luxury of a WFH benefit on my last job and now, for the past two years, I became a full time remote employee to a London-based eCommerce agency so I sort of know how to work from home, and I don't see myself ever again going to an office Monday to Friday, so here's my take with three aspects on how to nail working from home.

Your space in the house

My first ever mistake (and probably everybody's first ever mistake) when I started to work from home everyday was to use the same table where I ate as my desk too.

The problem is not the table itself and the fact that the Mac shares it with a slice of pizza, but the inner feeling of being always on the same place, always, all the time, when working and when not doing it.

So even if you disconnect from Slack or close the lid, you are always at your working station, which is not good (mentally speaking).

Having a room in your house as the office is the main recommendation somebody could give you when diving into the work from home culture because it will easily allow you to "call it a day" when you have to, the same way you picked up your things from your desk at the company building and returned home.

Sometimes you'll need to isolate from the rest of the house when living with somebody else, on situations like having to concentrate on a task or having a Zoom meeting so here's where a door will come at handy, or some noise-cancelling headphones.

This leads us to having a set of house rules for all the house members for when work is happening, because not everybody is used to this work from home scheme and there was no reason at all until now to be aware of this new normal and having somebody in the house that now works from it.

For example, I tend to announce that I'm going to start a meeting, and that's enough for me. But you can set other rules too, like "Headphones means no interruptions", or guidelines for when the office door is closed.

Surely, I understand that having a spare room to be used as an office is usually a luxury, I'm no idiot.

For example, I rented my current place with this objective in mind, and I'm sure this will be something that's going to be considered, in the future, for when renting and/or moving.

But, still, there's always something you can do to mentally disconnect from work when you are done with it.

If you can't have a separate room, you maybe can have a specific place in the house to work, which is not the table where you eat. Like a small desk on the dinner or living room, that you know you use only for working.

Even if there's no physical space to do so, and you are forced no matter what to use the dinner table for working, then you can rely on environment settings to differentiate working hours from free time (like lighting).

Finally, something that works when there's no office room in the house is to close the computer and save it on a drawer, as a big gesture to call it a day.

A routine to avoid burnouts

One of the main problems of working from one, that we already mentioned as partially solvable by having a dedicated physical space to work, is the feeling of being on a constant work mode, on a state where work and life get mixed together and there's no clear differentiation between one and the other.

Having to go to an office imposed, at some capacity, a routine that you had to follow like waking up at a specific hour, having to take a shower for the sake of respecting your coworkers, having breakfast, etcetera.

Now you have to set your own routine, which is easy, and follow it, which is not.

This starts with having to follow regular hours every day, a routine. For example, I have set on my smartwatch reminders to have breakfast and lunch, which is a way to avoid losing track of time when I'm working.

Even if I do not actually follow them on a day because "I'm too busy" or because "I need to finish this first", it's a way to take awareness of "when are we".

You don't need to actually get up hours before work to take a shower, that clearly can be done later, but you shouldn't get up a minute before checking in at work. Allow you at least 15 minutes of being up and running before sitting on your desk.

I know that stay in bed for as much as we can is temping, and it's a clear benefit of working from home. But that's the benefit of not commuting, that's from where we gain sleeping hours.

So, 15 minutes of sleep won't make you any difference, but having 15 minutes for you before starting to work results on being more awake, therefore rested, through the entire day.

For a better working day, work on having a better wake up routine.

You don't have to have breakfast before work, that doesn't have to necessarily be part of your wake up routine, but instead you can have it later, during work, as a break.

Pause work during working hours to have breakfast? Isn't that against the rules? Please! When you were at the office you had some water cooler moments, or stop by the desk of a coworker to have some chat about whatever, or you made yourself five cups of coffee.

You had your breaks at the office and it's fine to have them now at home.

Call it a day

Avoid falling into an eternal working state of mind, or workaholism, is what you will be constantly fighting while working for home if you don't train yourself to be better at remote working.

Stop working is part of being good at it.

If the company you work for doesn't care for time tracking, you should track your time anyway, for yourself, to be aware of how much are you spending at work. And, as if you were going to an office, you should call it a day at some point, and don't work until the next day.

At the company I work for we have a Slack reminder with some stuff before we go, which also works as a reminder of what time is it (the same as the use of an alarm or the reminders I already mentioned I have on my smartwatch).

And when it's time to go. Go. No, really, go. Whatever it is, with the exception of an emergency, can be continued tomorrow... or next week.

If you can go out after calling it a day, even better. Leaving home is very good to clear your mind, even if it's for a short walk or for having a moment at a coffee store (which is my thing).

Working from home was always a luxury I can see becoming the new normal after this big social experiment we all suffered due to the pandemic.

Internet is full of tips and tricks on how to succeed at working from home. You just need to find those that suit you and get on with it.