Monthly Archiv: December, 2021

Caddy as a Secure Reverse Proxy

I've been using Caddy as a front-end reverse proxy for several years now, on the advice of Marco Pivetta. Somewhere along the line version 2 was released, and I updated at some point, but evidently didn't quite understand some of its configuration options, particularly around HSTS support and providing your proxied application information about how the client tried to connect.

Caddy has always had a fairly declarative syntax, and tended towards sane defaults. The syntax is like a hybrid of YAML and HCL, for better or worse, and includes placeholders for substituting in request or block-specific values. Fortunately, you don't have to write much to get the most common scenarios to work correctly. And v2 now provides a JSON syntax as well. The JSON syntax gives full access to all configuration options, and is particularly useful to learn if you want to be able to update the configuration on the fly via Caddy 2's configuration API. That said, the JSON syntax is incredibly verbose, and has quite a large set of nested members; I've found that for the bulk of my usage, the declarative HCL-like syntax tends to be easier to read and implement.

For instance, the documented way to create a reverse proxy to a service running on port 9000 of another machine, and that uses HTTPS by default is simply:

your.host.name {
  reverse_proxy machine-running-actual-service:9000
}

Boom, done.

Even better: Caddy can serve local IPs and addresses over HTTPS as well. It will generate self-signed certificates using its own root certificate, which you then install into your system trust store. The benefit is you can test your sites locally using TLS, which can help when testing JavaScript interactions, and reduce behavior differences with production.

Securing reverse proxies

That said, I've run into some small issues when running reverse proxies:

  • I assumed HSTS headers were in place. They were not. (This is true of any Caddy-served site, though, and not specific to reverse proxies.)
  • I assumed things like the X-Forwarded-Host and X-Real-IP request headers were in place. They were not. That said: by default, Caddy:
    • Passes the Host header intact to the proxy. This is actually quite handy, as most application frameworks will prefer the Host header when present anyways.
    • Adds the X-Forwarded-Proto header; this is the one most standardly consumed by other web servers and web application frameworks.
    • Adds or updates the X-Forwarded-For header, which is used by load balancers.

Fortunately, adding configuration for these are relatively straight-forward

your.host.name {
  reverse_proxy machine-running-actual-service:9000 {
    header_up X-Real-IP {remote}
    header_down Strict-Transport-Security max-age=31536000
  }
}

If you have quite a number of reverse proxies, you likely don't want to copy-paste those. Caddy to the rescue again: configuration supports snippets. These look like your host blocks, but the name will be in parentheses. When a configuration block can re-use it, it can import it by name.

(reverseproxyheaders) {
    header_up X-Real-IP {remote}
    header_down Strict-Transport-Security max-age=31536000
}

your.host.name {
  reverse_proxy machine-running-actual-service:9000 {
    import reverseproxyheaders
  }
}

With these changes, my applications now:

  • can resolve the client IP correctly
  • provide HSTS headers to the client, helping protect users from MITM attacks

My own configuration defines three reverse proxies, two subdomains that redirect elsewhere, and defines one static site. All in a total of 34 lines of configuration.

I'll take it.

Endnote

Why use Caddy, particularly if you're comfortable and/or knowledgable with Apache or nginx?

For me, the decision comes down to sane defaults and ease of setup. Setting up ACME with Apache or nginx, while it has become simpler, is not turn-key. Caddy, however, assumes TLS by default, uses ACME to marshal a TLS certificate, and redirects non-TLS requests to TLS, all without requiring any additional configuration whatsoever. Similarly, the fact that setting up a reverse proxy can often be as simple as pointing it to the proxy, and not require remembering to pass on common headers, sets it apart from the traditional web servers. Finally, it's built for speed, and I've found that the performance overhead of running it as a reverse proxy is essentially negligible.

Truncated by Planet PHP, read more at the original (another 816 bytes)

Advent of Functional PHP: Day 6

Advent of Functional PHP: Day 6

Day 6's challenge is a little fishy. Given what we've already done so far, it's pretty simple. The only catch is making sure you do it in an efficient way.

Specifically, we're asked to model the growth patterns of fictional lantern fish. In this silly model, we start with a list of fish at various ages. Each fish spawns a new fish every 7 days, and a newborn fish takes an extra 2 days before it starts spawning new fish. Fish also never die. (Someone warn the AI people that we've found the paperclip optimizer.)

Part 1 asks us how many fish there are after 80 days, all around the world, given the start data. Let's find out, but let's do so efficiently.

Continue reading this post on PeakD.

Larry 6 December 2021 - 12:43pm

20 Beautifully Imperfect Free Brush Fonts for Designers

