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
This lady’s troll of that Aussie breakdancer is perfect. Come for the video, stay for the memes 👨‍🍳🤌
https://media.notthebee.com/articles/66ba492c5c88f66ba492c5c890.jpg
If you missed the Australian breakdancer lady from the Olympics, well, I hope the rock you’re living under is comfortable.
Not the Bee
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
MySQL Performance Monitoring Tools and the Most Important Metrics to Monitor
This article covers some of the most popular MySQL performance monitoring tools alongside the key performance metrics that can help improve and optimize query performance in MySQL databases.
The post MySQL Performance Monitoring Tools and the Most Important Metrics to Monitor appeared first on Devart Blog.
Planet MySQL
Ladies and gentlemen, may I present the most “CNN” segment of all time
https://media.notthebee.com/articles/66b21c3bd1ef266b21c3bd1ef3.jpg
This is the most CNN thing you’ll see today. The network decided they needed to do a little research to debunk the emerging idea that black people don’t like Kamala Harris – or at least, they don’t see her as one of them.
Not the Bee
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
Copy Data Directly To A MySQL Instance With MySQL Shell
MySQL Shell offer many features to make life easier for DBAs and developers. In this post we discuss how we can copy data from one MySQL instance directly to another.Planet MySQL
Why CleanMyMac X Is a Safe Tool and a Must-Have for Your Mac Maintenance Needs
https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2024/07/cleanmymac-x.png
This article is sponsored by CleanMyMac X. Product choices and opinions expressed are from the sponsor and do not reflect the views of MakeUseOf editorial staff.
If the name CleanMyMac X sounds familiar, it’s probably because this handy software application has been around for 16 years and has been downloaded more than 30 million times. This multi-functional app will clean up junk and other files that are cluttering up your hard drive, monitor performance, and remove malware, leaving your Mac performing like it did when you first bought it.
Plus, its ultra-convenient Menu App gives you complete oversight as to what’s happening on your Mac and where the problems are.
When your Mac is running slowly, the first piece of advice is always the same: clean up your files! Further to a simple file cleanup, CleanMyMac X runs many more diagnostics and checks to bring your speed and overall performance up to par.
CleanMyMacX
CleanMyMac X is all-in-one package to enhance the speed and performance of your Mac. It cleans megatons of junk and makes your computer run faster. Just like it did on day one.
If you’ve never cleaned up your Mac before, chances are you’re running at a much slower speed due to outdated caches, broken downloads, and gigabytes of other useless or hidden files. So before you go trading in your Mac for something newer, give it a good deep clean to reveal its true performance capabilities.
The beauty of CleanMyMac X lies in its simplicity: clicking the one-button Smart Scan is all it takes to launch the newly updated scanning algorithm and get your computer running more efficiently in under a minute. Read on to find out more about what CleanMyMac X can do and learn about the cutting-edge tech brand that built it.
MacPaw Is a Long-Time Trusted Software Brand
Tech brand MacPaw has been on a mission to create user-empowering software that simplifies people’s lives. The company released the original CleanMyMac in 2008 as a simple solution to help Mac users declutter and get their machines running quicker and smoother.
Since its inception, CleanMyMac has launched a Version 2, Version 3, and finally its fourth version, CleanMyMac X, its most optimized and comprehensive cleanup, protection, and high-speed tool yet.
The most exciting advantages of the CleanMyMac X software are:
- Smart Scan all-in-one center
- CleanMyMac Assistant intelligent helper
- Malware removal
- Updater for your installed apps
- Reinvented menu with internet speed check, available Dropbox space, and control for resource-consuming apps
- Leading-edge visual design
Reliable Software From an Award-Winning Innovator
Throughout its 16 years of innovating, MacPaw has grown into an internationally recognized, award-winning brand—this includes two Red Dot Awards and an iF Design Award for CleanMyMac product design.
How CleanMyMac Keeps your Apple Computer in Prime Condition
CleanMyMac X is a safe tool for maintaining and optimizing your Mac’s performance. If you think your Mac might need some tuning up, consider this: the average CleanMyMac X user cleaned 47 GB of junk, removed 4 unneeded apps, and neutralized 3 malware threats. Keep reading to find out how the app takes your Mac from sluggish and cluttered to quick and clean.
Clean Up Your files
The main feature of the CleanMyMac X app is the intuitive Smart Scan function, which is the starting point for optimizing your Mac’s speed and performance. Once you click “Scan,” the algorithm will automatically do a deep dive to find useless files and junk that you can then choose to keep or delete from the summary of found items.
The System Junk feature helps you target non-essential files—including duplicate mail attachments, automatically generated system junk, and deleted files—that can all be removed to free up space and improve overall performance.
Let the Assistant Help You Along the Way
The CleanMyMac X Assistant is always ready to give tips on how to use the app more effectively—such as further cleanup, reminders about incomplete operations, and steps to enhance your Mac’s security.
Protect Your Mac
Sometimes malicious files can be tough to locate, but the Malware Removal module, powered by Moonlock engine, targets vulnerabilities from unwanted adware, viruses, spyware, and cryptocurrency miners.
The Privacy module can completely wipe any trace of all unwanted activity. Want to delete all of your browsing history in one go? Done. Need to get rid of all your random downloads? Easy.
Enhance Your Speed
The CleanMyMac X Speed Optimization feature helps you increase your Mac’s output by identifying the sources that could be slowing you down.
Within the Speed module, you can also perform regular diagnostic check-ups, including repairing disk permission and verifying the start-up disk, which can both help to keep your Mac optimized.
Take Control of Your Applications
Did you know that even after you delete an app, remnants of it can remain on your computer? The updated Uninstaller module removes applications wholly and deletes parts that have been left behind, plus it can identify potentially harmful apps with the new Suspicious Apps category.
The Updater helps you to ensure that all of your current applications are kept up-to-date, and includes convenient descriptions of any changes.
Manage Your Storage Space
Sometimes you know that you’re running low on space, but it can be hard to pinpoint the culprits. The innovative Space Lens is a space-management module that visualizes everything in your folders, displaying them as bubbles of various sizes. From there you can review this detailed storage map and decide what stays and what can go.
More Features to Enhance Your Mac Experience
The all-new Menu App provides more oversight of how your Mac is performing with six detailed monitors: storage, protection, CPU performance, memory, battery, and connected devices. In the Connected Devices module, you can even safely eject all devices individually or all at once.
Each of the above monitoring categories breaks out into its own detailed view:
- Connected Devices: Get an instant view of anything connected to your Mac via WiFi, Bluetooth, or cable.
- Protection Monitoring: Visualize threats and get ideas on how to protect your Mac from malware.
- CPU Performance: Keep an eye on your CPU load, see a list of top-consuming apps, and monitor for unusual activity spikes.
- Memory: See what’s happening with your RAM and which apps are taking up space.
- Storage: Keep track of available storage, temperature, and condition of your drive.
- Battery: Monitor the overall health of your battery, including how long it takes for one full charge.
Is CleanMyMac Legit?
CleanMyMac X is a widely used and completely safe software application for your Mac. CleanMyMac X is notarized by Apple, which guarantees that the app is free from malicious components and safe for distribution. It is also available on the Mac App Store, boasting an impressive 4.6 stars out of 5, with 9,900 reviews.
Besides, Apple regularly features and adds CleanMyMac to its app collections lists on MAS: Featured app: CleanMyMac X, optimize your Mac, Tidy up your Mac : App Store Story, Apps optimized for M1 Macs.
How to Get CleanMyMac X Today
CleanMyMac X is available starting at $97.61 as a one-time purchase or starting at $41.79 for a one-year subscription, depending on your needs. It can also be bundled for more savings when you buy CleanMyMac X for two Macs or for five Macs.
Don’t let your Mac maintenance take a back seat: take control of your Mac’s storage, speed, performance, and security. If you’re still unsure, you can get a free, seven-day trial of CleanMyMac X with instant activation and cancellation at any time. Thirty million downloads can’t be wrong!
MakeUseOf
Laravel 11 JSON Web Token(JWT) API Authentication Tutorial
https://www.itsolutionstuff.com/upload/laravel-11-jwt-authentication.png
In this post, I will show you how to API Authentication using JWT token in laravel 11 application. We will learn from scratch about APIs, JWT REST APIs, and Laravel JWT Authentication, and create an example API as well.
What is API?
An API (application programming interface) is simply a way of communication between two or more computer programs.
APIs are also used for web and mobile application development; therefore, building a REST API is very essential for any web and mobile application developer.
What is JWT?
JWT stands for JSON Web Token, it is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. JWT is commonly used for Authorization, Information Exchange, etc.
In this example, we will install the Laravel 11 application. Then, we will install the api. Then we will use php-open-source-saver/jwt-auth package to use JWT. After that, we will create register, login, refresh, profile, and logout APIs for user authentication. So, let’s follow the steps below to complete this example step by step:
Step for Laravel 11 JWT Authentication API Tutorial
- Step 1: Install Laravel 11
- Step 2: Enable API and Update Authentication Exception
- Step 3: Install and Setup JWT Auth package
- Step 4: Update User Model
- Step 5: Create API Routes
- Step 6: Create Controller Files
- Run Laravel App
Follow the below few steps to create a restful API example in the laravel 11 app.
Step 1: Install Laravel 11
This step is not required; however, if you have not created the Laravel app, then you may go ahead and execute the below command:
composer create-project laravel/laravel example-app
Step 2: Enable API and Update Authentication Exception
By default, laravel 11 API route is not enabled in laravel 11. We will enable the API using the following command:
php artisan install:api
Now, if user is not authenticate then exception will call and we will return json response. so, let’s update app.php file.
bootstrap/app.php
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Http\Request;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
$exceptions->render(function (AuthenticationException $e, Request $request) {
if ($request->is('api/*')) {
return response()->json([
'message' => $e->getMessage(),
], 401);
}
});
})->create();
Step 3: Install and Setup JWT Auth package
In this step, we will install php-open-source-saver/jwt-auth composer package.
composer require php-open-source-saver/jwt-auth
now, publish the package config file:
php artisan vendor:publish --provider="PHPOpenSourceSaver\JWTAuth\Providers\LaravelServiceProvider"
Next, generate a secret key. This will add JWT config values on .env file:
php artisan jwt:secret
now, we will update auth guard config file.
config/auth.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
],
...
Step 4: Update User Model
In the model, we implement first the Tymon\JWTAuth\Contracts\JWTSubject contract on the User Model and implement the getJWTIdentifier() and getJWTCustomClaims() methods.
app/Models/User.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
}
Step 5: Create API Routes
In this step, we will create API routes. Laravel provides the api.php file for writing web service routes. So, let’s add a new route to that file.
routes/api.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\API\AuthController;
Route::group([
'middleware' => 'api',
'prefix' => 'auth'
], function ($router) {
Route::post('/register', [AuthController::class, 'register']);
Route::post('/login', [AuthController::class, 'login']);
Route::post('/logout', [AuthController::class, 'logout'])->middleware('auth:api');
Route::post('/refresh', [AuthController::class, 'refresh'])->middleware('auth:api');
Route::post('/profile', [AuthController::class, 'profile'])->middleware('auth:api');
});
Step 6: Create Controller Files
In the next step, we’ve created a new controller called BaseController and AuthController. I created a new folder named "API" in the Controllers folder because we’ll have separate controllers for APIs. So, let’s create both controllers:
app/Http/Controllers/API/BaseController.php
<?php
namespace App\Http\Controllers\API;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller as Controller;
class BaseController extends Controller
{
/**
* success response method.
*
* @return \Illuminate\Http\Response
*/
public function sendResponse($result, $message)
{
$response = [
'success' => true,
'data' => $result,
'message' => $message,
];
return response()->json($response, 200);
}
/**
* return error response.
*
* @return \Illuminate\Http\Response
*/
public function sendError($error, $errorMessages = [], $code = 404)
{
$response = [
'success' => false,
'message' => $error,
];
if(!empty($errorMessages)){
$response['data'] = $errorMessages;
}
return response()->json($response, $code);
}
}
app/Http/Controllers/API/AuthController.php
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\API\BaseController as BaseController;
use App\Models\User;
use Validator;
use Illuminate\Http\Request;
class AuthController extends BaseController
{
/**
* Register a User.
*
* @return \Illuminate\Http\JsonResponse
*/
public function register(Request $request) {
$validator = Validator::make($request->all(), [
'name' => 'required',
'email' => 'required|email',
'password' => 'required',
'c_password' => 'required|same:password',
]);
if($validator->fails()){
return $this->sendError('Validation Error.', $validator->errors());
}
$input = $request->all();
$input['password'] = bcrypt($input['password']);
$user = User::create($input);
$success['user'] = $user;
return $this->sendResponse($success, 'User register successfully.');
}
/**
* Get a JWT via given credentials.
*
* @return \Illuminate\Http\JsonResponse
*/
public function login()
{
$credentials = request(['email', 'password']);
if (! $token = auth()->attempt($credentials)) {
return $this->sendError('Unauthorised.', ['error'=>'Unauthorised']);
}
$success = $this->respondWithToken($token);
return $this->sendResponse($success, 'User login successfully.');
}
/**
* Get the authenticated User.
*
* @return \Illuminate\Http\JsonResponse
*/
public function profile()
{
$success = auth()->user();
return $this->sendResponse($success, 'Refresh token return successfully.');
}
/**
* Log the user out (Invalidate the token).
*
* @return \Illuminate\Http\JsonResponse
*/
public function logout()
{
auth()->logout();
return $this->sendResponse([], 'Successfully logged out.');
}
/**
* Refresh a token.
*
* @return \Illuminate\Http\JsonResponse
*/
public function refresh()
{
$success = $this->respondWithToken(auth()->refresh());
return $this->sendResponse($success, 'Refresh token return successfully.');
}
/**
* Get the token array structure.
*
* @param string $token
*
* @return \Illuminate\Http\JsonResponse
*/
protected function respondWithToken($token)
{
return [
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth()->factory()->getTTL() * 60
];
}
}
Run Laravel App:
All the required steps have been done, now you have to type the given below command and hit enter to run the Laravel app:
php artisan serve
make sure in details api we will use following headers as listed bellow:
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$accessToken,
]
Here is Routes URL with Verb:
Now simply you can run above listed url like as bellow screen shot:
1) Register API: Verb:POST, URL:http://localhost:8000/api/auth/register
2) Login API: Verb:POST, URL:http://localhost:8000/api/auth/login
3) Profile API: Verb:POST, URL:http://localhost:8000/api/auth/profile
4) Refresh API: Verb:POST, URL:http://localhost:8000/api/auth/refresh
5) Logout API: Verb:POST, URL:http://localhost:8000/api/auth/logout
Output:
You can download code from git: Download Code from Github
I hope it can help you…
Laravel News Links
Ohio residents can now add driver’s license, state ID to the iPhone Wallet app
https://photos5.appleinsider.com/gallery/47606-92947-000-lead-Arizona-xl.jpgOhio officially becomes the fifth state to support driver’s licenses and State IDs stored on the iPhone and Apple Watch via the Apple Wallet app.
In 2020, Apple announced plans to allow iPhone owners to add their passport, driver’s license, and state ID to the iPhone. Four years later, only a handful of states have adopted the feature.
Spotted by 9to5mac, Ohioans can now add their driver’s license or state ID to their iPhone or Apple Watch. This allows them to pass through select Transportation Security Administration (TSA) checkpoints faster and more securely. Currently, the Wallet-stored IDs can be used at the following airports:
- Baltimore/Washington International Thurgood Marshall Airport (BWI)
AppleInsider News