Image for post
Image for post
Kedge, easy to use global state hook for React

Kedge adds new useStore hook that feels and behaves a lot like useState except that it is shared globally.

Installation

npm install kedge

Usage

Previously, React state was an object that contained multiple properties describing the state of the component.

useState changed this. State is now a single value that represents a single property of the component. As such, components have multiple state objects.

The same principle applies to stores created with useStore. Store is a single value and an application will most likely have more than one.

When creating stores, I recommend doing so in a centralized location.

# store.jsimport { createStore } from…


Image for post
Image for post

I don’t own a business. I don’t have business meetings. I don’t do “business”. I meet new people and have friends.

Giving out “business” cards feels shallow and superficial to me and I have always wanted to find a more personal way to connect.

Having conversations with someone is a great way to connect but exchanging contact information can disrupt that experience.

To solve these issues I don’t need a business card. I need a Personal Card.

I ordered a bunch of absolutely minimalistic business cards.

Image for post
Image for post

The idea is that I can give every person I meet a personalized keepsake.

At first, I thought that most of the time I would simply write “Hi. …


Image for post
Image for post

I don’t think Laravel needs any introduction at this point. Afterall, it is the most popular PHP framework.

This article assumes that you have already setup Homestead. If you have not, please read my previous article on the subject.

Notice

These instructions are specific to OS X. However, these concepts can be applied to other operating systems like Windows or Linux.

If you were to install Laravel from your local machine you might get an old version due to PHP being out of date. …


Regex is very powerful but it has a major flaw. It is a major pain to maintain.

The patterns you write may seem simple and easy to understand to you at this very moment but I absolutely guarantee you that someone (most likely you in 2 months) will spend way too much time breaking them down to understand what they do.

SQL deals with that problem by using natural language instead of specialized representation.

SRL is SQL for RegEx.

Take a look at this pattern.

/^(?:[0-9]|[a-z]|[\._%\+-])+(?:@)(?:[0-9]|[a-z]|[\.-])+(?:\.)[a-z]{2,}$/i

And the same thing in SRL.

begin with any of (digit, letter, one of "._%+-") once or more,
literally "@",
any of (digit, letter, one of ".-") once or more,
literally ".",
letter at least 2 times,
must end, case insensitive

Way simpler. Learn more here: https://simple-regex.com/


In this article, I will show you how PHP static methods, more often than not, result in coupled code that is hard to test. Certainly, it is possible to write clean, decoupled, maintainable and easy to test code using static methods. However, in the real world, I have never seen this. The amusing part about static methods is that the problems come up, not in these methods themselves but in the code calling them.

But first, let’s lay down some foundation.

Domain Layer

In short, the idea is to separate the business logic (domain) from the application logic (framework) as much as possible. Most of the production applications I have worked with were so tightly coupled to the framework that any attempt at moving to a different framework was equivalent with a significant rewrite. How nice would it be if it was possible to move an entire app from Phalcon to Laravel in a week? The same principle applies when switching from a traditional web application to a single page application or even native mobile apps. …


Image for post
Image for post

Here is a useful bookmarklet for TweetDeck users that clears all your columns in one go.

Unfortunately, Medium sucks for posting these. You have to copy the below code into a bookmark.

javascript:(function(){$.each(TD.controller.columnManager.getAll(),function(_,b){b.clear()})})();

Image for post
Image for post

Now that we have vagrant going we could set up the entire stack by hand using our favorite flavor of Linux. Or, we could just use a premade box that is ready to go with everything we might need. Say hello to Homestead.

Homestead is Laravel’s official Vagrant box. It comes preconfigured with a lot of tools you might need. It really makes things a lot easier and quicker.

Notice

These instructions are specific to OS X. However, these concepts can be applied to other operating systems like Windows or Linux.

To install Homestead, we will pull its Vagrant file from GitHub. Git is already installed on OS X so just run this command in…


Image for post
Image for post

Before we write any code, we will set up a local development environment where we can run it and test it. Vagrant will help us do just that.

Vagrant is a tool that lets you easily spin up pre-configured development virtual machines. There are many reasons to use Vagrant but for the purpose of this course let’s just say that it is the recommended Laravel way. There is an official Vagrant box made specifically for Laravel development called Homestead. It integrates extremely well into the workflow and it has no lasting impact on your computer.

Notice

These instructions are specific to OS X. However, these concepts can be applied to other operating systems like Windows or Linux.

About

Matt Stypa

Calm work culture advocate. Open source contributor. Lead software engineer @ http://Neighborhoods.com

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