Distorted, irregular, and beautifully imperfect. Every individual character is unique and carefully created by hand. Rustic in style yet seamlessly blends in with modern design.

Yes, we’re talking about paint brush-style typography, and it is currently enjoying a revival in popularity. And, we love it!

If you’re looking to jump on the brush-style typography bandwagon, in this article, we have a curated collection of our favorite brush fonts that you can freely download and use in your own creative design projects.

All of the fonts have been created by professional designers and can be used to create something truly unique.

As already mentioned, all of the below fonts are free, but please double-check the license before usage as they can change from time to time.

Zallord Brush Font Free, by Husain Assyahid

Zallord free font brush hand-written hand-painted

Namashte Brush Font on Envato Elements

Namashte free font brush hand-written hand-painted

Perfect Moment Handwritten SVG Font Free, by Ivan Rosenberg

Perfect Moment SVG free font brush hand-written hand-painted

Besom Brush Font Free, by Krišjānis Mežulis

Besom free font brush hand-written hand-painted

Northen Brush Font on Envato Elements

Northen free font brush hand-written hand-painted

Hensa Hand-Painter Brush Script Font Free, by Vlad Cristea

Hensa Hand-Painter Brush Script free font brush hand-written hand-painted

Hey October Brush Font Free, by Khurasan

Hey October free font brush hand-written hand-painted

Shuttles Brush Font on Envato Elements

Shuttles free font brush hand-written hand-painted

Painter Brush Font Free, by Jammy Creamer

Painter free font brush hand-written hand-painted

Kust Brush Font Free, by Krisjanis Mezulis

kust free font brush hand-written hand-painted

Mighty Brush Font on Envato Elements

Mighty free font brush hand-written hand-painted

Crocky Brush Font Free, by Creatype Studio

Crocky free font brush hand-written hand-painted

Better Hobby Highlighter Font Free, by Letterhend Studio

Better Hobby Highlighter free font brush hand-written hand-painted

Flat Brush Font on Envato Elements

flat free font brush hand-written hand-painted

True South Brush Font Free, by Stefie Justprince

True South free font brush hand-written hand-painted

Debby Hand-Drawn Brush Font Free, by Artimasa Studio

debby free font brush hand-written hand-painted

Mazak Hand-Drawn Brush Font Free, by Ewelina Gąska

Mazak free font brush hand-written hand-painted

Lemon Tuesday Brush Font Free, by Daria Kwon

Lemon Tuesday free font brush hand-written hand-painted

Chiesty Script Font Free, by CreativeTacos

Chiesty Script free font brush hand-written hand-painted

Thorn Brush Font Free, by Stefie Justprince

thorn free font brush hand-written hand-painted

Chocoleta Brush Font Free, by CruzineDesign

Chocoleta free font brush hand-written hand-painted

Willful Handwritten Brush Sans Font Free, by Mr.Typeman

Willful Sans free font brush hand-written hand-painted

Wildrock Brush Font Free, by Creatype Studio

Wildrock free font brush hand-written hand-painted

Brush King Font Free, by Subectype

king free font brush hand-written hand-painted

The post 20 Beautifully Imperfect Free Brush Fonts for Designers appeared first on Speckyboy Design Magazine.

10 WordPress Plugins for Importing and Exporting Data

Data portability is something that we don’t often think about until we need it. This is especially so with WordPress. Our posts, users, eCommerce orders, etc., live happily in a database. But when we want to access and take that information with us (and potentially import it into another site), it’s not always a simple task.

One way to handle this is via backend software like phpMyAdmin. You can import and export a full database or just specific tables. It offers a lot of flexibility. But that is not recommended for the faint of heart. It is entirely possible to bring down a site if you’re not careful.

In most cases, the better way to perform these tasks is through a WordPress plugin. Many feature a more user-friendly GUI and some are built for niche uses like user accounts or WooCommerce orders. This is an added layer of convenience overdoing things through phpMyAdmin.

A word to the wise: Misuse of a plugin can still result in damage. So always make sure to back up your site before messing around with critical data. Even better, make a copy of your site and test things out in a staging environment before touching a live install of WordPress.

With that, here are 10 free plugins you can use to import and export various kinds of data with WordPress. Note that while the plugins are categorized as Import or Export, some will happily perform both functions.

WP All Import

WP All Import is designed for times when you want to import posts from a CSV or XML file that isn’t WordPress-friendly by default. It could be something a client created, or it could be from a different CMS. The plugin doesn’t require any special elements or layouts in the file, making a tough job easier.

A companion Export plugin is also available.

WP All Import

WP Ultimate CSV Importer

