If Modern Apps Ran on macOS 9

https://theawesomer.com/photos/2021/12/modern_apps_on_macos_9_t.jpg

If Modern Apps Ran on macOS 9

Link

macOS X and its successors have been around since 2001, but those of us who used Apple’s computers in the 20th century remember even earlier versions of the operating system. Designer Michael Feeney imagines what it might have been like if today’s apps ran on the more primitive user interface of macOS 9.

The Awesomer

Laravel – Redirecting HTTP to HTTPS

https://www.jhanley.com/wp-content/uploads/2021/06/pexels-pixabay-33153-scaled.jpg

Introduction

Once you have an SSL certificate configured, the next step is to redirect unencrypted traffic. There are several methods of doing this. Within your application (Laravel), by the web server (Apache or Nginx) or by the frontend (load balancer). This article will redirect HTTP requests to HTTPS in Laravel using middleware.

If you are also deploying a frontend load balancer, configure both HTTP and HTTPS frontends. In most cases, you will forward traffic from the load balancer to the backend (Laravel) via HTTP and not by HTTPS. This is called SSL Offloading. This means your Laravel middleware must detect the protocol (HTTP or HTTPS) that the client connected to the load balancer and ignore the protocol that the load balancer is using to connect to the backend. Otherwise, the middleware will detect HTTP even if the client connected to the load balancer using HTTPS, and the client will go into a redirect loop.

In this article, I will use yourdomain.com. Replace with your domain name.

Laravel middleware only supports files served by routes. Files that are not served by Laravel, such as /js/app.js will NOT be redirected. This is one of the reasons I like to have HTTP Redirection as several layers (load balancer, web server, application framework). Another reason is to ensure that more than one service layer enforces HTTP Redirection.

Configure .env

This article supports two environments, development and production. The development settings will not redirect HTTP to HTTPS. The production environment will redirect. The environment will be detected by the APP_ENV setting.

Production Configuration:

  • APP_ENV=production
  • APP_DEBUG=false
  • APP_URL=https://yourdomain.com

Development Configuration:

  • APP_ENV=local
  • APP_DEBUG=true
  • APP_URL=http://localhost:8000

The application environment labels local and production are used to enable/disable certain features in Laravel.

Initial Testing

Open a web browser and connect to your site via HTTP: http://yourdomain.com. Verify that your site loads correctly, and you are not redirected to HTTPS. Note: some TLD domains such as .dev automatically redirect in browsers. If this is the case for you, use the curl command method below.

Open a command prompt and run this command:

curl I http://yourdomain.com

We are interested in the first part of the output which is the HTTP status code. If HTTP redirection is disabled, you should receive a 200 response:

For this article, we want a 200 response so that we can implement and test HTTP redirection.

If HTTP redirection is enabled, then you will receive a 3xx response with an HTTP Location header:

HTTP/1.1 302 Found

....

Location: https://yourdomain.com

Before continuing, disable redirects in your web server or frontend (load balancer). Save your changes, so that you can reenable redirection at the frontend or at the webserver.

Note: browsers tend to cache HTTP redirects. You might need to disable the browser cache.

Disable Chrome Cache

  • Open the Chrome Developer Tools (F12).
  • Go to the Network tab and make sure Disable cache is ticked.
  • Keep the Developer Tools open while testing.

Create the Middleware

Using artisan create the middleware template:

php artisan make:middleware HttpRedirect

This creates the file app/Http/Middleware/HttpRedirect.php.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<?php

 

namespace App\Http\Middleware;

 

use Closure;

use Illuminate\Http\Request;

 

class HttpRedirect

{

    /**

     * Handle an incoming request.

     *

     * @param  \Illuminate\Http\Request  $request

     * @param  \Closure  $next

     * @return mixed

     */

    public function handle(Request $request, Closure $next)

    {

        return $next($request);

    }

}

Near the top of the file add:

use Illuminate\Support\Facades\App;

