SEPTEMBER 17, 2019

I've been living in a small apartment in downtown Málaga for the past seven months. Two people producing one or two bags of trash per week—mainly food packaging and spoiled items—bringing them to a nearby dumpster and starting over again.

In May 15, 2019, two Limasa trucks were collecting trash at La Plaza de la Merced. The small vehicle brooms and sucks the garbage that people mindlessly drop on the floor and accumulates trash from street sweepers as well. While I was sketching, this little truck moved from right to left to release all of its trash into the bigger one, which also collects trash from street containers.

It's become part of our daily lives. Trash cans, street sweepers, and a variety of vehicles keeping the streets clean for us and bringing our waste to landfills. We rarely stop and ask ourselves whether we should produce less trash and how to do it.

Could our individual decisions make a change or do decisions need to be made by the cities and entities who supply us with goods? I'm a bit skeptical of the real impact our individual decisions as consumers have, but that's a story for another day.

SEPTEMBER 11, 2019

As a security mechanism, Windows natively lets you unzip files by right-clicking and choosing Extract All.. Well, you can skip the manual unblocking of the files by using 7-Zip to extract the files instead of Windows’ mechanism.

We want to get rid of a message you might have seen over and over when downloading files from the internet. "This file came from another computer and might be blocked to help protect this computer," next to an Unblock button. If you know about this, it's fine to unblock a couple files, but it's really annoying when you download a zip containing dozens of files which you have to unblock individually, one by one.

Download and install 7-Zip and unzip downloaded plugins with right-click > 7-Zip > Extract here, or any of the other extraction options.

This issue has given me a lot of headaches when installing both Dynamo and Grasshopper plugins, but you might run into this issue in other environments as well. I'm glad there's an alternative to unlocking each file--might it be DLL, gha, gh, dyn, PDF, exe or files in another formats--separately, unzipping a group of files, all unlocked, at once.

SEPTEMBER 10, 2019

By default NPM—the Node Package Manager—uses its own public registry (at https://registry.npmjs.org) to pull down packages when you run npm install or npm update inside of a project.

You can specify different registries at multiple levels or scopes to override these default value (and other configuration settings). Ideally, when working on projects that require a specific registry—due to security or maybe just because some packages are inside of a private repository—you would set NPM to look for packages on that registry inside of the project folder.

Command level (only affects the command itself)

npm install --registry=https://some.registry.url

Project level (these would be the contents of the .npmrc file inside of the project folder)

registry=https://some.registry.url
@namespace:registry=https://some.other.registry.url

Global (these would be the contents of the .npmrc file inside of your system user folder)

registry=https://some.registry.url
@namespace:registry=https://some.other.registry.url

How to check your configuration is working

Run the npm config list command to see what variables are set. If you run this in a project folder with an .npmrc file you should see its overriding configuration settings in the folder, and the system global settings after that.

If you run the command in any other folder (without an .npmrc file with custom settings) you should see whatever is set in the global .npmrc and then the default configuration values of NPM.

SEPTEMBER 10, 2019

A cheat-sheet for mathematical notation in [JavaScript] code form.

SEPTEMBER 9, 2019

Today I've automated the backup of the configuration, database, and static files of all the websites I manage. Two hours and a half that will save me a lot of time in the coming future, and remove stress when weird things happen. The backup—of six websites in three different servers running Laravel—downloads a copy of the database, the .env files, and the static files (a zip with the contents of the public folder) of each site.

I'll probably open source these scripts in the near future.

One new thing I learned was creating bash functions, like this one.

# create a variable with current date, formatted as yymmdd_HHMMSS
DATE_NOW=$(date '+%y%m%d_%H%M%S') 

# function that zips something and removes it
zip_and_remove() { cd $1 && zip "$2.zip" $2 && rm $2 && cd .. }

# function that downloads a file via ssh then calls the previous one
download_zip_remove() { scp $1 $2/$3 && zip_and_remove $2 $3  }

# a function call
download_zip_remove root@192.168.1.2:/var/www/site.com/folio/.env $DESTINATION $(echo $DATE_NOW)_$SITENAME.env

SEPTEMBER 5, 2019

Revit allows you to import PDF and image files from its Ribbon menu. After clicking either button (Import PDF or Import Image) you get the same window, really, just with a different extension pre-selected.

You import a file and place it into a view, and if the file happens to be a PDF file you select a page and a rasterization resolution (in DPI).

Internally, Revit uses the PDFNet library made by PDFTron to manipulate PDF files. One of the operations it seems to use it for is to rasterize the contents of a PDF to be able to display it on a view. This process makes the image data (of the image itself or a rasterized PDF) available inside of Revit. By using the Revit Lookup add-in, I found that the ImageType class offers a GetImage() method which returns a Bitmap object containing that image data.


Remember that, when you pick an existing imported image or PDF, you are selecting what's called an object of the ImageInstance class, which wraps an ImageType object. So we need to get the ImageInstance element, access its ImageType, then get its image data.


Let's see the code.

// This code goes somewhere in your Revit add-in
// Prompt user to pick a Revit Element
Reference pickedObject = UIDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);

