Ted Lasso returns to promote Hannah Waddingham’s special

https://photos5.appleinsider.com/gallery/57420-116906-000-lead-Waddingham-promo-xl.jpgTed Lasso — or at least star Jason Sudeikis — is back in a new role as taxi driver to Hannah Waddingham, ahead of her Apple TV+ Christmas special.

Jason Sudeikis (left) and Hannah Waddingham (right)Jason Sudeikis (left) and Hannah Waddingham (right)

"Ted Lasso" was the first breakout hit for Apple TV+, and when it officially concluded after three seasons, its stars including co-creator Jason Sudeikis have both hoped and hinted at a future return for the character.

Read more…AppleInsider News

Tiny House in an Old Airplane

https://theawesomer.com/photos/2023/11/airplane_tiny_house_t.jpg

Tiny House in an Old Airplane

Link

Unless you score Business Class seats, it’s pretty hard to sleep on an airplane. That is, unless it’s this old Douglas DC-6 that’s been converted into a home. Tiny House Giant Journey visits with homeowners and flight trainers Jon and Stephanie, who turned the airplane into a 2 BR, 1 BA Airbnb with a kitchen, a wing deck, and a flight simulator in the cockpit.

The Awesomer

How to use the OpenAI Assistants API in Laravel

https://gehri.dev/images/blog/pestdocs-header.png

Code example

In this tutorial we are going to build a Laravel application using the new OpenAI Assistants API.
The goal of the application is to build a tool which answers questions about the Pest Testing framework based on the current state of the Pest documentation.

One of the benefits of using the Assistants API is that you can provide data which is then used by the AI. This way we can provide the latest version of the documentation instead of only using the outdated knowledge of the base model.

To achieve our goal we are going to use the OpenAI PHP Client for Laravel developed by me and Nuno Maduro.
If you are using any other PHP framework you can use the underlying OpenAI PHP Client directly.

All the source for this tutorial is available at GitHub.

API overview / what to do

If you are not familiar with the Assistants API yet, here is a brief overview of the API and what we need to do in order to achieve our goal.

The basic structur of the Assistants API is as follows:

  • Assistants are the main resource. There we can attach files and tools the AI can use to answer questions. In our case we are going to attach the Pest docs.
  • Threads contain the actual questions and answers. We can create multiple threads for the same assistant. You can think of a thread as a conversation between a user and the AI.
  • Messages are either a user input / question or an answer from the AI.
  • Runs are the requests to start the AI work after a thread has been created and optionally a user message has been added. Unlike the Chat API, we do not get the answer directly. Instead, we get a run id which we can use to get the result later on.
  • Steps represent the progress of the AI. We can use them to get the current state of the AI. This is useful if we want to show the progress to the user or for debugging purposes. We are not going to use them in this tutorial.

For more in-depth information visit the OpenAI documentation.

Prerequisites

If you want to follow along you need to have an OpenAI account and an API key. You can create an account at https://openai.com/.

Create a new Laravel application and install the OpenAI PHP Client

We start by creating a new application using the Laravel installer.

laravel new pest-docs-bot

Next we install the OpenAI PHP Client for Laravel.

Note: You need to install the latest (beta) version of the package.

