A Beginner’s Guide To Ghost Guns

Are you interested in building your own firearms at home, but aren’t really sure how to get started? Not to worry; we the New York State Police has your back.

In an effort to crack down on so-called “ghost guns,” the NYSP inadvertently put together the perfect beginner’s how-to manual:

Ghost Guns: Past, Present, and Future

It has all the info you need to start. Descriptions of the technologies available (80% receivers, CNC milling, 3D printing), along with suppliers for the various tools, and complete parts lists and suppliers.

It tells you what hand tools you’ll be wanting. It even tells which types of plastic filament are best suited for firearms and the model of 3D printer you choose. It shows you basic steps you’ll be following.

NYSP didn’t mean it this way; it was supposed to be an internal tyranny tool. But someone leaked it, and we aim to keep it leaked.

Download your COPY now.


Hat tip to David Codrea.

FacebooktwitterredditpinteresttumblrmailThe Zelman Partisans

HTTP Guzzle Request Example Laravel 10

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

In this tutorial, we will learn how to make web requests in Laravel 10 using Guzzle. We’ll explore the basics of making GET, POST, PUT, and DELETE requests with the Guzzle HTTP client library. It’s an essential skill in web development, and Guzzle makes it user-friendly in Laravel 10.

In the past, developers used cURL for similar tasks, but now we have more powerful tools like Guzzle, which we’ll look at here.

We’ll cover the following examples:

Laravel 10 HTTP Guzzle GET Request Example: How to perform a GET request using Guzzle in Laravel 10.

Laravel 10 HTTP Guzzle POST Request Example: Sending POST requests with Guzzle in Laravel 10.

Laravel 10 HTTP Guzzle PUT Request Example: Making PUT requests with Guzzle in Laravel 10.

Laravel 10 HTTP Guzzle DELETE Request Example: Sending DELETE requests with Guzzle in Laravel 10.

By the end of this tutorial, you’ll have a clear understanding of how to use Guzzle for different types of HTTP requests in Laravel 10. This knowledge will enable you to work more effectively with external APIs and web services.

 

Step 1: Download Laravel

Let us begin the tutorial by installing a new laravel application. if you have already created the project, then skip following step.

composer create-project laravel/laravel example-app

 

Step 2 : Laravel 10 HTTP cURL GET Request Example:

Here, we will see how to send curl http get request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts', [HttpPostController::class, 'index']);
php artisan make:controller HttpPostController

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function index()
    {
        $response = Http::get('https://jsonplaceholder.typicode.com/posts');
    
        $jsonData = $response->json();
          
        dd($jsonData);
    }
}

 

Step 3 : Laravel 10 HTTP cURL POST Request Example:

Here, we will see how to send curl http post request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts/store', [HttpPostController::class, 'store']);

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function store()
    {
        $response = Http::post('https://jsonplaceholder.typicode.com/posts', [
                    'title' => 'This is test from Nicesnippest.com',
                    'body' => 'This is test from Nicesnippest.com as body',
                ]);
  
        $jsonData = $response->json();
      
        dd($jsonData);
    }
}

Output:

Array
(
    [titile] => This is test from Nicesnippest.com
    [body]  => This is test from Nicesnippest.com as body
    [id] => 101
)

 

Step 4 : Laravel 10 HTTP Curl PUT Request Example:

Here, we will see how to send curl http put request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts/update', [HttpPostController::class, 'update']);

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function update()
    {
        $response = Http::put('https://jsonplaceholder.typicode.com/posts/1', [
                    'title' => 'This is test from Nicesnippets.com',
                    'body' => 'This is test from Nicesnippets.com as body',
                ]);
  
        $jsonData = $response->json();
      
        dd($jsonData);
    }

Output:

Array
(
    [titile] => This is test from Nicesnippest.com
    [body]  => This is test from Nicesnippest.com as body
    [id] => 1
)

 

Step 5 : Laravel 10 HTTP cURL DELETE Request Example:

Here, we will see how to send curl http delete request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts/delete', [HttpPostController::class, 'delete']);