// Get Element
Element element = Doc.GetElement(pickedObject.ElementId);

// Get Element Type
ElementId elementTypeId = element.GetTypeId();
ElementType elementType = Doc.GetElement(elementTypeId) as ElementType;

// Do something if object selection exists
if (pickedObject != null)
{
    // Check if picked element is an ImageInstance
    if (element is ImageInstance)
    {
        // Cast types for ImageInstance and ImageType
        // ImageType Id = ImageInstance Id - 1
        ImageInstance image = element as ImageInstance;
        ImageType imageType = elementType as ImageType;

        // Get image properties
        var filename = image.Name; // eg. FloorPlan.pdf

        // Get imported file path from ImageType
        var filepath = imageType.get_Parameter(BuiltInParameter.RASTER_SYMBOL_FILENAME).AsString();
        var pixelWidth = imageType.get_Parameter(BuiltInParameter.RASTER_SYMBOL_PIXELWIDTH).AsInteger();
        var pixelHeight = imageType.get_Parameter(BuiltInParameter.RASTER_SYMBOL_PIXELHEIGHT).AsInteger();

        // Get image data
        Bitmap bitmap = imageType.GetImage();

        // Save image to disk
        bitmap.Save(@"C:\users\username\Desktop\image.bmp");
    }
}

Before you go

If you found this useful, you might want to join my newsletter; or take a look at other posts about code, Revit, C#, TypeScript, and React.

SEPTEMBER 3, 2019

If you are inside of a function which uses a type parameter—T—you can do a Console.WriteLine, for instance, to inspect what type is being used on a given function call.

Console.WriteLine(typeof(T));
// System.object or other type

AUGUST 6, 2019

On top of being an author and entrepreneur, Scott Young is an ultralearner. After learning MIT's 4-year computer science curriculum in less than twelve months, Scott taught himself four new languages in a year.

In his book Ultralearning—released today—Scott shares the principles and methods that he and other ultralearners employ to quickly master new skills, acquire knowledge, and become good at things that seem impossible to you right now.


Listen to "Scott Young — Ultralearning, How to Master Hard Skills, Outsmart the Competition, and Accelerate Your Career"

JULY 24, 2019

This example uses regular expressions (RegExp) to replace multiple appearances of a substring in a string.

const string = `The car is red. The car is black.`;

const replacedString = string.replace(/car|is/g, "·····");

console.log(replacedString);
// returns The ····· ····· red. The ····· ····· black.

Before you go

If you found this useful, you might want to join my newsletter; or take a look at other posts about code, TypeScript, and React.

JULY 24, 2019