WP Ultimate CSV Importer (which also provides Exports) enables you to import an array of data. Included are the abilities to import posts, pages, custom post types, comments, users, custom fields and even SEO information from All in One SEO Pack. You can also import images from external URLs.

WP Ultimate CSV Importer

Import Users from CSV with Meta

If you have many users to import, Import Users from CSV with Meta is a lifesaver. Not only will it bring new users into your WordPress install, but it can also update data for existing users. Plus, it will import Meta from plugins like WooCommerce, or you can create your own custom info.

You’ll also be able to assign each user a specific role and choose whether or not to send an email to new users.

Import Users from CSV with Meta

Customizer Export/Import

Recreating the exact theme settings in the WordPress Customizer can be extremely tedious – especially when you’re using a theme that has lots of options.

Customizer Export/Import makes it a breeze, allowing you to export or import settings from another site (or restore a backup) directly from within the Customizer.

Customizer Export/Import

JSON Content Importer

JSON Content Importer lets you display live data from a JSON feed through a simple Shortcode. Control how many items are displayed, use keyword settings to only display specific types of content, and more. The plugin uses a template engine to help you tweak the layout to your liking.

JSON Content Importer

Export Plugins

Export User Data

Perfect for eCommerce and membership sites, Export User Data makes it easy to export a custom spreadsheet of users. Craft your export from custom user meta (including fields added by BuddyPress), registration date, and user role. This allows administrators to quickly narrow things down to just a specific segment of accounts.

Export User Data

Advanced Orders Export for WooCommerce

Advanced Orders Export for WooCommerce is incredibly flexible. It enables you to export virtually anything associated with a WooCommerce product, including Meta and custom fields.

Powerful filters and the ability to move fields around allow for fine-tuning an export to your liking. Export your orders in CSV, XLS, XML, and JSON. Available code snippets help you add compatibility with certain Woo extensions.

Advanced Orders Export for WooCommerce

Export All URLs

Do you need to quickly grab a listing of all the titles, URLs, and categories for your WordPress Website? Export All URLs will create a page on your site listing it all. Data can be exported and categorized by post type.

Export All URLs

Simple CSV/XLS Exporter

Simple CSV/XLS Exporter is a utility that lets you pick and choose what is included with your export.

Pick from any standard or custom post type, select fields, or get really specific by choosing posts made by a specific user ID. WooCommerce orders can also be included in an export.

Simple CSV/XLS Exporter

Export Media with Selected Content

When exporting a post type in WordPress, the media attached to those posts are not included. Export Media with Selected Content provides a fix by allowing you to choose whether or not to include media files in the package.

Export Media with Selected Content

Portability is Important

The ability to move data around is a necessary feature for many organizations. User data can go back and forth to keep a membership roster up to date. Online sales data can be imported into accounting software to get ready for tax time. And, there’s always the need to move data between websites.

While some of the plugins above have a more narrow focus than others, they can all serve the purpose of making a WordPress website’s data more portable. That, in turn, makes life easier for both designers and site owners.

The post 10 WordPress Plugins for Importing and Exporting Data appeared first on Speckyboy Design Magazine.

8 Outstanding eCommerce Microinteraction CSS & JavaScript Snippets

Microinteractions, those tiny details revealed when someone hovers or clicks on an item, is key to a successful user experience. They provide a hint as to what a specific design element does, thus making it more intuitive.

These little gems are especially important on eCommerce websites. We can use them to reinforce user actions and remove any chance of confusion. When done right, they fit seamlessly into a design.

What do eCommerce microinteractions look like in practice? We’ve rounded up a collection of unique code snippets that serve as prime examples. They utilize CSS and JavaScript to add something extra to the online shopping experience. Let’s get started!

Animated SVG Icons by Joni Trythall

Icons are used on all manner of websites but have particular importance for eCommerce.

This set of animated SVG animated icons can serve as confirmation for adding products to a cart, wish list, and more. Even better is that each icon has three variations to choose from.

See the Pen Animated Shopping Cart Icons by Joni Trythall

Rolling Shopping Cart by Aaron Iker

The simplicity of this animated button is wonderful. One click and a shopping cart icon rolls in and “fills up” with color. There’s a lot of movement, yet it doesn’t feel the least bit overwhelming. It would fit in with virtually any type of online store.

See the Pen Add to cart animation by Aaron Iker

Add a Product with Text Confirmation by Lance Jernigan

Fans of Google’s Material Design will want to check out this snippet. The look adheres to the design language, while the microinteraction is slick and informative.

Clicking the “Add To Cart” button results in a spinning loader graphic. From there, a text confirmation ensures that shoppers will know that their item has been successfully added.