composer require openai-php/laravel:^0.8.0-beta.2`

Prepare the Pest docs

Before we can upload the documents to OpenAI, we have to prepare them, as the documentation consists of several files and OpenAI has a limit of 20 files per assistant.

Therefore, we will merge all doc files into a single file. Furthermore, we are going to exclude some files as they do not contain any useful information for our goal.

First we create a new command.

php artisan make:command PrepareDocs

We are fetching a list of all the files in the PestDoc repository using the GitHub REST API.

Then we are looping through all the files and filter out files which do not have a download url or the ones we want to exclude.

Finally, we retrieve the contents of the individual files and merge them into a single file. Then we save the file locally.

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;

class PrepareDocs extends Command
{
    private static array $FILES_TO_IGNORE = [
        'LICENSE.md',
        'README.md',
        'announcing-pest2.md',
        'documentation.md',
        'pest-spicy-summer-release.md',
        'video-resources.md',
        'why-pest.md',
    ];

    protected $signature = 'app:prepare-docs';

    protected $description = 'Create one file containing the full Pest documentation';

    public function handle()
    {
        $files = Http::get('https://api.github.com/repos/pestphp/docs/contents')->collect();

        $fullDocs = $files->filter(fn (array $file) => $file['download_url'] !== null)
            ->filter(fn (array $file) => ! in_array($file['name'], self::$FILES_TO_IGNORE))
            ->map(fn (array $file) => Http::get($file['download_url'])->body())
            ->implode(PHP_EOL.PHP_EOL);

        Storage::disk('local')->put('full-pest-docs.md', $fullDocs);
    }
}

Upload the docs to OpenAI

Now we are ready to upload the docs to OpenAI. We are going to use the upload() method of the Files resource in a new UploadDocs command.

The file to upload has to be a resource stream. Therefore, we are using the readStream() method of the Storage facade.

As purpose we are using assistants as we want to use the file for an assistant.

As a result we get a File object which contains the id of the uploaded file. We are going to use this id later on when we create the assistant.
I would suggest to store this id somewhere in your application, for example in a AssistantFile model to keep track of your uploaded files.
For simplicity we are here just going to output the id to the console.

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
use OpenAI\Laravel\Facades\OpenAI;

class UploadDocs extends Command
{
    protected $signature = 'upload-docs';

    protected $description = 'Uploads the docs to OpenAI';

    public function handle()
    {
        $uploadedFile = OpenAI::files()->upload([
            'file' => Storage::disk('local')->readStream('full-pest-docs.md'),
            'purpose' => 'assistants',
        ]);

        $this->info('File ID: '.$uploadedFile->id);
    }
}

Then we run the command:

Upload docs output

Create the assistant

Now we need to create the assistant. We are going to use the create() method of the Assistants resource in a new CreateAssistant command.

We are giving the assistant a name, pass the id of the uploaded file from before and add the retrieval tool.
The Knowledge Retrieval tool is used to extract information from the uploaded file. For more information about the tool visit the OpenAI documentation.

Next we instruct the AI to use the uploaded file to answer questions. And set the model to gpt-4-1106-preview.
Note: The regular gpt-4 model does not work with the retrieval tool.

Finally, we output the id of the created assistant to use it later.

namespace App\Console\Commands;

use Illuminate\Console\Command;
use OpenAI\Laravel\Facades\OpenAI;

class CreateAssistant extends Command
{
    protected $signature = 'create-assistant {file_id}';

    protected $description = 'Creates the PestDocs assistant.';

    public function handle()
    {
        $assistant = OpenAI::assistants()->create([
            'name' => 'Pest Chat Bot',
            'file_ids' => [
                $this->argument('file_id'),
            ],
            'tools' => [
                [
                    'type' => 'retrieval',
                ],
            ],
            'instructions' => 'Your are a helpful bot supporting developers using the Pest Testing Framework.
                               You can answer questions about the framework, and help them find the right documentation. 
                               Use the uploaded files to answer questions.',
            'model' => 'gpt-4-1106-preview',
        ]);

        $this->info('Assistant ID: '.$assistant->id);
    }
}

Then we run the command:

Create assistant output

Create the interface

Now we are ready to create the interface. We are going to use the Livewire package to create a simple interface.

First we install livewire.

composer require livewire/livewire

Then we create a new Livewire component and a layout file.

php artisan make:livewire DocBot

php artisan livewire:layout

In our routes file routes/web.php we are registering the home route to the DocBot component.

Route::get('/', \App\Livewire\DocBot::class);

To style the component we are using Tailwind CSS with the Forms and Typography plugins.
All installation instructions can be found in the docs.

We are going to create a simple interface where the user can enter a question and the AI will answer it.

Because this tutorial isn’t about Livewire, here a brief list of the relevant parts:

  • wire:model directive to bind the input field to the $question property.
  • wire:submit.prevent directive to call the ask() method on form submit.
  • wire:loading directive to show a spinner while the AI is working.
  • When the AI has finished its work, we render the answer which comes as markdown with Spatie’s spatie/laravel-markdown library.

This is what the blade part of the component does look like. All the classes have been removed to keep it simple. You can find the full code at GitHub.

<div>
    <div>
        <h3>PEST Documentation Assistant</h3>
        <div>
            <p>Enter you question, and I will try to find an answer in the current Pest documentation.</p>
        </div>
        <form wire:submit.prevent="ask">
            <div>
                <label for="question">Question</label>
                <input type="text"
                       name="question"
                       wire:model="question"
                       placeholder="How to run a single test?"
                >
            </div>
            <button type="submit">
                <span wire:loading.class="invisible">Ask</span>
                <x-spinner class="absolute invisible" wire:loading.class.remove="invisible" />
            </button>
        </form>
        @if($answer)
            <h3 class="mt-8 mb-1 text-base font-semibold leading-6 text-gray-900">My answer</h3>
            <div class="mb-2 prose">
                <x-markdown>{!! $answer !!}</x-markdown>
            </div>
        @endif
    </div>
</div>

This gives us the following interface:

The form

Ask the AI

In the class part of the Livewire component we have two properties to store the user question and the AI answer and one more to store the error if necessary.

The ask() function is executed when the user submits the form. For now, it is empty. We are going to fill it in the next step.

<?php

namespace App\Livewire;

use Livewire\Component;
use OpenAI\Laravel\Facades\OpenAI;
use OpenAI\Responses\Threads\Runs\ThreadRunResponse;

class DocBot extends Component
{
    public string $question = '';
    public ?string $answer = null;
    public ?string $erro = null;

    public function ask()
    {
        // ...
    }

    public function render()
    {
        return view('livewire.doc-bot');
    }
}

When the user submits a question the ask() function does two things.
First it creates a new Thread and runs it, and then it loads the answer from the given run.

public function ask()
{
    $threadRun = $this->createAndRunThread();

    $this->loadAnswer($threadRun);
}

Create a new Thread and run it

Let’s start with the createAndRunThread() function. We are going to use the createAndRun() method of the Threads resource.
This endpoint allows us to create a new thread and run it in a single request. As an alternative we could also create a thread first and then run it in a next step. This is handy you want to prepare the thread synchronously but execute the run asynchronously.

We are passing the id of the assistant we created before and the question the user entered as the only message in the thread.

 private function createAndRunThread(): ThreadRunResponse
{
    return OpenAI::threads()->createAndRun([
        'assistant_id' => 'asst_6VzQhp0uC0ZouIRJlxhfxI0a',
        'thread' => [
            'messages' => [
                [
                    'role' => 'user',
                    'content' => $this->question,
                ],
            ],
        ],
    ]);
}

As a result we get a ThreadRunResponse object which contains the ids of the thread and the run. Besides that it has other properties like the status of the run.
At this point the status is always queued as the AI has not processed the thread yet.

Currently, there is no way yet to get the answer directly. Additionally, it is not possible to stream the request unlike the Chat API.
The only thing we can do is to periodically check the status of the run and wait until it is done.

OpenAI already announced that they are working on a streaming and notification options. So, this will change in the future.

Load the answer

Now we are going to implement the loadAnswer() function. We are going to use the retrieve() method of the ThreadsRuns resource to get the updated status of the run.

In a while loop we are fetching the run until the status is not queued or in_progress anymore.

Then we check if the run has terminated successfully. If not, we set the error message, which by the way is not handled in the GUI for simplicity.

When the run has completed successfully we are going to fetch the messages of the thread. The AI has added the result of the run as a new message.
Because new messages are added at the beginning of the list, we can access the answer at index 0.

Each message contains an array of content objects. These are either text or image objects. In our case there is always only one text object.
This text object has a text property which has a property value containing the actual answer we are interested in.
So, we are going to store this value in the $answer property of the component.

private function loadAnswer(ThreadRunResponse $threadRun)
{
    while(in_array($threadRun->status, ['queued', 'in_progress'])) {
        $threadRun = OpenAI::threads()->runs()->retrieve(
            threadId: $threadRun->threadId,
            runId: $threadRun->id,
        );
    }

    if ($threadRun->status !== 'completed') {
        $this->error = 'Request failed, please try again';
    }

    $messageList = OpenAI::threads()->messages()->list(
        threadId: $threadRun->threadId,
    );

    $this->answer = $messageList->data[0]->content[0]->text->value;
}

Using the bot

That’s all we have to do. Now we can ask the AI questions about the Pest documentation and see the result.

The form

Regular ChatGTP models are currently not able to answer this question correctly because throwsUnless has been added to Pest after the models have been trained.

Conclusion

In this tutorial we have seen how to use the new OpenAI Assistants API in a Laravel application.
We have seen how to upload files, create an assistant, create a thread and run it, and how to get the result.

Of course there is a lot more you can do with the Assistants API. For example, you can use the AI to analyse your data and draw a graph or extend the capabilities of the AI by giving it access to your software through tools.
If you want to learn more about the Assistants API visit the OpenAI documentation.

Additionally, we did not cover topics like error handling or testing. You can learn more about this in the PHP Client documentation.

I would love to hear your feedback. You can reach me on X / Twitter or by using the contact form.

If you like this tutorial I wouldn’t mind if you share it with your friends and colleagues. Thank you!

Laravel News Links

Murder Rate Fell 6.1% After Supreme Court’s Bruen Decision, Gun Control Industry Silent

https://cdn0.thetruthaboutguns.com/wp-content/uploads/2019/08/do-something.jpg

do something gun control protest
Courtesy Twitter

Next Post Coming Soon…▶

The mid to late 20th century was the peak era of gun control in America. The violence and unrest of the 1960s kicked it all off with the the Gun Control Cct of 1968, the Firearm Owners Protection Act of 1986, the Brady Law of 1993 and finally the Clinton “assault weapons” ban of 1994.

Few states allowed concealed carry in any form, while a number of western states only allowed open carry. Even Texas, despite its gun-friendly reputation, was very restrictive from the time of Reconstruction until the 1990s. Even in states that allowed open carry, it was common to face police harassment and social shunning for daring to carry.

As you can see, things began to slowly change quickly starting in the late 1980s. A wave of “shall issue” carry laws took hold in places where carry was either banned or permits were only issued to the wealthy and/or well-connected. After most states had a process where normal people could get a permit to carry a gun, the next wave of constitutional (permitless) carry began to sweep the United States. That process is ongoing today with 27 states having some form of permitless carry more still possible (Louisiana, South Carolina).

Every time anything threatened to change for the better on the map above, the story was always exactly the same. At hearings in state legislatures, the defenders of the restrictive status quo always showed up raise the alarm and claim the policy of limiting gun rights is better and more reasonable. If the legislature changed the law to give people more freedom, the warned, there would be dire consequences. Blood would run ankle-deep in the streets, fender-bender shootouts would erupt, robberies and murders would rise, and the fabric of the social order would be frayed.

Somehow, though, that never happened. There are lying statisticians who play games with the numbers, but the objective and honest ones have been able to show a rise in crime that could be attributed to letting law-abiding citizens carry firearms.

If anything, there’s good evidence that crime falls after gun control laws are relaxed. To pro-gun people, the reasons are obvious — criminals carried guns regardless of the law, and now law-abiders are carrying, too. Law-abiding gun owners engage in very little crime as a group, but the very fact that they’re armed suppresses the activities of criminals to a certain extent.

This dynamic played out again and again, yet the gun control industry never learned their lesson. Over and over, states decided to respect the right to keep and bear arms, removing carry restrictions. and the fools continue to predict more murder and mayhem. Yet it never came to pass.

When the Supreme Court told deep-blue states that they had to start issuing carry permits without applying bureaucratic discretion, the same dynamic went into overdrive. Once again, a great wave of crime was predicted. Here’s Brady’s dire predictions issued the day the Bruen decision was handed down . . .

“The court’s actions…will assuredly result in more gun violence immediately.”

If you poke around on the internet, other anti-gun groups made the same kind of prediction. But to paraphrase Mark Twain, what the gun control industry thought they knew just wasn’t so.

Recent data from the FBI (even though it’s being run by the Biden Administration now) shows, once again, that lowering the restrictions on gun ownership and carry wasn’t the disaster it was predicted to be.

According to The Hill . . .

The FBI’s annual crime report, released Monday, found that violent crime in the U.S. last year decreased while property crime is on the rise. Overall, violent crime dropped 1.7 percent, including a 6.1 percent decrease in murder and non-negligent manslaughter.

Overall, the rate of violent crime in 2022 — 380.7 per 100,000 people — is slightly below what was recorded before the pandemic in 2019 when it was 380.8 per 100,000 people. While violent crime is on a downward trend, property crime remains on the rise, with a 7.1 percent increase in 2022.

What seems fairly obvious here is that criminals are now more afraid to victimize people directly. There’s more of a chance that their victims can and will fight back.

Instead, they’ve switching to property crimes like auto theft and burglary of unattended properties. The few violent crimes that have risen are all based on getting the drop on people, including carjackings, but other forms of violent crime are below what they were even in 2019.

While it sucks to have packages stolen from your porch or your car broken into, or even to have someone steal your car from your driveway, all of those things can be replaced. We can’t replace our lives and having the ability to deter an attack on ourselves or our families — wherever we may be — is critical. So, this is definitely the trend line I’d rather be on.

 

 

 

 

 

Next Post Coming Soon…▶

The Truth About Guns

How to Carve a Turkey Like a Pro Chef

https://hips.hearstapps.com/amv-prod-gp.s3.amazonaws.com/gearpatrol/wp-content/uploads/2016/11/Carve-A-Turkey-Gear-Patrol-Lead-Featured.jpg?crop=1xw:0.65xh;center,top&resize=640:*

The first mistake you can make when carving a turkey is to attempt the whole ordeal table-side. Bad idea. “Most people don’t have a giant cutting board that they’re going to put on their table,” says Harry Rosenblum, cofounder of The Brooklyn Kitchen. “They have a platter, and that’s a horrible surface to cut on. The thing slides around. You don’t have control. Also, nobody wants to see you stick your hands on the turkey.”

Even in the comfort of the kitchen, however, carving a bird can induce varying levels of performance anxiety among turkey novices — especially if that’s where the crowd has gathered. Just remember now: you’re feeding friends and family, not competing on Chopped.

“Ultimately, as long as the turkey is cooked correctly, it’s not going to taste bad,” Rosenblum says. “There’s very little about carving turkey that could cause you to screw up Thanksgiving. If you got here, you’re basically all set.” So this year, get in the driver’s seat and carve that goddamn turkey. Just don’t do it at the table. Real Thanksgivings don’t need to look like Norman Rockwell paintings.

Step 1: Let Your turkey rest

Like with steak or pork, let your roasted turkey rest at room temperature for 15 to 30 minutes before carving. Use that time to check your potatoes, make gravy, drink more wine — but most of all, to make sure your chef’s knife is sharp and honed. That’s crucial if you want skin on every piece, Rosenblum says.

Step 2: Remove legs and thighs.

“The end goal is to take everything off the carcass,” Rosenblum says. “I like to start with the leg and thigh, following the natural seams of the animal.” To completely sever the thigh from the breast, you’ll need to cut through a knuckle on either side.

Step 3: Sever the leg from the thigh.

Flip the leg and thigh skin-side-down so you can locate the knuckle. Cut straight through it with your knife. “If the bird is fully cooked, the joint will just pop out,” Rosenblum says.

Step 4: Debone the thigh.

Locate the thigh bone and use the tip of your knife to cut around it. “There will be a little bit of meat on the bone,” Rosenblum says. “Save them. They’re great for soup.”

Step 5: Slice the thigh into individual pieces.

Flip the boneless thigh back skin-side-up, and slice into individual half-inch pieces. “Always slice against the grain of the muscle,” Rosenblum says.

Step 6: Cut down the center of the breast.

“The body comes up into a point,” says Rosenblum. That’s the breastbone. “Once you cut down either side, you’ll see the meat will start to come away from the carcass.” Cut through the ball joint that connects the breast and wing to the carcass.

Step 7: Remove the wing.

Before you slice the breast meat, remove the wing by locating the connective ball joint and removing it from the breast. You want a boneless piece of breast meat.

Step 8: Slice the breast meat.

Follow the same rule of thumb applied to the thigh: with the skin-side-up, and going against the grain, slice the breast meat into half-inch pieces.

Step 9: Plate the turkey.

“You can go as rustic or refined as you want,” Rosenblum says. “I always try to put the turkey back together on the plate, just without the bones.” This makes it easy for people to identify and choose the kind of meat they want.

Gear Patrol

The Story of Uziel Gal, Inventor of the Uzi Submachinegun

https://cdn0.thetruthaboutguns.com/wp-content/uploads/2023/11/shutterstock_2555897-scaled.jpg

Uzi submachine gun pistol
Shutterstock

Next Post Coming Soon…▶

By Tyler Hilliker

You have probably heard of the world famous Uzi and its variants, even if you aren’t really a “gun person.” The infamous little 9mm is just one of those guns that’s almost universally recognizable by almost anyone, much like the Tommy gun, M16, AK47 and GLOCK.

The Uzi was first introduced in Israel in the early 1950s, seeing use through the present day with several militaries, including the ongoing Russia-Ukraine war. Uzis of one kind or another have also been featured in literally hundreds of action films, TV shows, music videos and video games. If you’ve ever seen photographs from the 1981 attempted assassination of Ronald Reagan then you have surely seen the little sub gun being famously wielded by Secret Service agents.

Today we will be taking a look at the life of its inventor. I present to you the man, the myth, the legend…Uziel Gal.

Uziel Gal

This year marks the 100th anniversary of the birth of the Uzi, born as Gotthard Glas. Born on December 15th 1923 in Weimar Germany to a Jewish family, they to England in 1933 after the Nazis came into power. Then in 1936, they moved to Kibbutz Yagur in what was then the British Mandate of Palestine at which time he also changed his name to Uziel Gal.

From his youth, Gal was interested in weapons engineering. He designed his first automatic gun (which shot arrows) at age 15. At 20, now a member of the Haganah defense force and was arrested by British troops for carrying a gun (it was forbidden to Jews in Israel at the time). He spent three years in prison during which he studied mechanical engineering before being pardoned in 1946.

He joined what is now known as the Israeli Defense Force during the Israeli war of Independence in 1948 at the age of 24 where he saw combat in Northern Israel. That’s where he demonstrated his homemade prototype submachine gun in Yagur. It was during that time that Captain (later Major) Gal was sent to work at Israel Military Industries where his Uzi first went into production in 1950. It was adopted officially in 1951 and first saw use with IDF special forces in 1954. Eventually over 10 million would be made. 

Uzi Pistol Pro

Interestingly enough, Uziel didn’t even want the gun named after himself, but it proved to be so popular that his requests were ignored. In 1955, the IDF decorated him for his work with the Tzalash HaRamatkal. And in 1958, he became the first recipient of the Israel Security Award which was given to him by Israeli Prime Minister David Ben-Gurion.

Uziel remained with the IDF until 1975, rising to the rank of Lt. Col. when he retired. Shortly after, in 1976, he and his family emigrated to the United States, specifically Philadelphia, so that his daughter, Tamar, could receive proper extended medical care for a rare brain disorder. She unfortunately passed away in 1984 in her early 20s.

After coming to America, Uziel worked with Action Manufacturing (Action Arms) originally prototyping a .30 caliber military rifle. In 1978 He was approached by the owner of Action Arms to bring his Uzi to the U.S. civilian market. 

As a career IDF officer, Uziel had always felt that his invention for the Jewish state was part of his duty, and he never received any royalties on the original military design.

Uzi being processed at a Chicago gun “buyback” (image via Chicago Police Facebook page)

Working with Israel Military Industries, the first intended civilian model was sent to the ATF for approval, but was quickly denied, considered readily convertible to a machinegun. As it was simply a 16” barreled Uzi sub-machinegun with a metal bar welded into the removable grip frame to prevent the selector from being switched to full auto, it’s quite obvious why this original model was denied for import as a semi-auto.

Uziel then worked to design a truly semi-automatic only version of his design, which included a welded steel bar inside the receiver to prevent installation of a full auto bolt, and a change to a closed bolt design, amongst many smaller changes.

With an Uzi model newly approved for import, the gun was first introduced to the public at the 1980 SHOT Show, receiving a significantly higher than expected 7,000 orders initially. In the first three years, they managed to sell more than 36,000 additional semi auto Uzi’s.

In 1989, an American assault weapons import ban went into effect. Essentially dooming the Action Arms’ plans. The Uzi is still being manufactured in both licensed and unlicensed through the present day.

Uzi pistol brace
Courtesy IWI

Uziel eventually left Action Arms over a royalty dispute. He sued the company and won after four years of litigation. In the end, Uziel was awarded a substantial sum for royalties, which had been bumped from 5% to 10% by the judge, as well as a large sum in damages.

In his later years, Uziel worked with Ruger on the development of the Ruger MP9 Sub Machinegun, as well as a number of of other small projects. His wife passed away in 1998, and Uziel died in September, 2002. His body was returned to Israel where he is buried alongside his wife at the foot of Mount Carmel.

Uziel Gal will be remembered for his distinguished service to Israel, for his extraordinary creativity and the iconic, eponymous submachinegun he invented. He is survived by his son, Iddo Gal.

 

Tyler Hilliker is a USCCA certified firearms instructor, 2A advocate, and federally licensed firearms manufacturer. He is a vocal advocate, fostering informed discussions and is working to leave an indelible mark on the firearms community through education, training, and unwavering advocacy.

Next Post Coming Soon…▶

The Truth About Guns

Laravel 10 How to Find Nearest Location By Latitude and Longitude ?

https://ahtesham.me/storage/posts/September2023/Af1588tH7AwEovS2wV66.jpg

In this tutorial, we will learn how to find the nearest location based on latitude and longitude using Laravel 10 in a simple and easy-to-follow manner. I’ll guide you through the steps to make use of Laravel 10’s latitude and longitude tools to determine the closest location. Specifically, we’ll focus on finding nearby locations in Laravel 10. Follow these straightforward steps to utilize Laravel 10 for locating the nearest place based on latitude and longitude.

Having access to latitude and longitude coordinates can be highly valuable for various purposes, such as identifying nearby businesses, residences, hotels, cities, and more. In this example, we’ll take a user-friendly approach. To enable location-based user searches by their closest latitude and longitude, we’ll add latitude and longitude fields to the users’ table.

Let’s get started with these easy-to-follow instructions:

 

Step 1: Install Laravel

first of all we need to get fresh Laravel version application using bellow command, So open your terminal OR command prompt and run bellow command

composer create-project laravel/laravel blog	

 

Step 2: Create Route

In this is step we need to create one route for getting near location from lat and long example.

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\LocationController;
  
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
  
Route::get('near-by-places', [LocationController::class, 'index']);	

Read More : Laravel 10 Multiple Authentications using Middleware Example

 

Step 3: Create Controller

in this step, we need to create LocationController and add following code on that file. you have users table with lat and long columns. also add some dummy records on table as well.

app/Http/Controllers/LocationController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use App\Model\User;
  
class LocationController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $lat = YOUR_CURRENT_LATTITUDE;
        $lon = YOUR_CURRENT_LONGITUDE;
           
        $users = User::select("users.id"
                        ,DB::raw("6371 * acos(cos(radians(" . $lat . ")) 
                        * cos(radians(users.lat)) 
                        * cos(radians(users.lon) - radians(" . $lon . ")) 
                        + sin(radians(" .$lat. ")) 
                        * sin(radians(users.lat))) AS distance"))
                        ->groupBy("users.id")
                        ->get();
        dd($users);
    }
}

 

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

Now, Go to your web browser, type the given URL and view the app output:

http://localhost:8000/near-by-places	

i hope it can help you…

Laravel News Links