Here is an example of nested Promise.all() calls. We are using the Fetch API to load a given path or URL, then requesting the arrayBuffer() of each of the responses we get back. This is a trivial problem if we do it all asynchronously, but we want to do something with the output buffers when we have them all available, and not one by one.

Specifically, this code tries to (1) fetch an array of images; (2) get their array buffers; (3) then obtain their base64 representation. In essence, map an array of images (by providing their paths or URLs) to their corresponding base64 string.


While this technique works in both TypeScript and JavaScript, the code is only shown in TypeScript.

Approach 1: Verbose

const images = [/* Array of image URLs (or local path if running in Electron) */]

Promise.all(images.map((url) => fetch(url))).then((responses: any) => {

    return Promise.all(responses.map((res: Response) => res.arrayBuffer())).then((buffers) => {
        return buffers;
    });

}).then((buffers: any) => {

    return Promise.all(buffers.map((buffer: ArrayBuffer) => {
        return this.arrayBufferToBase64(buffer);
    }));

}).then((imagesAsBase64: any) => {

    // Do something with the base64 strings
    window.console.log(imagesAsBase64);

});

Approach 2: Simplified

const layerImages = [/* Array of image URLs (or local path if running in Electron) */]

Promise.all(layerImages.map((url) => fetch(url))).then((responses: any) => {

    return Promise.all(responses.map((res: Response) => res.arrayBuffer())).then((buffers) => {
        return buffers.map((buffer) => this.arrayBufferToBase64(buffer));
    });

}).then((imagesAsBase64: any) => {

    // Do something with the base64 strings
    window.console.log(imagesAsBase64);

});

Array Buffer to base64

// source: stackoverflow.com
private arrayBufferToBase64(buffer: any) {
    let binary = "";
    const bytes = [].slice.call(new Uint8Array(buffer));
    bytes.forEach((b: any) => binary += String.fromCharCode(b));
    // Inside of a web tab
    return window.btoa(binary);
}

Before you go

If you found this useful, you might want to join my newsletter; or take a look at other posts about code, TypeScript, and React.

JULY 19, 2019

Technologist and artist Cristóbal Valenzuela co-founded Runway with a simple idea in mind: putting machine learning in the hands of creators as an intuitive and simple visual interface.

We are on the verge of a new creative revolution. [Machine intelligence] is producing radical changes in the way digital content is made, understood, and processed, unfastening previously unimagined ways of creating.

Enjoy this conversation on how to power your creative work with artificial intelligence, and Cristóbal's take on simplicity, life, work, and creativity.


Listen to "Cristobal Valenzuela — Machine Learning for Creators"

JULY 10, 2019

It's convenient to deploy a single Laravel application and then point multiple domains to it and have different configurations (and databases) for each individual domain. This means that you can reuse your code and only deploy once if all of the websites share the same resources, and then just specify a custom .env environment file to configure each domain entry point.

The first thing you need to do is to add one .env per domain. (Leave your .env file as a default, which would be used as a fallback for domains where you haven't explicitly created a custom .env file.) For the domains you want to have their custom config, add an .env file attaching the domain name to the end of its filename, like .env.nono.ma, for instance.

Then add the following code to your bootstrap/app.php right before returning the $app.

// bootstrap/app.php

// ...

/*
|-----------------------------------------------
| Load domain-specific .env file if it exists
|-----------------------------------------------
*/

if(isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])){
    $domain = $_SERVER['HTTP_HOST'];
}

if ($domain) {
    $dotenv = \Dotenv\Dotenv::create(base_path(), '.env.'.$domain);
    try {
        $dotenv->overload();
    } catch (\Dotenv\Exception\InvalidPathException $e) {
        // No custom .env file found for this domain
    }
}

// ...

return $app;

I've tested this code with Laravel 5.8 and it works like a charm.

JULY 9, 2019


Important Looking Pirates on rendering Westworld:

For all the character work on Westworld, we used Arnold. It’s perfect for preserving detail in skin shading and also handles hair/fur very efficiently. For shading, we quite often work with Anders Langlands, alShader and also use shaders written here at ILP. Besides Arnold, we also used V-Ray for the train station sequence.