See the Pen Material Add To Cart Animation by Lance Jernigan

Docking Product Image by Filip Danisko

Looking for a unique microinteraction? This snippet sends a product thumbnail image to a sidebar dock when a user adds it to their cart. And it’s not just for show. Hover on the thumbnail and you can easily remove the product as well.

See the Pen Add to cart animation by Filip Danisko

Multi-Step Cart Process by Marcus Forsberg

Here’s an example that treats eCommerce as a step-by-step process. Adding a product to your cart brings up an attractive quantity UI. Select the amount you want, click on “GO,” and the fun really begins.

A visual confirmation appears, then floats over to the cart icon on the upper right of the screen. The overall functionality is great, and the animation successfully ties it all together.

See the Pen Add to cart animation by Marcus Forsberg

Going to Checkout by Richik SC

This animated checkout button sends users onto the next step in style. It utilizes a simple CSS animation to confirm their choice and show that the redirection is underway.

See the Pen Animated Checkout Button by Richik SC

Simple Add to Cart Button by Rune Sejer Hoffmann

Simplicity is the name of the game here. Add a product to the cart, and you’ll see a quick change in both the button background color and adjacent icon. This one gets the job done nicely and without any unnecessary theatrics.

See the Pen Ecommerce animations by Rune Sejer Hoffmann

Add and Remove Items by Amirtha Shankari

Here’s a snippet that focuses on the shopping cart icon itself. Adding a product unleashes an animated box icon. It ricochets off the cart as if it were a basketball hoop.

Remove an item and just the opposite happens. While it would be great to see some microinteractions on the buttons themselves, the cart effects are brilliant.

See the Pen Add to Cart Animation by AmirthaShankari

Improving eCommerce through Microinteractions

When it comes to improving the user experience of your online store, microinteractions are a great feature to consider. They’re an easy means to make an instant impact. And, because they often rely on CSS, you don’t have to sacrifice performance.

The snippets above demonstrate how even small enhancements make for a more intuitive UI. Want to go further? Check out our CodePen collection for more fantastic ideas.

The post 8 Outstanding eCommerce Microinteraction CSS & JavaScript Snippets appeared first on Speckyboy Design Magazine.

Advent of Functional PHP: Day 5

Advent of Functional PHP: Day 5

Submitted by Larry on 5 December 2021 - 9:23pm

After the last two days, Day 5 of Advent of Code is almost mundane in comparison. Today we're asked to read in the definition for a series of lines and compute how many times they intersect.

The process is much the same as the previous days: Parse the incoming data into some sort of data model, then run some computations on it. And both parts will consist primarily of `pipe()` operations, since we're really just shuffling data from one form to another.

Our input data looks like this (albeit with a much larger range of coordinates):

Continue reading this post on PeakD.

F3A

Package:
F3A
Summary:
PHP Web development framework like Laravel lite
Groups:
Design Patterns, Libraries, PHP 5
Author:
akeel
Description:
This package provides a PHP Web development framework like Laravel lite...

Read more at https://www.phpclasses.org/package/12311-PHP-PHP-Web-development-framework-like-Laravel-lite.html#2021-12-05-16:57:59

Advent of Functional PHP: Day 4

Advent of Functional PHP: Day 4

Submitted by Larry on 4 December 2021 - 7:41pm

Day 4 of Advent of Code has us playing bingo against a giant squid. (Don't ask; I don't understand it either.) More specifically, we want to take an input file that consists of a series of numbers that will get called, followed by a series of boards. We then need to compute which board will be the first to win, following the standard rules of bingo (although with no free space in the middle, the cheating squid...).

This sort of problem is inherently very stateful, and thus, frankly, not a good fit for functional code. It absolutely can be done in a functional way, but it's not the best fit. We're not interested in the best fit in this series, though, just how it could be done functional-style. So let's do it functional style just to say we did. Along the way we will really exercise the function composition concept, and show a few other tricks along the way.

Onwards!

Advent of Functional PHP: Day 3

Advent of Functional PHP: Day 3

Submitted by Larry on 4 December 2021 - 6:15pm

The third challenge in this year's Advent of Code is all about bit manipulation. We're asked to read in a series of binary numbers and interpret them in various entirely illogical ways as a form of diagnostics. (Incidentally, if you ever write a system that requires this kind of logic to debug its output, you're fired.)

In any case, we're given a file with a list of 12 digit binary numbers and asked to compute various values. In the first part, we are asked to find the most common bit (0 or 1) in each position, and the result is known as "gamma." Then we have to find the least common bit in each position, and the result is known as "epsilon." (I don't know why you would want to do this; it's all Greek to me.)

Powered by Gewgley