app/Http/Controllers/HttpPostController.php

<?php
   
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function delete()
    {
        $response = Http::delete('https://jsonplaceholder.typicode.com/posts/1');
  
        $jsonData = $response->json();
      
        dd($jsonData);
    }
}

 

Step 6 : Laravel 10 API with Response:

We will create very simple http request full example. we need to create simple route to call controller method. so let’s create it:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts', [HttpPostController::class, 'index']);

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
 
class HttpPostController extends Controller
{
    public function index()
    {
        $response = Http::get('http://jsonplaceholder.typicode.com/posts');
  
        $jsonData = $response->json();
          
        echo "<pre> status:";
        print_r($response->status());
        echo "<br/> ok:";
        print_r($response->ok());
        echo "<br/> successful:";
        print_r($response->successful());
        echo "<br/> serverError:";
        print_r($response->serverError());
        echo "<br/> clientError:";
        print_r($response->clientError());
        echo "<br/> headers:";
        print_r($response->headers());
    }
}

Output:

status:200
ok:1
successful:1
serverError:
clientError:
headers:Array
(
    [Date] => Array
        (
            [0] => Thu, 12 Mar 2020 06:08:58 GMT
        )
    [Content-Type] => Array
        (
            [0] => application/json; charset=utf-8
        )
    [Transfer-Encoding] => Array
        (
            [0] => chunked
        )
    .....
)

Read More : Laravel 10 Accessor and Mutator Example

I hope it can help you…

Laravel News Links

HTTP Guzzle Request Example Laravel 10

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

In this tutorial, we will learn how to make web requests in Laravel 10 using Guzzle. We’ll explore the basics of making GET, POST, PUT, and DELETE requests with the Guzzle HTTP client library. It’s an essential skill in web development, and Guzzle makes it user-friendly in Laravel 10.

In the past, developers used cURL for similar tasks, but now we have more powerful tools like Guzzle, which we’ll look at here.

We’ll cover the following examples:

Laravel 10 HTTP Guzzle GET Request Example: How to perform a GET request using Guzzle in Laravel 10.

Laravel 10 HTTP Guzzle POST Request Example: Sending POST requests with Guzzle in Laravel 10.

Laravel 10 HTTP Guzzle PUT Request Example: Making PUT requests with Guzzle in Laravel 10.

Laravel 10 HTTP Guzzle DELETE Request Example: Sending DELETE requests with Guzzle in Laravel 10.

By the end of this tutorial, you’ll have a clear understanding of how to use Guzzle for different types of HTTP requests in Laravel 10. This knowledge will enable you to work more effectively with external APIs and web services.

 

Step 1: Download Laravel

Let us begin the tutorial by installing a new laravel application. if you have already created the project, then skip following step.

composer create-project laravel/laravel example-app

 

Step 2 : Laravel 10 HTTP cURL GET Request Example:

Here, we will see how to send curl http get request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts', [HttpPostController::class, 'index']);
php artisan make:controller HttpPostController

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function index()
    {
        $response = Http::get('https://jsonplaceholder.typicode.com/posts');
    
        $jsonData = $response->json();
          
        dd($jsonData);
    }
}

 

Step 3 : Laravel 10 HTTP cURL POST Request Example:

Here, we will see how to send curl http post request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts/store', [HttpPostController::class, 'store']);

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function store()
    {
        $response = Http::post('https://jsonplaceholder.typicode.com/posts', [
                    'title' => 'This is test from Nicesnippest.com',
                    'body' => 'This is test from Nicesnippest.com as body',
                ]);
  
        $jsonData = $response->json();
      
        dd($jsonData);
    }
}

Output:

Array
(
    [titile] => This is test from Nicesnippest.com
    [body]  => This is test from Nicesnippest.com as body
    [id] => 101
)

 

Step 4 : Laravel 10 HTTP Curl PUT Request Example:

Here, we will see how to send curl http put request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts/update', [HttpPostController::class, 'update']);

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function update()
    {
        $response = Http::put('https://jsonplaceholder.typicode.com/posts/1', [
                    'title' => 'This is test from Nicesnippets.com',
                    'body' => 'This is test from Nicesnippets.com as body',
                ]);
  
        $jsonData = $response->json();
      
        dd($jsonData);
    }

Output:

Array
(
    [titile] => This is test from Nicesnippest.com
    [body]  => This is test from Nicesnippest.com as body
    [id] => 1
)

 

Step 5 : Laravel 10 HTTP cURL DELETE Request Example:

Here, we will see how to send curl http delete request in laravel 10, let’s update route file code and controller file code. you can see output as well:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts/delete', [HttpPostController::class, 'delete']);

app/Http/Controllers/HttpPostController.php

<?php
   
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
  
class HttpPostController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function delete()
    {
        $response = Http::delete('https://jsonplaceholder.typicode.com/posts/1');
  
        $jsonData = $response->json();
      
        dd($jsonData);
    }
}

 

Step 6 : Laravel 10 API with Response:

We will create very simple http request full example. we need to create simple route to call controller method. so let’s create it:

routes/web.php

<?php
  
use Illuminate\Support\Facades\Route;
  
use App\Http\Controllers\HttpPostController;
  