Bobo Skipper (VFX Supervisor of Important Looking Pirates):

We started our shot production for Westworld in early February 2016. The size of the team varied depending on what episode we were on. At times we were about five people and other times around 15. In total, we delivered around 65 shots.

We were so excited when Jay Worth (VFX Supervisor) approached us. The show looked promising, and there were a lot of cool shots planned. Our goal is always to deliver the best possible quality, and for all the VFX we did on "Westworld" the most important thing was that shots helped drive the story. I think the first season turned out to be incredible and I’m proud of our contribution to the show.

In general, the challenge was to deliver high-quality shots for all our sequences. A few of the extra tricky ones included creating a young version of Anthony Hopkins, a big terraformer digging up dirt and rock and the sequence of the robot boy opening up the face.


Read the full article on Autodesk AREA.

JUNE 30, 2019

Over the last months, I've been questioning why the streets of my hometown are flooded with electric scooters, at the same time that I keep asking myself if I should continue using social media and how.

In this essay, I briefly explain the way Amish communities decide whether to adopt a given piece of technology, and, hopefully, convince you that our modern communities—and ourselves as individuals—can learn from why and how the Amish do it.


Read "Would The Amish Ride Electric Scooters?"

JUNE 26, 2019

—Wake up.
—Oh God, another day? Boy, this hurts.


Simplicity might well be the art of hiding the messiness involved in our creative processes. (Drafts and versions; cutting and pasting; design tools; projects, clients, and deadlines.) Even when new technologies facilitate our arts and crafts, traditional methods may still work better than anything made today.

Enjoy this conversation with a maximalist artist living a simple life doing what makes him (and others) smile.

Turns everything off and goes outside.


Listen to "Pier Gustafson — Drawing Fast, Thinking Slow"

JUNE 12, 2019

Simplicity is an emerging trend; a luxury not everyone can afford.

For the last 10,000 years, human biology has barely changed — yet our lives feel more complex, accelerated, and stressful than ever before.

What are we trying to slow down from?


🎙 Listen to "Panagiotis Michalatos — Slow Down From What?"

JUNE 6, 2019

Hi Friends— 👋🏻

I'm excited to be preparing a newsletter to share my sketches with you on a weekly basis. Each week, subscribers will receive a sketch paired with a short essay. The drive of this project is to sketch and write daily, and to have a medium to share my drawings independent from social media. 👨🏻‍🎨

Curious about the format? Here's a sample email.

If you feel this is your kind of thing, here's how to join.

JUNE 5, 2019

Now it’s incredibly simple to start building a native Mac app from your current iPad app. Your apps share the same project and source code, so you can efficiently convert your iPad app’s desktop-class features, and add more just for Mac.

Apple seems to (finally) have started blurring the edges between what it means to be an iPadOS and a macOS app.

If your iPad app would make an excellent Mac app, now is the perfect time to streamline your code base and bring your app to life on Mac. The beta version of Xcode 11 is all you need. Begin by selecting the “Mac” checkbox in the project settings of your existing iPad app to create a native Mac app that you can enhance further. Your Mac and iPad apps share the same project and source code, making it easy to change your code in one place.

MAY 17, 2019

Yay! Visual Studio just announce a preview release of "extension [that] let you work with [Visual Studio] Code over SSH on a remote machine or VM, in Windows Subsystem for Linux (WSL), or inside a Docker container."

Go ahead and install the Remote Development extension. "An extension pack that lets you open any folder in a container, on a remote machine, or in WSL and take advantage of VS Code's full feature set."

MAY 15, 2019

Here are some highlights that might affect your Mailchimp account if you are close to moving to over 2,000 contacts in your Free Plan.


7B. Audience and Archiving

