How to Tie a Lasso

https://content.artofmanliness.com/uploads/2024/08/Tie-a-Lasso-2.jpg

What man hasn’t imagined what it would be like to be a cowboy on the open range?

And when you think about being a cowboy, you probably imagine yourself swinging a lasso above your head to round up wayward dogies

The lasso, or lariat, that we know today originated with Mexican vaqueros back in the 18th and 19th centuries. In the fluid social world of the American West, American cowboys picked up the lasso from their Mexican counterparts to aid them in their own cow punching.

North America isn’t the only place where the lasso has been used. Ancient Egyptians and Mongolians used lassos to herd animals, and ancient Persian warriors employed them in battle.

Yes, the lasso is indeed a manly implement. And today we’re going to show you how to tie one.

At the heart of every lasso is the honda knot. It’s a knot that creates a small, secure loop through which you pass the rope in order to create a large loop that can be tightened and loosened easily.

The rope you use for lassos needs to be a bit stiff so that the loop maintains its shape when you throw it. Traditionally, lassos were made with stiff rawhide or manila rope (check out our article on rope material!). Today, cowboys use nylon or polyester ropes which offer great durability.

Follow our illustrated guide and soon you’ll be ready to hit the Lonesome Dove trail with Gus and Woodrow.

Help support independent publishing. Make a donation to The Art of Manliness! Thanks for the support!

The Art of Manliness

Block Known Spam IPs from Your Laravel App with the Abuse IP Package

https://picperf.io/https://laravelnews.s3.amazonaws.com/featured-images/laravel-abuse-ip-featured.png

Block Known Spam IPs from Your Laravel App with the Abuse IP Package

The Laravel Abuse IP community package by Rahul Alam adds a layer of protection to your Laravel application from known spam IPs. This package provides an Artisan command to keep your IP list in sync with the Aggregated AbuseIPDB blocklist and middleware to check requests against the list.

To start using this package, you need sync the blocklist file of IPs. If you run your application on multiple servers, your storage drive will need to be centralized, or you’ll need to sync and store the IP list data on each server.

Next, the package’s AbuseIp middleware will check requests against the block list to prevent IPs on the list from accessing your application. To configure this middleware, you can add it to your Laravel project’s bootstrap/app.php file or add it to routes directly as desired:

->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\App\Http\Middleware\AbuseIp::class);
});

// Or via an individual route (or group of routes)
Route::middleware(AbuseIp::class)->get('/', function () {
    return view('welcome');
});

The AbuseIPDB list is updated multiple times a day, so you’ll also want to schedule an update to the blocklist (which is then cached) to run daily:

$schedule->command('abuseip:update')->daily();

You are free to update the source of the IP blocklist via the package’s configuration. You can learn more about this package, get full installation instructions, and view the source code on GitHub.


The post Block Known Spam IPs from Your Laravel App with the Abuse IP Package appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest
Laravel articles like this directly in your inbox.

Laravel News

DIY PVC Slingbow

https://theawesomer.com/photos/2024/08/diy_pvc_slingbow_t.jpgMaker Lis X has created some interesting weapons using unconventional materials. He used PVC tubing to build the frame for this unique slingbow and provided step-by-step directions so you can make your own. It’s designed to fire arrows and has a sturdy handgrip underneath for stability and aiming accuracy. Here’s another video showing it in […]The Awesomer

Rebel Ridge (Trailer)

https://theawesomer.com/photos/2024/08/rebel_ridge_trailer_t.jpg(PG-13: Language) A man on his way to post bail for his cousin is assaulted and robbed by the local police themselves. Unfortunately for the crooked cops, their “victim” is a former Marine, and they’re about to reenact Rambo. Writer and director Jeremy Saulnier may have cooked a sleeper in this thrilling action flick. Premieres […]The Awesomer

Request fingerprints and how to use them in Laravel

https://www.amitmerchant.com/cdn/request-fingerprinting-and-how-to-use-it-in-laravel.png

A fingerprint, in general, refers to a unique pattern or characteristic that can be used to identify an individual or an object. This concept is widely used in various fields.

For instance, to uniquely identify a human, the unique patterns of ridges and valleys found on the surface of human fingers or DNA sequences are used.

Similarly, in web applications, the unique patterns of the HTTP requests made by a user can be used to uniquely identify them.

A request fingerprint can be formed by hashing various values of the request, such as the URL, IP address, user agent, and other parameters. The hashed values can then be used to identify the web request.

This can be useful in various scenarios, such as:

  • Tracking: Track individual requests for debugging or monitoring purposes.
  • Logging: Enhance logging by including unique request identifiers, making it easier to trace specific requests in logs.
  • Caching: Create unique cache entries for requests, preventing conflicts and ensuring that the correct data is served for each unique request.
  • Debugging: Identify and debug specific requests more efficiently.

So, let’s learn about you can use fingerprints in Laravel.

Request fingerprinting in Laravel

Laravel comes with a built-in but undocumented method called fingerprint that can be used to generate a unique identifier for a request.

$fingerprint = request()->fingerprint();

// cf3fcc20ae756f4d5a3e1f48a91e722ed93345ca

Here’s what the definition of the fingerprint method in Laravel’s source code looks like.

/**
* Get a unique fingerprint for the request / route / IP address.
*
* @return string
*
* @throws \RuntimeException
*/
public function fingerprint()
{
    if (! $route = $this->route()) {
        throw new RuntimeException('Unable to generate fingerprint. Route unavailable.');
    }

    return sha1(implode('|', array_merge(
        $route->methods(),
        [$route->getDomain(), $route->uri(), $this->ip()]
    )));
}

As you can tell, the method uses things like the request’s IP address, the route’s domain, and the route’s URI to generate a unique identifier for the request. So, the fingerprint for a request will be unique for each request, regardless of the parameters or headers sent with the request.

Usage of the request fingerprints

The generated fingerprint can be used as a part of your cache key to ensure unique cache entries per request should you wish to cache the response.

$fingerprint = request()->fingerprint();

$cacheKey = 'response_' . $fingerprint;
$response = Cache::remember($cacheKey, 60, function () {
    // Generate the response
});

Apart from this, the fingerprint can also be used for logging, debugging, and tracking purposes. For instance, you can use it as a part of the log message to identify the request uniquely.

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
    public function report(Throwable $exception)
    {
        $fingerprint = request()->fingerprint();
        \Log::error('Exception occurred', [
            'fingerprint' => $fingerprint,
            'exception' => $exception
        ]);
        
        parent::report($exception);
    }
}

Here’s how a log message generated by the above code looks like.

[2024-07-20 12:34:56] local.INFO: Request Fingerprint: 123e4567-e89b-12d3-a456-426614174000 {"url":"http://example.com/api/resource"}
[2024-07-20 12:34:57] local.INFO: Handling request in index method {"fingerprint":"123e4567-e89b-12d3-a456-426614174000"}
[2024-07-20 12:34:58] local.ERROR: Exception occurred {"fingerprint":"123e4567-e89b-12d3-a456-426614174000","exception":"[object] (Exception(code: 0): Example exception at /path/to/file.php:123)"} 

In closing

Incorporating request fingerprints in Laravel enhances debugging and request management by providing unique identifiers for each request.

This enables easy traceability, isolation of issues, and detailed context for debugging. By generating and logging these fingerprints, you can efficiently track and debug requests, improving the overall reliability and maintainability of your application.

Laravel News Links