Robot Sets Up 100,000 Dominoes

http://img.youtube.com/vi/8HEfIJlcFbs/0.jpg

Robot Sets Up 100,000 Dominoes

Link

Setting up dominoes can be time-consuming and requires a steady hand. We’ve seen robots that can stand one domino at a time. Mark Rober and his engineering pals presents DOM – a custom-built robot that can set up 300 dominoes at a time. The robot arm and Hot Wheels track loading system is equally awesome.

The Awesomer

Robot Sets Up 100,000 Dominoes

http://img.youtube.com/vi/8HEfIJlcFbs/0.jpg

Robot Sets Up 100,000 Dominoes

Link

Setting up dominoes can be time-consuming and requires a steady hand. We’ve seen robots that can stand one domino at a time. Mark Rober and his engineering pals presents DOM – a custom-built robot that can set up 300 dominoes at a time. The robot arm and Hot Wheels track loading system is equally awesome.

The Awesomer

Laravel Loggable models

https://opengraph.githubassets.com/db0e6a23a6df1faaf7e544f2a9b8ab02dba173b75fcf45e2badc54b4b6c0c8d4/alkhachatryan/laravel-loggable

Laravel Loggable – Log you model changes

Software License
Packagist Version
CodeFactor Grade
Total Downloads

Laravel Loggable is a package for eloquent models, which will monitor the changes on the models and log.
It supports two drivers: File and Database.

Features

  • High-configurable
  • Two drivers (database and file)
  • Possibillity to use two drivers at once
  • Possibillity to select the columns for the model which should be logged
  • Possibillity to select the actions for the model which should be logged (create, edit, delete)
  • Facade-based structure to fetch the logs for specific model
  • Much more

Logs

Installation

Install the package.

composer require alkhachatryan/laravel-loggable

Publish the configuration file

php artisan vendor:publish --tag=loggable

Run migration

php artisan migrate

Configuration

Open the configuration file at /config/loggable.php

Set the driver whhich will log the model changes (can be both).
However, it’s recommended to use the database driver so you can fetch the logs in the future.

That’s it!

Usage

class Post extends Model
{
    /** Include the loggable trait */
    use Loggable;
    
    /** Specified actions for this model */
    public $loggable_actions = ['edit', 'create', 'delete'];

    /** Specified fields for this model */
    public $loggable_fields  = ['title', 'body'];

    protected $fillable = ['title', 'body'];
}
Retriving the model logs via Facade
Loggable::model('App\Post');
Retriving the model logs via Model
LoggableModel::whereModelName('App\Post')->orderBy('id', 'DESC')->paginate(10);
Event

You can use the event Alkhachatryan\LaravelLoggable\Events\Logged in pair with your listeners.

Changelog

Please see CHANGELOG for more information what has changed recently.

Todo

Tests!!! Tests!!! Tests!!!

Security

If you discover any security-related issues, please email info@khachatryan.org instead of using the issue tracker.

License

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

Laravel News Links

Memes that made me laugh 68

https://1.bp.blogspot.com/-YLs1tgKch6E/YP3OolfRIHI/AAAAAAAAtOc/isHXmpN9yVk4ExVMVgp0G0a1FbO5qPWXgCPcBGAsYHg/

 

… plus a couple that made me think, gathered from the Internet over the past week.  Click any image for a larger view.

More next week.

Peter

Bayou Renaissance Man

Olympics Broadcaster Announces His Computer Password on Live TV

In what is, at least so far, the biggest cybersecurity blunder of the Tokyo Olympics, an Italian TV announcer did not realize he was on air when he asked the password for his computer. Motherboard reports: "Do you know the password for the computer in this commentator booth?" he asked during the broadcast of the Turkey-China volleyball game, apparently not realizing he was still on air. "It was too hard to call the password Pippo? Pippo, Pluto or Topolino?" he complained, referring to the Italian names for Goofy, Pluto and Mickey Mouse. The snafu was immortalized in a video posted on Twitter by cybersecurity associate professor Stefano Zanero, who works at the Polytechnic University of Milan. A source who works at Eurosport, the channel which was broadcasting the volleyball game, confirmed that the video is authentic.
A colleague of the announcer can be heard in the background saying the password depends on the Olympics organizers, and asking the announcer if it’s on a paper or post it close-by. Turns out the password was "Booth.03" after the number of the commentator’s booth. "Even the dot to make it more complicated, as if it was NASA’s computer," he said on the air. "Next time they will even put a semicolon." "Ma porca miseria," he concluded, using a popular italian swearing that literally means "pork’s misery" but is more accurately translated to "for god’s sake."


