Creating virtual domains with vhost middleware

Image for post
Image for post

First off, what is VHost?

vhost is a NodeJS middleware package that serves as a simple manager to segment traffic to specific services based on the requesting hostname. More often you’ll see vhost used in Express servers as it is bundled with the Express standard library viaExpress.vhost.

Looking at the vhost source on github, the code is actually quite simple. All it does is read the req.headers.host value and then have some helper functions for RegEx validation on the parsed hostname. At its core, the package validates the request hostname against the specified RegEx.

Despite it’s simple implementation it allows your server to organize and…


Carl O Sauer’s writings on Spain’s exploration of the New World

Image for post
Image for post

All the information provided in this article was derived from the writings of Carl O Sauer. The historical geography of the Spanish in California is rich, these are only the accounts of the first commissioned surveys of California coast and the maps they produced.

Carl O Sauer

Famously known for his contributions to post-16th century North American geography, Carl O Sauer remains one of the United States’ treasured intellects of the last 100 years. He formulated the concept of “cultural landscapes” which is still widely referred to in today’s mainstream ecological sustainability vernacular. Sauer was a precocious individual with professional interests in domains…


A natural law governing domains of creative human production.

Image for post
Image for post

Background

I recently stumbled upon a lecture given by Psychology Professor Jordan Peterson where he details socio-political developments of the Soviet Union after the first World War. He begins by explaining how the“peasant class” in the Soviet Union had become tremendously successful in agricultural production, ultimately supplying a large proportion of food for Russia and Ukraine. But eventually what happened was Vladimir Lenin, in his capricious leadership of the Soviet Revolution in the late 1910’s, pushed to collectivize the farms, which targeted a small number of highly successful peasant farmers, who were labelled as the Kulaks. …


Rocks — The Refuge of the Mircoworld.

Image for post
Image for post

An often dismissed component in plant health is the comparative distribution of rocks to plants in a given landscape. The sight beneath a rock is quite predictable to those who have ever been outside. The soil is moist and dark with a possible biological makeup of various arthropods such as arachnids, crustacean, and insects. On even a smaller and possibly more important measure is the composition of protozoa, bacteria, and fungi.

One of the most important biological forms in soil is mycorrhiza, a critical fungal organism that allows for plants to efficiently uptake nutrients through its roots. The literary research…


A quick demonstration on how you can migrate your current reducers to be pure and immutable.

Image for post
Image for post

Quick Redux Recap

Redux at its core is really just a one way messaging subscription system, but with this we can create amazing scalable state management.

In this messaging system we can subscribe (AKA “observe” and “listen”) to events, such as calling a function to make a request to an API. Interestingly so, in this subscription we can pass data.

  • Subscriptions are set
  • Stores are declared.

Data Flow

  1. Dispatch Action w/data → 2. Subscribers are notified w/data → 3. Data set in global store

As you can see redux is quite modular and simple. …


We’re going to walk through one of the small nuances of requiring vs reading a file directly during a running NodeJS process.

Image for post
Image for post

NOTE: This is not an in depth comparison of require and fs.readFile

If want to reference the latest version of a file throughout your running NodeJS process use the fs package, otherwise if you want your data to remain constant or don’t anticipate the file changing use require.

Example

When programming it is common to reference local files and use them in your code, for example:

let data = require(‘./data.json’);
// data = {"name": "count": "value": 4}

But what happens if you need to update the file’s value? You might try something like this:

const fs = require('fs').promises;const newData =…

Image for post
Image for post

Below are benchmarks and the accompanying function for the various ways to iterate in JavaScript.

Some people may argue that benchmarking without real application data is pointless but I still find it useful to understand data flow in these artificial setups.

Each was tested by iterating 10 million times.

TLDR; Regular “For Loop” is most performant and the “For Of loop” is least performant.

Here are the rankings:

  1. For Loop — 8 ms
  2. While Loop — 8 ms
  3. For In Loop — 16 ms
  4. For Each — 18 ms
  5. Filter — 34 ms
  6. Reduce — 34 ms
  7. Map — 69 ms
  8. For Of —…

TLDR; Chrome is pushing an update to its browser to enforce SameSite and Secure values on all third party cookies. Systems that rely on third party cookies without these values will not be set in browser nor sent with any following requests. Below is a local network audit of New York Times. We highlight system data loss with one of their advertising partners and those affected downstream. The analysis is somewhat technical, but it is encouraged to at least take a look at the network visuals.

The SameSite HTTP cookie property was initially proposed by the HTTP Working Group August…


Image for post
Image for post

Motivation

The following research is motivated by the relentless presidential advertisements I receive whenever I’m using my personal devices. Whether paid ads in my gmail inbox or posts in my Twitter feed, presidential advertisements are abundant.

I did some in-depth research on three of the top U.S presidential candidates’ campaign websites. I started a fresh session on each site and recorded all the network request/response data and then analyzed (I only did 3 in the interest of time).

TLDR; Kamala Harris’ site (33 trackers and advertising partners) tracks everything it possibly can and syncs it with the major social media sites…


Image for post
Image for post

adChain Publisher Registry

The past few weeks have been heavily research focused but we have made some enhancements to the adChain Publisher Registry Dapp. We have cut the page load time in half by removing a lot of unneeded data in the contract ABI files. When we compile the contracts on our machine with Truffle, it generates a JSON file with information about the contract. Within the file there is a lot of unnecessary data for actually instantiating the contract in Web3. After we cut out this data across three different contracts, the page load time improved significantly.

The engineering team has been…

Nicholas Porter

Researcher. Software. Plants.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store