Modify the function handle(). Note the following features:

  • Check if the request is using HTTP: !$request->secure()
  • Check if the environment is production: App::environment('production')
  • If both requirements are met, redirect the client to the same URI using HTTPS. Otherwise, proceed to the next handler.

    public function handle(Request $request, Closure $next)

    {

        if (!$request>secure() && App::environment(‘production’) {

                return redirect()>secure($request>getRequestUri());

        }

 

        return $next($request);

    }

The above redirect will return the HTTP code 302. For permanent HTTP to HTTPS redirects, return HTTP code 301 (permanent redirect):

return redirect()>secure($request>getRequestUri(), 301);

If you have development, staging and production environments and you want HTTP redirection for both staging and production:

    public function handle(Request $request, Closure $next)

    {

        if (!$request>secure() && App::environment([‘staging’, ‘production’])) {

                return redirect()>secure($request>getRequestUri(), 301);

        }

 

        return $next($request);

    }

Edit App/Http/Kernel.php and add the middleware to $middleware:

    protected $middleware = [

        ...

        \App\Http\Middleware\HttpRedirect::class,

Clear the configuration:

php artisan optimize:clear

Supporting Proxy Frontends

If you are using a load balancer that connects to your Laravel backend using HTTP, detect the HTTP header X-Forwarded-Proto. Use this code for the handle() function instead:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

    public function handle(Request $request, Closure $next)

    {

        // If the client connected to the frontend (load balancer) via https

        // redirection is not necessary

 

        if ($request>headers>has(‘X-Forwarded-Proto’)) {

            if (strcmp($request>header(‘X-Forwarded-Proto’), ‘https’) === 0) {

                return $next($request);

            }

        }

 

        if (!$request>secure() && App::environment([‘staging’, ‘production’])) {

                return redirect()>secure($request>getRequestUri(), 301);

        }

 

        return $next($request);

    }

Warning

If your Laravel application does not have a proxy (load balancer) accepting traffic, do not add the proxy code. A smart hacker could manually add the header X-Forwarded-Proto and bypass the HTTP Redirect feature.

If you allow your Laravel backend to be accessed from a load balancer and directly from the Internet, add logic to only process the X-Forwarded-Proto header if the request arrives from a known frontend. Google Cloud HTTP(S) Load Balancers use the 130.211.0.0/22 and 35.191.0.0/16 IP address ranges.

Additional Options

The above middleware will redirect requests that are handled by Laravel routes. I also recommend that Laravel always generate content using HTTPS based URLs. Examples are JavaScript and CSS references.

Edit app/Providers/AppServiceProvider.php

Near the top add:

use Illuminate\Support\Facades\App;

use URL;

Add the following code to the boot function:

    public function boot()

    {

        if (App::environment([‘staging’, ‘production’])) {

            URL::forceScheme(‘https’);

        }

    }

Summary

I prefer to implement multiple layers of security. When implementing HTTP Redirection, I try to implement this feature at each service layer. Starting with the backend (Laravel), then with the web server (Apache or Nginx), and finally at the load balancer. Sometimes mistakes are made, and one layer might disable HTTP Redirection. By enabling this feature in more than one service, I have a higher confidence level that clients’ data is and remains encrypted.

Photography Credits

I write free articles about technology. Recently, I learned about Pexels.com which provides free images. The image in this article is courtesy of Pixabay at Pexels.

I design software for enterprise-class systems and data centers. My background is 30+ years in storage (SCSI, FC, iSCSI, disk arrays, imaging) virtualization. 20+ years in identity, security, and forensics.

For the past 14+ years, I have been working in the cloud (AWS, Azure, Google, Alibaba, IBM, Oracle) designing hybrid and multi-cloud software solutions. I am an MVP/GDE with several.

Related Posts

Laravel News Links

3D Printing Advances and Innovative 3D-Printed Objects of 2021

https://s3files.core77.com/blog/images/1226899_81_111236_gTOoP6wNM.jpg

This year 3D printing continued its inexorable rise as a powerful, game-changing fabrication technique. Two areas were of interest to us: Pro-level advances achieved by corporations or universities, and the experiments, improved techniques and innovative objects produced by individuals or small teams.

Professional Advances

Argentinian manufacturer Trideo makes a 3D printer so large, it comes on wheels. Their Big T Has a build area of one square meter!

Stratasys wowed us with the bonkers 3D prints that their J8 Polyjet machines are capable of.

Also from Stratasys comes this VeroUltra 3D printing material, which offers crazy level of material realism, convincingly replicating wood, glass and even LED displays. Note that the sweaty bottle and label below were printed in a single shot.

This year we learned about Desktop Metal’s binder jetting, a 3D printing process that uses inkjet print heads to deposit a liquid binding agent onto a powder bed. It can be roughly 100 times faster than laser powder bed fusion systems (see side-by-side comparison below) and looks to be a gamechanger.

Desktop Metal subsidiary Forust is using binder jetting to 3D print wood from sawdust—pretty convincingly, at least in photos.

As for more affordable improvements, Mosaic Manufacturing’s Palette 3 Pro is a filament splicer that allows you to print up to eight colors with your existing single-nozzle 3D printer.

Researchers at USC created a mechanical bed for an FDM 3D printer that allows them to print without support structures.

By studying lobsters and crustaceans, Purdue University researchers discovered that 3D printing in spiral layers adds strength to structures, halting cracks and fractures.

Similarly, researchers at Australia’s RMIT University found that 3D printing concrete in different patterns also positively impacts the strength of a structure.

Moving closer to commercial construction, researchers at Spain’s Polytechnic University of Valencia (UPV) in Spain have developed a 3D-printed alternative to reinforced concrete beams, made from recycled plastic.

Researchers at Switzerland’s ETH Zürich, along with Zaha Hadid Architects, 3D printed concrete at specific angles to create a new type of bridge. The technique not only uses less material, but enables new types of forms.

As we mentioned in our 2021 roundup post of architecture, this year Habitat for Humanity started building their first 3D-printed houses.

Also this year, a company called Icon started selling "the first 3D-printed homes for sale in the U.S." in Austin, Texas.

Individual/Small Team Efforts

Here’s a handy tip: Stefan over at CNC Kitchen shows you how to make your 3D printer quieter for $2.

After a vintage design for a fractal vise went viral this year, product designer Christopher Borge figured out how to 3D print one.

Digital fabrication enthusiast MakerPaul designed and 3D printed an hourglass-like timer that notifies you when time’s up, and can be instantly reset.

Engineer Akaki Kuumeri brilliantly used 3D-printed flexures to improve an Xbox game controller.

ID student Charlie Ransford developed a 3D-printed turntable.

I know it’s silly, but Oodesign sells this amusing 3D-printed rubber-band-implementing insect cage.

In the name of science and space exploration, mechanical engineer Yuto Kuroki hacked a 3D printer to make sandwiches.

If you’re looking to make money selling self-designed items you can 3D print, you can be inspired by TreeHugger Systems’s smart, low-cost 3D-printed objects to make camping easier.

Lastly, here’s a free resource that should be useful for 2022 and beyond: The Scan the World Open Source Museum offers, for free, 17,000+ scans of famous artworks you can download and 3D print.

Core77

The Witcher’s Cast Talks Ciri and the New Witchers Who Help Her Grow

https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/fa8e4a45862755335e61e11785382f74.jpg

The second season of Netflix’s The Witcher brings a lot of good material with it, from the growing relationship between Geralt (Henry Cavill) and Ciri (Freya Allan) to Yennefer (Anya Chalotra) growing into her magical power. For Geralt and Ciri in particular, a lot of their relationship is rooted in him training her to become a Witcher at Kaer Morhen, a key location in the books and Geralt’s childhood home.

Netflix has been releasing a series of videos going into the development of Witcher’s sophomore season, and two specifically are focused on the remaining Witchers and Ciri’s character development. After spending the first season running from threat after threat, Allan was excited for Ciri to both “navigate what she wants,” and to finally be involved in the action.

“It’s very difficult to go straight into swordfighting routines,” Allan recalled. “So I had to do quite a bit of training.” When it came time to do actual stunt work, showrunner Lauren Schmidt Hissrich had glowing praise for Allan’s dedication, particularly when it came to the obstacle course at Kaer Morhen. “She couldn’t have loved it more…Watching Freya get knocked physically off of it so many times was pretty incredible and terrifying.”

Though Ciri wants to follow in the footsteps of her surrogate father, he’s not the only Witcher she spends time with throughout the season. Below, the second video shines a spotlight on the other Witchers: Eskel (Basil Eidenbenz), Coen (Yasen Atour), and Lambert (Paul Bullion). All three are fan favorites from the books and games, but they’re all arguably outclassed in terms of importance by Kim Bodnia’s Vesemir, Geralt’s own father figure who starred in the animated prequel Nightmare of the Wolf. Vesemir has been leading the remaining Witchers since the events of the film, and Allan says that over the course of the season, Ciri comes to respect him as much as Geralt does.

Every winter, the remaining Witchers go to Kaer Morhen because it’s where they “feel rooted as a family,” in the words of Paul Billion, who plays Lambert, . The scarcity of their ranks have only made their bonds with each other grow stronger, something you see throughout the season as they help train Ciri and fight monsters together. “It’s about family and exploring what family means,” Bullion continued. “It’s what the Witchers represent.”

G/O Media may get a commission

The family bond is something fans have wanted to see in the show for some time, but the new season has thrown a curve ball that not all are happy with, and have left fans demanding answers.

When Geralt and Ciri arrive at Kaer Morhen in the second episode, the reunion turns grim when it’s revealed that Eskel was infected by a leshen while hunting it down. He’s then killed by Geralt, something that very much doesn’t happen in the books. Speaking on the show’s podcast on YouTube, Schmidt Hissrich discussed how the process of Eskel’s grim fate came to be. They’d known how they always wanted to kill someone, and it was important to make sure it had something to do with Ciri. Regardless of who died, that death had to to force Geralt and the other Witchers to realize her presence here would change things.

Originally, that death was going to be for a brand new character she called “John.” But that death wouldn’t have mattered, so it was changed to Eskel as to really have an affect on Geralt and spur him to truly train Ciri. “I know that there are fans who love Eskel and who feel like, why would we do that?…But honestly, his death is what changes everything for Geralt.” Part of the desire to kill off Eskel and more Witchers was also to drive home the idea of the Witchers being caught up in a constantly changing world. “So much of season two is about the fact of, ‘Is the Witcher brotherhood over?’…Of course we had to kill more.”

Despite how bleak things are for the organization, Schmidt Hissrich believes that Vesemir still has some hope for the future. “There’s this history in Vesemir, he’s the keeper of Witcher history…When Ciri and Vesemir are walking through the Kaer Morhen lab, we hear his retelling of the deaths of the Witchers, and suddenly why he thinks Ciri could be their savior. It’s that type of optimism that’s really important to Vesemir.”

The Witcher season two is out now on Netflix.

Gizmodo

Using the new `afterRefreshingDatabase` test method

https://downing.tech/storage/wink/images/B9M6RvU12M6VJLYsU7jzZodFDJbn5OjPpo0oIu7A.png

In Laravel 8.76, support for a new `afterRefreshingDatabase` method in tests was added. Want to know when and where to use it? Read on!

A while back, I PR’d a LazilyRefreshDatabase trait to the Laravel Framework. This came from the annoyance of having to manually include RefreshDatabase in each test, unless you wanted to suffer a performance penalty. It was very well received. So well, in fact, that it almost became the default way of refreshing your test database in new Laravel projects. Almost, until it was revealed there was a catch.

For most projects, LazilyRefreshDatabase would work without issue. I had several projects that were updated and running in less than 5 minutes. But on other projects, that wasn’t quite the case.

As an example, take the TestCase from the in-progress PestPHP news site: https://github.com/pestphp/news.pestphp.com/blob/main/tests/TestCase.php. We have a non-standard migration strategy here: before each test, we need to ask Laravel to also migrate Wink’s migration files, then run a seeder.

This would cause a real problem for LazilyRefreshDatabase. Why? Basically, if we did it in the setUp method, we would be completely negating any benefits provided by the LazilyRefreshDatabase trait, because the database would go back to being refreshed after every test. What if instead we use a listener that fires after database migration is complete, like so?

public function setUp()

{

parent::setUp();

 

Event::listen(MigrationsEnded::class, function () {

$this->artisan('migrate', [

'--path' => 'vendor/themsaid/wink/src/Migrations',

]);

});

}

Well, this seems like a good idea, until you run it. What we’ve actually caused here is an endless loop, because the Wink artisan command will cause the MigrationsEnded event to fire again. Not good. Not good at all.

What we actually need is a hook. A hook that will fire after the database has refreshed. A hook that doesn’t care whether you’re using RefreshDatabase or LazilyRefreshDatabase, but rather just works.

That’s exactly what the new afterRefreshingDatabase method does. It will fire once the database has been refreshed (as the name implies), and gives you the perfect location to drop any test setup code like this. By using this method, we keep all of the benefits of lazily refreshing our database whilst allowing for pretty much any database setup, whether that’s additional migrations, seeding or something else, that is required.

public function afterRefreshingDatabase()

{

$this->artisan('migrate', [

'--path' => 'vendor/themsaid/wink/src/Migrations',

]);

}

I have to give a shoutout to Aaron Francis here, who inspired me to write this PR after this conversation on Twitter: https://twitter.com/aarondfrancis/status/1469331525422489604?s=20.

So, now you know why and how to use afterRefreshingDatabase in your Laravel tests. Since adding this method to the Laravel Framework, I’ve been able to adopt LazilyRefreshDatabase in all of my projects without any issues!

Kind Regards,

Luke

Laravel News Links

Breaking: God Is With Us

https://media.babylonbee.com/articles/article-10179-1.jpg

BETHLEHEM—According to sources, the eternal Word of God has become flesh in the form of a newborn baby who was born this morning.

Some claim that this child is the human incarnation of the God of the Universe, who has come to reconcile a broken creation with its holy Creator, saving a wayward human race in a heroic rescue echoed in myths, legends, prophecies, and whispered hopes since the dawn of time. 

If true, then God is with us, and things will never be the same again.


The Babylon Bee

[Video] Behind the Scenes: Remington Ammo Factory

https://www.pewpewtactical.com/wp-content/uploads/2021/12/1.-Remington-Factory-Ammo.jpg

Today we’re taking a behind-the-scenes look at one of the oldest American names in firearms, Remington.

Recently the Pew Pew Crew were invited to tour their manufacturing facility.

This “How It’s Made” peek is cool in its own right, but this is also a comeback story – how Big Green got its groove back.

I think this is 120,000 rounds of 9mm, ready to go.

So follow along as we take a tour of Remington and see the processes behind ammo manufacturing.

Of course, if you want to see it in action, you can check out the video below.

As always, be sure to head over to Pew Pew Tactical’s YouTube channel for more guns and gear.

Table of Contents

Loading…

A Quick History

You may recall Remington filed for bankruptcy in 2018 then quickly remerged after restructuring.

But the 200-year-old firearms giant filed once again in 2020,r resulting in a bankruptcy court parting and selling the company.

remington arms factory
Remington Arms

The firearms component was bought by Roundhill Group LLC and rebranded as RemArms.

On the other hand, the ammunition side of things was purchased by Vista Outdoor. It’s here in the wooded plains outside Lonoke Arkansas, that our tale begins.

We met a lot of great folks as we toured the facility but were reminded that it’s still a working factory.

I tucked my hair under my hat, kept my hands to myself, and we headed into the 2A equivalent of the Wonka Chocolate Factory.

No Wonkavator, but the elevator in the shot tower was cool.

The Remington grounds sprawled across 1,200 acres and contained multiple sites for building, testing, and even enjoying their products.

The Book of Eli

We learned a lot. Led by our guide Joel, we started in a building called Eli which was named for Eliphalet Remington who founded the company in 1816.

This awesome building was currently assigned to mass-producing 9mm and the machines were whirring away as we toured.

Casings, before primers and bullets.

We saw machines that handled giant coils of brass weighing 4,000 pounds.

The material was stretched, pressed, and snipped into shell casings. Then, different parts of the process added the actual bullet and primer on either end.

At a bullet maker, we spoke with Adam the plant manager who was dealing with a mechanical issue.

The giant clutch for the machine was broken down and only made in Canada.

Here, bullets are installed in the cases.

The techs they needed to work with only spoke French, a graphic example of some of the challenges faced when making ammunition.

Joel explained how coming under the Vista brand has improved things.

Working with sister agencies like Federal, the various ammo manufacturers benefit from cross-pollination — seeing how they can do things better or more efficiently.

Vista inherited some major issues when they took over but their efforts are paying dividends.

Promptly righting the ship, they worked on facility issues and brought bankruptcy furloughed employees back in time for Christmas so they’d have benefits.

The vaunted 8-gauge.

Newly helmed, Remington continued in that trend, hiring 20 people a week, and building up to three shifts in some areas to run the production 24/7 in an effort to match demand.

A month before our visit, Remington shipped out more ammunition than they had in the past five years combined!

Joel estimated their output in the billions of rounds per year.

The view from the shot tower.

And the company is still growing. The Eli building is slated for a skunkworks addition — a section dedicated strictly to R&D, hinting at some exciting developments.

Shotshell

We toured the area where shotgun shells come to life.

Seeing long tubes of plastic heated, stretched, then cooled in tanks of water and snipped to length offered a fascinating look into the process.

Above all, the shot tower was a highlight. Some 12 stories up, a giant furnace exists strictly to melt lead into molten metal.

It gets hot in the tower with the furnace making shot.

This metal then pours out through filters that form the basic size of the shot. As it drops, it cools. Then it’s collected at the bottom.

We didn’t see this running live because of the heat and risk, but there was plenty of evidence of it running everywhere we looked. Carts, hoppers, and bins of shot were everywhere.

Rimfire

We moved onto rimfire, where Remington steadily churns out rounds.

As I think about it, even during the heightened demand, I never saw a lack of .22 LR or shotgun shells on the shelves in stores.

I would love to show up at the range with one of these hoppers of .22 LR.

This process, like the rest, was really cool. Primers are a whole different situation since they are inclusive to the case.

One of the greatest parts was just seeing enormous amounts of .22 in giant hoppers that probably weight hundreds of pounds.

At several points during this trip, I found myself wondering how long it would take me to shoot various piles of ammo I encountered.

Testing, testing…

One of the cooler stops was down in the underground testing facility where workers indiscriminately test batches of ammo.

They actually pull a sample off the assembly line, load it into a test chamber, and fire it.

Testing apparatus.

Jimmy explained these tests examine the function, pressure, velocity, and accuracy of everything Remington makes.

Just as important, they test for real-world scenarios — freezing and heating ammunition to simulate actual scenarios shooters might face.

Shot “filters”

Most noteworthy was the armory at Jimmy’s fingertips, just about one of everything you could imagine!

With the tour of the facility complete, we headed out to a couple of different ranges where we shot — centerfire rifle out to 200 yards, followed by 9mm through Glocks.

No complaints here.

We also shot rimfire, rifle, and pistol, sampling a good deal of the quality products Remington offers.

Finally, we moved on to a sporting clays course. I shot skeet and trap a little, but never anything this cool.

Giant bars of metal are staged outside the furnace.

The course was as fun as it was humbling and greatly demonstrated an area where I needed a lot of practice.

Conclusion

By the end of the trip, I could appreciate how far Big Green had come. In 2020, the company faced another bankruptcy.

But now, the ammo giant has recovered and is increasing production.

From what we could tell, production was full steam ahead.

Top that off with an intense quality control program and an investment in the future with research and development.

In many ways, Remington benefitted from its separation from the firearms manufacturer of the same name. Now they have their own budget, own direction, and vision.

Coupled with the proven know-how of Vista Outdoors, this American icon is working toward a brighter future.

For a look into the factory, see the video below.

What do you think of Remington? Let us know in the comments below. Still struggling to find ammunition? Check out our guide for the Best Online Places to Buy Ammo.

The post [Video] Behind the Scenes: Remington Ammo Factory appeared first on Pew Pew Tactical.

Pew Pew Tactical