Read more of this story at Slashdot.

Slashdot

Comic for July 25, 2021

https://assets.amuniversal.com/847ca950b16301396557005056a9545d

Thank you for voting.

Hmm. Something went wrong. We will take a look as soon as we can.

Dilbert Daily Strip

How to Implement Laravel Livewire Infinite Pagination

https://postsrc.com/storage/QYYl32nR4cIPwSVOmv1SCyGqHYlrqtlxOL3gUPKY.jpg

In this post, you’ll learn how to implement an “infinite pagination” component in Laravel with the help of Livewire. The cursor pagination will be used to paginate the data for faster and efficient querying over your model. The steps are very simple so let’s get started.

Laravel Livewire Infinite Pagination Example

1 – Install the Required Dependency

The dependency that you will need to have is “

Laravel Livewire

” and “

TailwindCSS

“.

composer require livewire/livewire

For the TailwindCSS you can make use of the available CDN otherwise you can refer to the

Installation Guide

for more options.

<link href="https://unpkg.com/[email protected]^2/dist/tailwind.min.css" rel="stylesheet">

Full Base Layout Code
The full layout should be as follows. If you have an existing layout, do put the “@livewireStyles”, “@livewireScripts” and “” on the necessary location.

// views/layouts/app.blade.php

<!DOCTYPE html>
<html class="h-full">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Laravel App</title>
    <link href="https://unpkg.com/[email protected]^2/dist/tailwind.min.css" rel="stylesheet">
    @livewireStyles
</head>
<body class="font-sans antialiased bg-gray-50 h-full">

    <main class="mt-12 min-h-full">
        
    </main>

    @livewireScripts
</body>
</html>

2 – Create “InfinitePostListing” Livewire Component
Now that you have the layout code ready in place, it’s time to create a new “InfinitePostListing” Livewire component and you can use the command line to generate it.

php artisan livewire:make InfinitePostListing

Upon successfully creating the component you should see the command line output like below.

COMPONENT CREATED  🤙

CLASS: app/Http/Livewire/InfinitePostListing.php
VIEW:  resources/views/livewire/infinite-post-listing.blade.php

3 – Define the Route Endpoints
Before we start with the component logic, define the route in “routes/web.php” to provide the access endpoint.

# routes/web.php

Route::get('/infinite-posts', App\Http\Livewire\InfinitePostListing::class)
    ->name('posts.infinite-posts');

4 – InfinitePostListing Livewire Component Logic
Inside the Livewire component, you’ll need to define 3 methods:

  1. mount() – The lifecycle method to initialize the data 
  2. loadPosts() – The method to load more posts
  3. render() – The method to render the “views”

public function mount() {}

public function loadPosts() {}

public function render() {}

Other than that you will need to have 3 properties and they are the:

  1. $posts – To hold the posts data
  2. $nextCursor – to hold the next pagination cursor
  3. $hasMorePages – to determine whether there are more records
public $posts;

public $nextCursor;

public $hasMorePages;

The full code example will be as follows. Do note that Laravel Livewire component only accepts PHP “scalar types”,  “Models” and “Collection” so other than those types, the component will throw out an error.

<?php

namespace App\Http\Livewire;

use App\Models\Post;
use Illuminate\Pagination\Cursor;
use Illuminate\Support\Collection;
use Livewire\Component;

class InfinitePostListing extends Component
{
    public $posts;

    public $nextCursor;

    public $hasMorePages;

    public function mount()
    {
        $this->posts = new Collection();

        $this->loadPosts();
    }

    public function loadPosts()
    {
        if ($this->hasMorePages !== null  && ! $this->hasMorePages) {
            return;
        }

        $posts = Post::cursorPaginate(12, ['*'], 'cursor', Cursor::fromEncoded($this->nextCursor));

        $this->posts->push(...$posts->items());

        if ($this->hasMorePages = $posts->hasMorePages()) {
            $this->nextCursor = $posts->nextCursor()->encode();
        }
    }