/*
|--------------------------------------------------------------------------
| 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('posts', [HttpPostController::class, 'index']);

app/Http/Controllers/HttpPostController.php

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
 
class HttpPostController extends Controller
{
    public function index()
    {
        $response = Http::get('http://jsonplaceholder.typicode.com/posts');
  
        $jsonData = $response->json();
          
        echo "<pre> status:";
        print_r($response->status());
        echo "<br/> ok:";
        print_r($response->ok());
        echo "<br/> successful:";
        print_r($response->successful());
        echo "<br/> serverError:";
        print_r($response->serverError());
        echo "<br/> clientError:";
        print_r($response->clientError());
        echo "<br/> headers:";
        print_r($response->headers());
    }
}

Output:

status:200
ok:1
successful:1
serverError:
clientError:
headers:Array
(
    [Date] => Array
        (
            [0] => Thu, 12 Mar 2020 06:08:58 GMT
        )
    [Content-Type] => Array
        (
            [0] => application/json; charset=utf-8
        )
    [Transfer-Encoding] => Array
        (
            [0] => chunked
        )
    .....
)

Read More : Laravel 10 Accessor and Mutator Example

I hope it can help you…

Laravel News Links

7 Websites to Practice Data Structure & Algorithm Coding Challenges

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2023/09/decentralized-websites.jpg

Software engineering interviews often involve several rounds. Data structures and algorithms are one of the critical areas that employers may test. As such, it’s a no-brainer that you need to sharpen your data structures and algorithms (DSA) skills if you want to ace technical interviews.

Fortunately, there are many websites you can use to learn about DSA and practice your understanding.

These are some of the best platforms for practicing your knowledge of data structures and algorithms through coding challenges. These websites support various programming languages, so whichever you’re familiar with, you’re good to go.

LeetCode is one of the best platforms to prepare for technical interviews. It’s packed with a variety of problems that you can solve, touching on different areas including common to advanced data structures and algorithms.

If you’re starting your journey, you can use the platform’s crash course to learn about the basics and gain the confidence and skills to start solving problems. The platform also provides editorial solutions to problems, showcasing the best approach for when you’re stuck.

You can also view solutions from other LeetCode users. For advanced users, LeetCode has regular weekly and bi-weekly contests where you can compete with others to solve problems, gain points, and climb the ranks.

HackerRank is another solid platform for practicing your DSA skills. It includes a variety of topics and languages but, most importantly, dedicated sections for data structures and algorithm problems. Like LeetCode, you can sort the coding challenges by difficulty level (Easy, Medium, and Hard).

You can also sort questions by their subdomains, like search, arrays, trees, heaps, sorting, graph theory, dynamic programming, and recursion. The site covers all the data structures every developer should be familiar with.

Under each question, there’s an editorial section with answers, another for discussions, where you can seek clarification and help from your peers, and a leaderboard.

Preparing for an upcoming technical interview? If so, you can make use of HackerRank Kits that let you practice specific DSA skills. HackerRank also has contests, but they are less frequent than LeetCode’s.

Codewars is not as streamlined as the first two websites. Its challenges might seem a bit random, but you can use its filters to only display challenges related to DSA. You can view data structures by selecting the Data Structures tag and algorithms by selecting the identically named tag.

You can sort the challenges by difficulty level using Codewars’ Japanese martial arts-inspired system (the lower the number, the harder the problem). Don’t let the ranking system confuse you, though. The most important point is polishing your DSA skills by solving challenges on the platform.

Codility is a platform that is dedicated to helping companies hire software developers. Still, in addition to that, it also offers a section for training. The app has various lessons but is very limited relative to the first three sites in this list. Codility divides its training into three categories: challenges, lessons, and exercises.

You can jump in and take on any problem, but what makes Codility unique is that it gives you a timeframe to find your solution. Other platforms just track the time you take to solve a problem, except for contests and challenges.

This is particularly important if you have an interview soon because it ensures that, as much as you are practicing your problem-solving skills, you’re sharpening your time-management skills at the same time.

HackerEarth has several sections, including a practice tab that covers data structures, algorithms, interview preparation, mathematics, basic programming, and more. The algorithm section comprises nearly a thousand problems, while the algorithms section has over 350 problems. After signing up, you need to select the languages you use. Still, you can use any language to solve the challenges.

The platform also has an editorial section under each problem, which showcases the solution and the thought process behind it. You can practice further questions under the specific subdomain by checking for similar problems.

Like HackerRank and LeetCode, the Discussions tab is where you can chat with other students about the challenges you’re facing while tackling a problem. HackerEarth also includes regular challenges and a leaderboard if you’re the competitive type.

Techie Delight has nearly 600 problems on its platform. Unlike most of the professional sites in this list, this one’s free, and you don’t have to create an account to practice. When you visit the site, the first problem is waiting for you to solve. We recommend using the filters available to make good use of the site. Use the category and tags filter to display data structure or algorithm-related problems.

It may sound perfect, but there’s one drawback to using Techie Delight. At the time of writing, it only supports three programming languages: Python, Java, and C++. So you’ll need to be familiar with one of these three languages to use the site. There’s also no editorial section and no discussions tab that you can use to seek assistance when stuck.

With over 600 problems on the platform, InterviewBit is another solid site for DSA practice. It categorizes its questions according to different factors including difficulty, topics, and companies. For DSA practice, use the topic filter to drill down the questions displayed by specific subdomains under data structures or algorithms. When you navigate to a question’s tab, InterviewBit goes a mile extra by including a Hints tab.

It divides the Hints tab into three, with increasingly detailed steps on how to go about solving the problem. Viewing a hint deducts 10% from your score. A suggested approach to the solution reduces the final score by half, and you don’t get a score at all if you view the complete solution. You can use this clever feature to learn, practice, and test yourself as you see fit.

Master Data Structures and Algorithms Using Coding Challenges

We’ve listed the best websites for practicing data structures and algorithm concepts. These sites allow you to practice DSA in various programming languages, including popular high-level ones like Python, Java, and JavaScript alongside even low-level ones like C, C++, and Rust.

Most of these sites include solutions and the thought process behind solving a problem, which can be helpful while starting your journey to DSA mastery.

MakeUseOf

When Matthew Perry Met Windows 95

Long-time Slashdot reader destinyland writes: In 1994 the TV show Friends premiered, and its first season’s high ratings made it the 8th most-popular show. The next year Microsoft released Windows 95 — and filmed a promotional video for it with 25-year-old Matthew Perry and 26-year-old Jennifer Aniston. "They’ll be taking you on an adventure in computing that takes place in the office of Microsoft chairman Bill Gates," explains the video’s narrator, adding "Along the way, they meet a wacky bunch of propellor-heads…. And are introduced the top 25 features of Windows 95!" It’s a journey back in time. (At one point the video refers to Windows as the operating system "with tens of millions of users.") Their 30-minute segment — billed as "the world’s first cyber sitcom" — appears in an hour-long video introducing revolutionary features like the new "Start" button. Also demonstrated in Excel are the new minimize and maximize "features" in "the upper right-side of the window". And the two actors marvel at the ability to type a filename that was longer than eight characters… Watch for reminders that The Microsoft Windows 95 Video Guide was filmed nearly three decades ago. When the desktop appears after waking from screensaver mode, Perry notes that there’s "no messy DOS build-up." And later the video reminds viewers that Windows 95 is compatible "with DOS games like Flight Simulator." There’s also a brand new feature called "Windows Explorer" (which is described as "File Manager on steroids"), as well as a new "Find" option, and a brand new icon named "My Computer". And near the end they pay a visit to the Microsoft Network — which was mostly a "walled garden" online service — described in the video as "your on-ramp to the information superhighway". The video even explains how Windows 95 "uses the right mouse button for what Microsoft calls power users." And by the end of it, Jennifer Anniston finds herself playing Space Cadet 3D pinball.

Read more of this story at Slashdot.

Slashdot

7 List Functions Every Python Programmer Should Know

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2023/10/checklist.jpg

Key Takeaways

  • The len() function is useful for determining the number of items in a list, saving time and code compared to manual calculation.
  • The append() function adds a new item to the end of a list, allowing for easy modification based on conditions or user input.
  • The extend() function adds multiple items to an existing list at once, simplifying the process of modifying a list with new elements.

Lists form an essential part of data structures and algorithms in Python. They play an important role, and ignoring them in your projects is almost impossible.

Due to the large importance of lists, Python provides some built-in functions to perform common list operations. These functions aim to help developers work faster and easier.

1. The len() Function

Use the len() function to get the number of items inside a list. Here’s an example:

 my_list = [1, 2, 3, "hello", "rice", "code", 1.2]
list_length = len(my_list)
print(list_length)

Without the len() function, you would have to manually calculate length, like in this example which uses a Python for loop:

 my_list = [1, 2, 3, "hello", "rice", "code", 1.2]
count = 0

for i in my_list:
    count += 1

print(count)

From this example, it is obvious that the len() function saves some code. Ensure you use it whenever the need arises.

2. The append() Function

The append() function adds a new item to the end of your list. A good use of this is to add an item to your list after your code fulfills a certain condition. Here’s a simple example:

 my_list = [1, 2, 3, "hello", "rice", "code", 1.2]
question = input("Do you love Python?: ").lower()

if question == "yes":
    my_list.append("Python is the best!!")
else:
    my_list.append("You should try Python")

print(my_list)

This example uses an if statement to add a certain sentence to the initial list based on the user’s input.

The append() function can add only one item at a time to your list. Instead of the append function, you can use an operator instead:

 my_list = [1, 2, 3, "hello", "rice", "code", 1.2]
my_list += ["Python is the best!!"]

Using the addition operator will ultimately be less efficient because it doesn’t modify your initial list. Instead, it creates a new list in memory and adds a new item to it. The append() function modifies your initial list directly.

3. The extend() Function

The extend() function is a built-in function that adds several items to an existing list at once. It takes in the new items as an argument and modifies your existing list with the argument. Here’s how to use the extend() function:

 my_list = [1, 2, 3, "hello", "rice", "code", 1.2]

my_list.extend(["item", "muo", 350])

print(my_list)

The extend() function can only take one argument, so you should add all your items to a list like the code above.

4. The reverse() Function

The reverse function simply rewrites your list in the reverse order. Here’s an example of the reverse function in use:

 my_list = [1, 2, 3, "hello", "rice", "code"]

my_list.reverse()
print(my_list)

To reverse a list without using the reverse() function, you would need to slice your list. Here’s an example:

 my_list = [1, 2, 3, "hello", "rice", "code"]

reversed_list = my_list[::-1]
print(reversed_list)

In the above example, my_list[::-1] creates a reversed copy of the original list. This means you’ll have two lists in memory, which is not the best approach if you simply want to reverse the original list.

5. The insert() Function

The insert() function modifies a list and adds an item to it like the append() function. However, the insert() function allows you to specify the index (position) of your new item in the list. Here’s an example:

 my_list = [1, 2, 3, "hello", "rice", "code"]

my_list.insert(0, "first")
print(my_list)

From the above code, this is the correct syntax to use the insert() function:

 your_list.insert(index, new_list_item)

6. The sort() Function

The sort() function takes a list of a particular data type and rearranges the elements in ascending order. Here’s an example:

 my_list = [1, 2, 10, 30, 3, 2.4]
my_list2 = ['code', 'rice', 'zion', 'hello']

my_list.sort()
my_list2.sort()

print(my_list)
print(my_list2)

If you use the sort() function on a list with different data types, such as strings and numbers, you will get a TypeError.

7. The count() Function

The count() function counts the number of times a specific element occurs in a list and returns the value to you. Here’s how to use it:

 my_list = ['code', 10, 30, 'code', 3, 'code', 'rice', 5]
print(my_list.count('code'))

Performing such an operation without the count() function would require you to write more code. Here’s an example:

 my_list = ['code', 10, 30, 'code', 3, 'code', 'rice', 5]
count_code = 0

for item in my_list:
    if item == 'code':
        count_code += 1

print(count_code)

The len() function will return the total number of elements in a list, while the count() function will return the number of times a specific element occurs in a list.

Using List Functions to Write Better Code

When working with lists in Python, it is important to use the available list functions to write efficient and clean code. They generally save you from writing complex and time-consuming code.

List functions enable you to easily perform common list operations, giving you more time to focus on other parts of your code.

MakeUseOf

How MySQL Tuning Improves the Laravel Performance

https://cdn.devdojo.com/posts/images/March2023/how-mysql-tuning-improves-laravel-performance4.jpg?w=1280&w=720

MySQL Configuration tuning is an important component of database management implemented by database professionals and administrators. It aims to configure the database to suit its hardware and workload. But beyond the database management sphere, the usefulness of MySQL Configuration tuning is largely ignored.

We hypothesize that MySQL tuning can significantly affect the performance of web apps. If we can showcase the value of MySQL tuning, we believe that enterprises and organizations may be keen to incorporate this practice on a larger scale.

How to Improve Laravel Application Performance

Improving application performance with tuning is best achieved with a comprehensive approach that addresses the following areas:

  • Server Resources – CPU, Memory, Storage
  • Software Configurations – Linux, Nginx, Php…
  • Database Management System (DBMS) Configurations – MySQL, PostgreSQL
  • Optimize database scheme and change indexes
  • Optimize applications – Code, Queries, Architecture…

Many experienced developers don’t look at database performance tuning as an opportunity to improve the performance of their apps because they know little about this domain. They spend a lot of time optimizing the codebase, but it reaches a point where it no longer brings a valuable result for the time and energy invested. Our research on how MySQL tuning positively affects the performance of popular open-source web applications is aimed at showcasing this fact to developers.

Testing Approach

Our testing procedure for Laravel Aimeos lets us compare the app’s performance before and after configuration using seeded data. By running the test with the default configuration first, we gain valuable control results to compare the tuned configuration against.

We used the following process to prepare and test each application:

  1. Deploy Laravel Aimeos.
  2. Seed database with data.
  3. Prepare test for JMeter.
  4. Run test for 10 minutes – Ran JMeter test using the Blazemeter performance testing platform.
  5. Tune MariaDB configuration – After default configuration testing, our setup remained the same, but MariaDB was tuned for workload, server resources, and database size.
  6. Re-run test – Repeated the JMeter test using Blazemeter for the tuned configuration.

We published JMeter tests, MySQL Status, and MySQL Variables during tests on Github.

What metrics we looked at?

The metrics we looked at during this research are:

  1. Response Time ( Latency ) is the time between sending the request and processing it on the server side to the time the client receives the first byte. It is the important metric that gives you insight into server performance.
  2. Queries per second is a metric that measures how many queries the database server executes per second.
  3. CPU Utilization.

We collected CPU Utilization and Queries per second metrics to compare the workload.

Laravel Aimeos

Aimeos Laravel is a popular e-commerce web app framework for creating online shops, marketplaces, and B2B apps. With Aimeos, users can create API-first eCommerce shops for Laravel that can scale to support over 1 billion items. It’s available in over 30 languages and has over 300,000 installs.

Testing Setup

To test Aimeos, we started the test with ten users, but we had to decrease the number of users because we couldn’t finish the test with the default configuration.

We seeded the database with 500 Mb data.
Our test duration was 10 minutes.

We used:

  • AWS EC2 instance c5.xlarge with installed Debian 11 as the operating system,
  • Apache as a web server,
  • MariaDB 10.5 set to the default configuration with database size 500 MB.

MySQL Configuration

The configuration used for Aimeos Laravel is as follows:

Tuned Configuration for Laravel Aimeos 500Mb

query_cache_type=1
query_cache_size=134217728
query_cache_limit=16777216
query_cache_min_res_unit=4096
thread_cache_size=0
key_buffer_size=8388608
max_allowed_packet=1073741824
sort_buffer_size=2097152
read_rnd_buffer_size=262144
bulk_insert_buffer_size=8388608
myisam_sort_buffer_size=8388608
innodb_buffer_pool_chunk_size=134217728
innodb_buffer_pool_size=805306368
max_heap_table_size=16777216
tmp_table_size=16777216
join_buffer_size=8388608
max_connections=151
table_open_cache=2048
table_definition_cache=1408
innodb_flush_log_at_trx_commit=1
innodb_log_file_size=201326592
innodb_log_buffer_size=16777216
innodb_write_io_threads=4
innodb_read_io_threads=4
innodb_file_per_table=1
innodb_flush_method=O_DIRECT
innodb_thread_concurrency=0
innodb_purge_threads=4
optimizer_search_depth=0
thread_handling=pool-of-threads
thread_pool_size=2

Testing Results

The Aimeos Laravel testing results showcased dramatic performance improvements between the default and tuned configurations.

The optimization of MySQL resulted in a significant improvement in the average server Response Time, which was reduced from 1.4 seconds to under 800 milliseconds.

Response Time ( Latency ) fell by 42% and average CPU utilization by 86%, while Queries per second increased by an incredible 291%, from 12 to 35 queries per second.

The graph of the results is available below:

AIMEO111.jpeg
S_Latency.pngResponse Time (ms), Aimeos Tuned MySQL Configuration vs Default
Aimeos_CPU1.pngCPU Utilization (%), Aimeos Tuned MySQL Configuration vs Default
Aimeos_QPS.pngQueries Per Seconds, Aimeos Tuned MySQL Configuration vs Default

We teamed up with Laravel developers Gevorg Mkrtchyan and Sergey Sinitsa from Initlab company to investigate this line of questioning and are very grateful for their expertise.
Sergey deployed Aimeos, and Gevorg prepared code for seeding the database.

Conclusion

Our testing procedure, using Aimeos Laravel, showed dramatic improvements in Response Time (Latency), CPU Utilization, and Queries per second after configuring the database server configuration.

Responce Time (Latency) dropped between 42%, while CPU Utilization fell 86%. Queries per second increased in Aimeos Laravel 500MB by 291%.

In conclusion, MySQL tuning is an essential aspect of database management that can have a significant impact on the performance of Laravel applications. Poorly performing web applications can lead to increased page load times, slow request handling, and a poor user experience, which can negatively affect SEO and sales. By optimizing the performance of web apps with MySQL tuning, enterprises and organizations can increase sales, pageviews, conversion rates, and SEO rankings.

With this research, we hope to showcase the value of MySQL tuning as a means to improve the performance of Laravel applications and encourage Laravel developers to consider this practice when optimizing the performance of their apps.

Using tools like Releem, databases can be quickly and easily configured for optimal performance, reducing the burden on software development teams.

Laravel News Links

Make your PHPUnit test runner look like Disk Defragmenter

https://repository-images.githubusercontent.com/692616979/67e6393f-1574-457d-89bc-327aee959e6a

This package generates a satisfying Defrag-style output when running your PHPUnit test suite.

Sample output

MS-DOS 6.x included a defrag utility that honestly was just so satisfying to watch. The 90s were a different time, folks. Disk defragmentation took about an hour and physically rearranged the data on your hard drive so it was more efficient to read off the disk.

Defrag Running in MS-DOS 6.22

Install the package via composer:

composer require benholmen/defrag --dev

Add the following lines to your phpunit.xml file:

<extensions>
    <bootstrap class="BenHolmen\Defrag\Extension"/>
</extensions>

Run PHPUnit as usual:

Of course, this produces the defrag output you’d expect.

Please see CONTRIBUTING for details.

The MIT License (MIT). Please see License File for more information.

Laravel News Links

SQL Programming Test in 2023

https://www.techbeamers.com/wp-content/uploads/2023/10/SQL-Programming-Test.png

Welcome to this amazing SQL programming test that will help anyone deeply interested in working with databases. This test will not only help you assess your strengths but also find gaps in your SQL programming skills. Ultimately, you’ll get to know which part of the SQL you need to focus on. SQL Programming Test – […]

The post SQL Programming Test in 2023 appeared first on TechBeamers.

Planet MySQL

10 Ways to Get Free AWS Credits

https://blog.finxter.com/wp-content/uploads/2023/10/image-182.png

5/5 – (1 vote)

????‍???? When looking for ways to get free AWS credits to be used on AWS services such as LLM training for your AI SaaS or EC2 instances, I discovered many resources that provide broken or stale links (or worse, harmful links), so I thought providing this list would be helpful for many Finxters.

To obtain free AWS credits, consider the following programs:

  1. AWS Activate: Ideal for startups, AWS Activate provides up to $100,000 in AWS promotional credits to help grow your business. With resources available quickly, it offers a low-cost, easy-to-use infrastructure.
  2. AWS Activate Founders: A part of AWS Activate, this package is for bootstrapped and self-funded startups. It offers credits, resources, and dedicated support to help startups build, test, and deploy on AWS.
  3. AWS Activate Portfolio: Aimed at startups affiliated with an AWS Activate Provider, this package provides up to $100,000 in AWS Activate Credits for AWS services or AWS Activate Business Support credits for technical support.
  4. Publish an Alexa Skill: Developers can earn a $100 AWS promotional credit for each Alexa skill published, aiding in unlocking your skills’ potential.
  5. AWS Webinars & Events: Attend AWS webinars, events, and conferences to earn AWS credits. Proof of attendance is required. Often, you’ll get an email inviting you to an event to gain AWS credits.
  6. AWS Educate: Designed for institutions, educators, and students to learn cloud skills, AWS Educate provides AWS credits for hands-on experience with AWS tech and training.
  7. AWS Cloud Credits for Research: This program evaluates academic research, awarding credits to researchers building cloud-hosted services or migrating research processes to the cloud.
  8. AWS Imagine Grant Program: Open to registered 501(c) nonprofit organizations, this grant provides up to $100,000 in AWS Promotional Credit to those using technology to address critical global issues.
  9. AWS Free Tier: A great option for new users to access AWS products at no cost up to specified limits for one year from account creation.
  10. Customer Surveys: I get an email from AWS asking me to complete a customer survey roughly every quarter. The survey takes 15 minutes to complete, and I’ll get a $100 credit.

If you want to learn the ins and outs of new technologies and polish your Python and OpenAI skill, feel free to check out our email academy by downloading this cheat sheet:

The post 10 Ways to Get Free AWS Credits appeared first on Be on the Right Side of Change.

Be on the Right Side of Change