You may have several types of contacts in your Mailchimp account, but only contacts that you can engage through the Service count as contacts in your “audience” for purposes of your Monthly Plan or Free Plan. Subscribed, unsubscribed, and transactional (or e-commerce) contacts count towards your audience. Cleaned, pending, reconfirmed, deleted, and archived contacts do not count towards your audience. You may elect to archive contacts at any time, but any profile changes for an archived contact (whether initiated by you, the contact, or an integration) will automatically unarchive that contact. You cannot engage in any activity through the Service with archived contacts unless and until they are unarchived. If a contact is unarchived, it will immediately count towards your audience for your current billing cycle and any future billing cycles unless and until archived again.

8. Free Plans

If you use the Service under the free plan (“Free Plan”) and you want to go over the Free Plan limits, you’ll be required to upgrade your account to, and select and pay for, a Monthly Plan. Monthly Plans are described in Section 7A above. If you exceed your Free Plan limits, or otherwise upgrade your account to a paid Monthly Plan, you’ll only be provided one complimentary downgrade to the Free Plan (provided your sending volume and audience numbers drop down to the Free Plan limits again). If you go over the limits for the Free Plan more than once, you’ll no longer qualify for the Free Plan, even if your future sending volume and audience numbers are within the limits of the Free Plan.

MAY 6, 2019

It's been eight months since I left Cambridge, Massachusetts, and moved back to Málaga, Spain. Take a look at my now page to see what I'm focusing on now: writing, podcasting, sketching, machine learning, and reading.

MAY 2, 2019

To improve your experience with Apple Podcasts, we want to share the following information and updates.

iOS 12.2
In addition to bug fixes and feature enhancements, we'd like to call your attention to these improvements to the Podcasts app on iOS 12.2:

  • Browse. Featured collections and categories, as well as the Top Episodes and Top Shows charts, are now presented on the Browse tab for easier discovery.
  • Episode numbers. Now, both show types, episodic and serial, will display episode numbers for subscribed users as dictated by the tag.
  • Mark as Played. With 3D Touch or by tapping , listeners can now mark episodes as played for their subscribed shows.

Apple Podcasts Preview

Apple Podcasts Preview pages on the web have been updated. For the first time, we are introducing a dedicated episode page that includes the ability to play directly on the web. The design is also mobile responsive and provides a better experience for Android users.

Podcasts Connect Help

We've updated the RSS tags section to explain the different supported tags more clearly and show how they are displayed on Apple Podcasts on iOS 12.2. Also, the relevant section now distinguishes between required, recommended, and situational tags. Previous tags and values will continue to be supported unless otherwise communicated.

Being able to play podcast episodes in a web browser (and even have an individual page per episode) is huge.


They've also updated the example of a well-formed RSS feed.

MAY 1, 2019

It’s not a better UI — it’s the facade of a better UI built on top of the same old crap, which was in turn a facade on top of older crap.

[…]

I’d rather retire from using computers than use Windows 10. What a mess.

APRIL 30, 2019

Opportunities to talk to people like Saba Ghole and learn about how they understand life and what drives them to do what they do every day, is what moves me to continue with the Getting Simple project.

"I had a chance to reminisce with Nono about what it means to get simple and embody a growth mindset on his very special podcast. Mixed in are bits about my childhood, my artistic pursuits, and my current love and passion, NuVu Studio." —Saba Ghole, Co-founder and Chief Creative Officer of NuVu Studio

If you're intrigued about how growth mindset can be taken to reality, listen to this episode and learn about how NuVu, an innovation school for middle and high school students, helps students build long-lasting core competencies and creative skills.


🎙 Listen on iTunes · Spotify · Overcast · Stitcher

APRIL 12, 2019


Here's the video of my BIMOn 2019 talk, in Spanish, on intuitive interfaces, artificial intelligence, and their potential uses for BIM. I also talk about Suggestive Drawing and Getting Simple.

Take a look at the talk links.

Want to see older publications? Visit the archive.

Listen to my Podcast.