    public function render()
    {
        return view('livewire.infinite-post-listing')->layout('layouts.base');
    }
}

So a little bit explanation of the code above, there’s 5 important flow that you have to know.

  1. When the component is loaded, the “mount()” method will be triggered and the “posts” property is initialized with an empty Laravel Collection.
  2. Then the “loadPosts()” method is triggered to load the “posts” that are retrieved by the “cursorPaginate” method.
  3. The pagination will be determined by the “nextCursor” property which is encoded and decoded every time the “loadPosts” method is called.
  4. The retrieved data is “pushed” to the “posts” collection.
  5. Finally, the “render()” method renders the view for the user to see.
5 – InfinitePostListing Views

The views will loop through the “posts” properties and for this example, simple styling is applied with “TailwindCSS” classes. Assuming the “Post” model has a “title” and “body” column, you can access it as you normally would in Laravel Blade file.

Infinite Load Posts

The code for the views will be as follows. Do note that we are including the “skeleton” loading component to show that the post are being loaded when scrolling to the bottom of the page.

<!-- /resources/views/livewire/infinite-post-listing.blade.php -->

<div class="container p-4 mx-auto">
    <h1 class="font-semibold text-2xl font-bold text-gray-800">Infinite Load Posts</h1>

    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8 mt-4">
        @foreach($posts as $post)
            <a href="#" class="block p-4 bg-white rounded shadow-sm hover:shadow overflow-hidden" :key="$post['id']">
                <h2 class="truncate font-semibold text-lg text-gray-800">
                    
                </h2>

                <p class="mt-2 text-gray-800">
                    
                </p>
            </a>
        @endforeach
    </div>

    @if($hasMorePages)
        <div
            x-data="{
                init () {
                    let observer = new IntersectionObserver((entries) => {
                        entries.forEach(entry => {
                            if (entry.isIntersecting) {
                                @this.call('loadPosts')
                            }
                        })
                    }, {
                        root: null
                    });
                    observer.observe(this.$el);
                }
            }"
            class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8 mt-4"
        >
            @foreach(range(1, 4) as $x)
                @include('partials.skeleton')
            @endforeach
        </div>
    @endif
</div>

The skeleton component can be as simple as below.

<!-- partials/skeleton.blade.php -->

<div class="mt-4 p-4 w-full mx-auto bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-800 shadow-sm rounded-md">
    <div class="animate-pulse flex space-x-4">
        <div class="flex-1 space-y-4 py-1">
            <div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4"></div>
            <div class="space-y-2">
                <div class="h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
                <div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-5/6"></div>
                <div class="h-4 bg-gray-200 dark:bg-gray-700 rounded w-5/6"></div>
            </div>
        </div>
    </div>
</div>
Skeleton Component

Now when you scroll to the end of the page you will see the skeleton component and within a split second the next posts will be loaded.

By now you should be able to implement Laravel Livewire Infinite pagination and If you found this tutorial to be helpful, do share it with your friends, cheers and happy coding 🍻.

Related Posts

Laravel News Links

Giant Plasma Cannon

https://theawesomer.com/photos/2021/07/giant_plasma_cannon_t.jpg

Giant Plasma Cannon

Link

If you’ve never seen one, a plasma popper is an awesome-looking device that directs a ball of propane gas through a series of twisted tubes. Charles over at Hacksmith Industries was asked to build a plasma popper, then leveled up the challenge with bigger and bigger versions, culminating with a massive fireball maker.

The Awesomer

Learn to Code Python Free With These Courses and Apps

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2021/07/pythononflash.jpg

Python is a powerful programming language that is very popular and widely used. It has various real-world applications in data science, web development, artificial intelligence, data analytics, and much more.With so many available resources, knowing where to begin is sometimes overwhelming.

Learning Python can become even more confusing if you do not understand its basic building blocks. Without these fundamentals, you cannot build anything interesting. Luckily for you, though, we’ve compiled a list of free Python courses and apps that you can utilize to kickstart your Python career.

Keep reading to find out where you can learn Python free.

Where Can I Find a Free Python Course?


If you are someone who’s just started learning to code or are thinking about coding for the first time, then you’re going to need to start with the fundamentals. Perhaps you want to learn Python to start working as a freelancer, or maybe you’re thinking about a career change; whatever your reasons, maybe Python is a brilliant and versatile programming language that can help you achieve your personal goals.

For beginners looking for a free Python course, we recommend starting with the basic syntax and programming structure. Once you have acquainted yourself with the syntax, you can learn Python for a specific chosen area of interest.

Related: Coding Apps That Make Programming Easier

You do necessarily need to master Python syntax; this is something that you will learn while working on different projects. We recommend learning Python 3, since Python 2 is an outdated version that is no longer supported.

Here are some courses and apps you can use to learn the basics of Python for free:

Be careful not to spend too much time learning the syntax, because this is something that you can always come back to. A few weeks of practicing the basic Python syntax should be more than enough. After getting the hang of the fundamentals, you can go ahead and start working on Python projects in an area that interests you.

Learn Python For Data Science


Python is the most popular programming language in data science and machine learning (ML); it can solve complex problems efficiently with the aid of dedicated data analysis libraries. The demand for data scientists keeps increasing exponentially. If you learn Python for data science, artificial intelligence (AI), or machine learning, it will help open many career opportunities for you.

Bear in mind that data science is a vast field, and you need to learn many different skills to have a successful career in this area. These skills can include machine learning, text analysis, social network analysis techniques, information visualization, standard Python libraries such as Pandas, NumPy, and more.

Related: The Beginner’s Guide to Regular Expressions With Python

Here are some free data science-related python courses that you can use to kickstart your career as a data scientist:

  • Applied Data Science with Python Specialization: This course specialization is offered by the University of Michigan on Coursera, and will teach you data analysis skills and apply data science methods and techniques. The specialization includes five different courses that cover a range of different data science techniques.
  • Python Basics for Data Science: Offered by IBM on edX, this course will teach beginners the basics of Data Science and enable them to work on independent projects.
  • Python for Data Science, AI & Development: This course specialization is offered by IBM on Coursera and is comprehensive. It will cover Python basics, data structures, Python libraries, and APIs, and data collection.
  • Introduction to Computational Thinking and Data Science: This course is available for free on MIT OpenCourseWare and is a good place for students to understand the basics of Data Science and its application.

Please note that on Coursera, some courses are free and will provide you with a completion certificate at the end of the course. Other courses are paid, but you can still learn for free if you choose to audit the course. If you choose to audit a course, Coursera will not provide you with a completion certificate—but you will have access to the entire course content.

Learn Python for Web Development


Python’s sheer power and versatility make it an incredible platform for web development. You can use Python to create web-based applications in combination with JavaScript. Django (pronounced "jango") is a popular framework for web development and is used to create high-level websites. It is essentially a backend framework for Python and is very secure and easy to use.

Here are some free courses you can use to learn web development in Django:

  • Django for Everybody: This specialization is offered by the University of Michigan on Coursera and introduces Python programmers to building websites on the Django framework. The four courses included in this specialization will teach you to build web applications, use JavaScript and JQuery/JSON in Django, and much more.
  • Web Programming with Python and JavaScript: This course is offered by Harvard University and dives into designing and implementing web applications with Python, Javascript, and SQL.
  • A Beginners Guide to Django at Udemy: This free course on Udemy will take you through the basics of Django and get you started with building websites.

Learn Python Free for Hardware and Robotics

Python is very popular in applications for robotics and hardware engineering. You can utilize platforms such as Raspberry Pi and Arduino for coding with Python.

Here are some courses that can help learn Python for Robotics and Hardware:

Your Next Free Python Course Is Just a Few Clicks Away

Learning Python is never a bad idea, regardless of your reasons. Coding is a vital skill in the fast-growing technology world of today, and Python is at the center of it.

It is best to start with the basic syntax and then dive into small Python projects. Once you are comfortable with the fundamentals of Python, you should start looking into courses and projects of your interest. Hands-on practice with projects will allow you to master your skills and be a valuable addition to your resume.

MUO – Feed