A Peek Into the Soviet Computer Revolution

One of the largest and coolest collections of Soviet computers in the world resides in an apartment complex in Mariupol, Ukraine. Dmitriy Cherepanov started Club 8-bit with a small collection of computers built when the Soviet bloc was crafting its own personal computers.

It’s like looking into an alternative universe. The machines popular to kids growing up in the Soviet bloc look just different enough from what we’re familiar within the western world, but still carries that same since of nostalgia you or I might get for a Commodore 64 or Macintosh II.

Cherepanov has been collecting and restoring these computers for over a decade, and his museum of PCs is a fascinating look at the wide scope of the 80s PC revolution.

via Gizmodo
A Peek Into the Soviet Computer Revolution

Behold the power of shotgun

Good news from The Sun UK:

IN HIS SIGHTS SAS hero kills five terrorists in seven seconds with shotgun to stop ‘suicide bombing’

AN SAS hero armed with a shotgun reportedly killed five terrorists in just seven seconds to stop a suicide bombing attack.

The Brit soldier had stormed a bomb factory as part of an SAS raid on an ISIS outpost in Baghdad, Iraq.

As the SAS ‘breach team’ entered a courtyard, they were confronted by a group of heavily armed jihadis.

One of the brave Brits fired at them with his Benelli M4 Super 90 semi-automatic shotgun, killing three would-be bombers.

Another two terrorists appeared from a building and he reportedly shot them dead as well.

Several other jihadis then emerged, but immediately surrendered after seeing two of the bodies “didn’t have heads”, reports claim.

Ha ha ha, fuck yeah!!!

I’m reminded of what the great Clint Smith said about shotguns:

Shotguns at the right range with the right load will physically remove a chunk of shit off your opponent and throw that shit on the floor.  And you have to get someone to come in and clean this shit up with a shovel.”

Apparently that SAS operator was at the right range with the right load and that chunk of shit was Muhammad Bin Terrorist’s head.

“The terrorists were no more than a few feet away when the SAS team came face to face with them,” the source said.

“They had just finished morning prayers and were loading weapons into a vehicle. We now think they were about to carry out an attack.

“One of the breach team opened fire…it was a case of bang, bang, bang, then bang, bang. It was over in seven seconds.”

Suicide vests filled with slabs of plastic explosives and ball bearings were found on two of the dead jihadis.

The vests are understood to have been designed for mass casualties.

I remember being told a story by one of my Marine buddies.  They were having problems in Iraq where they would shoot some terrorist in a breaching operation but the terrorist had enough time before dying to pull the pin on a grenade or set off explosives and get the Marines who entered the room.

So a few of them bought 1 oz. deer slugs when they got rotated back home and loaded those up in their shotguns on their next deployment.

A 1 oz. deer slug hitting center of mass at no more than 10 yards is so traumatic that it shuts a human being off like a light.

There is nothing like the power of a 12 gauge scattergun at close range for ending threats.

via
Behold the power of shotgun

How Colored Pencils are Made

How Colored Pencils are Made

Link

We’ve seen footage of pencils being made before, but the guys at Faber-Castell want us to know that their process is the best. Watch as they make black leads from graphite and clay, and colorful ones from powders and wax, then sandwich them into wooden shells, and paint them to match.

via The Awesomer
How Colored Pencils are Made

ClamAV Anti-Virus Validator for Laravel

ClamAV Anti-Virus Validator for Laravel

ClamAV Validator is a Laravel package by Krishnaprasad MG that provides a custom virus validator based on ClamAV antivirus scanner for file uploads.

Some setup is required to use this package—you need to install ClamAV antivirus scanner on your server to make this package work.

Once you have configured your servers, you use this rule like any other validation rule:

$request->validate(['upload' => 'clamav']); 

To learn more about the underlying anti-virus engine, check out the ClamAV antivirus website.

You can learn more about the ClamAV Validator package, get full installation instructions, and view the source code on GitHub at sunspikes/clamav-validator.


Filed in: News


Enjoy this? Get Laravel News delivered straight to your inbox every Sunday.

No Spam, ever. We’ll never share your email address and you can opt out at any time.

via Laravel News
ClamAV Anti-Virus Validator for Laravel

The Empire Strikes Axe

The Empire Strikes Axe

Link

Star Wars tribute band Galactic Empire bangs out an awesome hard rock cover version of John Williams’ The Imperial March, giving the Empire’s most iconic theme song an appropriately razor-sharp edge to accompany all of their evil deeds. Even Emperor Palpatine approves, and he’s not easy to please.

via The Awesomer
The Empire Strikes Axe

Video Platforms Parser

Video Platforms Parser

The Video Platforms parser PHP package by @chojnicki is an easy-to-use SDK for multiple platforms like YouTube, Dailymotion, Facebook, and more.

The API usage is simple, you can get video info like this:

$info = $parser->get('https://www.youtube.com/watch?v=jofNR_WkoCE'); 

Here’s some sample output from Dailymotion, which is similar data you’ll see from any supported platform:

>>> \VideoPlatformsParser::get('https://www.dailymotion.com/video/x6qac05?playlist=x5xlnc'); => [ "id" => "x6qac05", "platform" => "dailymotion", "title" => "Simon Pegg on His Most Iconic Characters", "description" => "Simon Pegg breaks down his favorite and most iconic characters, including Tim from "Spaced," Shaun from "Shaun of the Dead," Nicholas Angel from "Hot Fuzz," Gary King from "The World's End," Scotty in "Star Trek," Unkar Plutt in "Star Wars: The Force Awakens," and Benji Dunn in the "Mission: Impossible" movies. Simon stars in "Mission: Impossible - Fallout," out in theaters July 27th.", "thumbnail" => "https://s1.dmcdn.net/v/OGOr51TU0A1fJD7He", "tags" => [ "celebrity", "iconic", "mission impossible", "simon pegg", "Season: Season 1", "Series: Iconic Characters", ], "api" => true, ] 

At the time of writing this package supports the following platforms:

  • YouTube
  • Dailymotion
  • Facebook
  • LiveLeak
  • CDA
  • Vimeo

You can learn more about this package, get full installation instructions, and view the source code on GitHub at chojnicki/video-platforms-parser.


Filed in: News


Enjoy this? Get Laravel News delivered straight to your inbox every Sunday.

No Spam, ever. We’ll never share your email address and you can opt out at any time.

via Laravel News
Video Platforms Parser

Getting started with Laravel APIs Part 2: Stoplight Studio

stoplight studio logo

stoplight studio logo

Designing an API can be easy. As long as you approach it in a logical way, and take each part separately, so you do not over complicate the process. For this article I am going to take a theoretical API and walk through how I would design it.

What we are building?

building blocks

building blocks

In this series we will be building a Training Log API, what is this? A training log is a simple referencing platform which allows individuals, or organisations, to make a log of what training has been completed as well as marking attendance for training courses.

Possibly one of the first steps for anyone creating an API is figuring out some sort of business logic, what will this system do extactly. These can theen be broken down into user stories/epics/features and go through some level of project management flow to create what will become our sprints.

Lets figure out what we need

As this is a tutorial, I will not be going completely indepth with what this system will do – it will be a trimmed down API to demonstrate a process. We can break down our requirmeents in a simple list at this stage. I like to think in a behavioural way at this stage:

  • As a user, I must be able to login and register
  • As a user, I must be able to see courses available
  • As a user, I must be able to enrol on a course
  • As a user, I must be able to attend training sessions as part of a course
  • As a user, I must be able to see my progress on a course and my completed courses

These are some pretty basic requirements for our training log API. However, even these simple requiremnts will give us a good insight into how we should approach designing our API.

Stoplight is a fantastic tool for designing your API, and the Models within your API. It has a great user interface, and has the benefit of creating openapi spec deocuments for you. For example:

model designer on stoplight studio

model designer on stoplight studio

Which in turn outputs:

title: User type: object description: An entity that can log into our system properties:  id:  type: integer  uuid:  type: string

For this style system a User is always one of the first things that I build, for the purpose of saving reading space I am ommiting none crucial fields from the models.

One we have an entity that is able to access our system we can start to define the connecting models which will in turn define what our API can do.

Breaking down our requirements

Going through our requirements above, it is easy to see how we could break down our resources and start to map relationships between them. Below I will break down the process:

As a user, I must be able to login and register

So a User model will need to be able to access our system – this part is easy enough to understand.

As a user, I must be able to see courses available

A User needs to be able to see available courses. So we will need a Course model and one of the requirements is that we need to see only available ones: so this will want a boolean flag to mark availability which we can apply through the API.

As a user, I must be able to enrol on a course

So we have a User and we have Courses. Now we need to enrol on them. The easiest option here would be to create a many to many relationship through a pivit table in Laravel it would look like:

<?php class User extends Model {  public function courses()  {  return $this->belongsToMany(Course::class);  } } class Course extends Model {  public function users()  {  return $this->belongsToMany(User::class);  } }

This, however, is not what I am going to do. For this I will create a new model called Enrolment which will capture both User and Course but will give us more extensibility than a standard pivot relation.

As a user, I must be able to attend training sessions as part of a course

So each course will want to be broken into sections, which will have an order to them. From this you can also gather that we will want some meta information to tag onto courses and sections. From working in EdTech previously, I know that a course/section will need to have topics that it covers so that an end user can figure out what they will learn on this course and if they want to do it.

To mark attendance, a simple pivot relation will suffice here for now. I do not think this is the time to think about CQRS and Event Sourcing – while it will give great control and insight into the data, it will be over engineering for what we need.

As a user, I must be able to see my progress on a course and my completed courses

So Users want to Enrol onto a Course, which will be tagged with Topics, which will allow them to Attend the many Sections and see progress along the way.

When you look at the feature requirements and the outputted list, there are other areas where improvements could be added – however it is easy to get carried away with yourself and over engineer an API at this point.

So, Stoplight Studio – putting the piecse together

Below you will see some examples (screenshots) and markup which you can use in your projects:

User Model

title: User type: object description: An entity that can log into our system properties:  id:  type: integer  uuid:  type: string

Course Model

title: Course type: object description: An Entity that Users can Enrol onto properties:  id:  type: integer  uuid:  type: string

Enrolment Model

title: Enrolment type: object description: A entity that allows the linking of Users to Courses properties:  id:  type: integer  uuid:  type: string  user:  $ref: ./user.v1.yaml  course:  $ref: ./course.v1.yaml

Section Model

title: Section type: object properties:  id:  type: integer  uuid:  type: string  course:  $ref: ./course.v1.yaml  order:  type: integer description: An entity that defines parts of a Course

Conclusion

Breaking down requirements can take a little bit of extra thought, but using a tool like Stoplight to visualise the information is very handy – and actually makes the task a lot nicer!

In the next part to this series we will be starting some Laravel code going through how we should set up Laravel for an API, and what changes we might want to consider.

via Laravel News Links
Getting started with Laravel APIs Part 2: Stoplight Studio

How To Export Data In Excel and CSV In Laravel 6 | maatwebsite/excel 3.1

How To Export Data In Excel and CSV In Laravel 6 | maatwebsite:excel 3.1

In this tutorial, we will see How To Export Data In Excel and CSV In Laravel 6 | maatwebsite/excel 3.1. If you want to up and running with basic laravel functionality, then go to my other article on this web blog called Laravel 6 Crud Example From ScratchIf you want to Generate PDF In Laravel, then check out Laravel 6 Generate PDF From View Example. For this example, we use the package called maatwebsite/excel version 3.1. So, our Laravel 6 and maatwebsite/excel 3.1.

Export Data In Excel and CSV in Laravel 6

When using the package in your application, it’s good to understand how the package functions behind the scenes. Following the behind-the-scenes will make you feel more comfortable and confident using the maximum potential of the tool.

Laravel Excel 3.1

🚀 Laravel Excel is intended at being Laravel-flavoured PhpSpreadsheet: a simple, but an elegant wrapper around PhpSpreadsheet to simplify the exports and imports.

🔥 PhpSpreadsheet is the library written in pure PHP and providing the set of classes that allow us to read from and to write to different type of spreadsheet file formats, like Excel and LibreOffice Calc.

Laravel Excel Features

  1. We can easily export collections to Excel.
  2. We can export queries with automatic chunking for better performance.
  3. We can queue exports for better performance.
  4. We can easily export Blade views to Excel.
  5. We can easily import to collections.
  6. We can read the Excel file in chunks.
  7. We can handle the import inserts in batches.

Requirements

  1. PHP: ^7.0
  2. Laravel: ^5.5
  3. PhpSpreadsheet: ^1.6
  4. PHP extension php_zip enabled
  5. PHP extension php_xml enabled
  6. PHP extension php_gd2 enabled

Step 1: Installation

Require the following package in the composer.json of your Laravel 6 project. The following command will download the package and PhpSpreadsheet.

composer require maatwebsite/excel
➜  laravel6 git:(master) ✗ composer require maatwebsite/excel
Using version ^3.1 for maatwebsite/excel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Installing markbaker/matrix (1.1.4): Downloading (100%)
  - Installing markbaker/complex (1.4.7): Downloading (100%)
  - Installing phpoffice/phpspreadsheet (1.9.0): Downloading (100%)
  - Installing maatwebsite/excel (3.1.17): Downloading (100%)
phpoffice/phpspreadsheet suggests installing mpdf/mpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing tecnickcom/tcpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing jpgraph/jpgraph (Option for rendering charts, or including charts with PDF or HTML Writers)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: barryvdh/laravel-dompdf
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: maatwebsite/excel
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
➜  laravel6 git:(master) ✗

Step 2: Configure package

The Maatwebsite\Excel\ExcelServiceProvider is auto-discovered and registered by default.

If you want to register by yourself, then add the ServiceProvider in config/app.php:

'providers' => [
    /*
     * Package Service Providers...
     */
    Maatwebsite\Excel\ExcelServiceProvider::class,
]

Excel facade is auto-discovered.

If you want to add it manually, add a Facade in config/app.php:

'aliases' => [
    ...
    'Excel' => Maatwebsite\Excel\Facades\Excel::class,
]

If you want to publish a config, run the vendor publish command:

php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider"
➜  laravel6 git:(master) ✗ php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider"
Copied File [/vendor/maatwebsite/excel/config/excel.php] To [/config/excel.php]
Publishing complete.
➜  laravel6 git:(master) ✗

This will create the new config file named config/excel.php.

Step 3: Create model and migration files

Type the following command.

php artisan make:model Disneyplus -m

Now, go to the [timestamp].create_disneypluses_table.php file and add the columns.

public function up()
{
        Schema::create('disneypluses', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('show_name');
            $table->string('series');
            $table->string('lead_actor');
            $table->timestamps();
        });
}

Now, migrate the database using the following command.

php artisan migrate

Step 4: Create a controller and routes

Next step is to create a DisneyplusController.php file.

php artisan make:controller DisneyplusController

Now, add the two routes inside the routes >> web.php file.

// web.php

Route::get('disneyplus', 'DisneyController@create')->name('disneyplus.create');
Route::post('disneyplus', 'DisneyController@store')->name('disneyplus.store');

Now, create two methods inside the DisneyplusController.php file.

<?php

// DisneyplusController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Disneyplus;

class DisneyplusController extends Controller
{
    public function create()
    {

    }

    public function store()
    {
        
    }
}

Step: 5 Create a form blade file for input the data

Now, inside the views folder, create one file called form.blade.php file. Add the following code.

@extends('layout')

@section('content')
<style>
  .uper {
    margin-top: 40px;
  }
</style>
<div class="card uper">
  <div class="card-header">
    Add Disneyplus Shows
  </div>
  <div class="card-body">
    @if ($errors->any())
      <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
              <li></li>
            @endforeach
        </ul>
      </div><br />
    @endif
      <form method="post" action="">
          <div class="form-group">
              @csrf
              <label for="name">Show Name:</label>
              <input type="text" class="form-control" name="show_name"/>
          </div>
          <div class="form-group">
              <label for="price">Series :</label>
              <input type="text" class="form-control" name="series"/>
          </div>
          <div class="form-group">
              <label for="quantity">Show Lead Actor :</label>
              <input type="text" class="form-control" name="lead_actor"/>
          </div>
          <button type="submit" class="btn btn-primary">Create Show</button>
      </form>
  </div>
</div>
@endsection

Step 6: Store data in the database

Now, we will write the two functions inside the DisneyplusController.php file.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Disneyplus;

class DisneyplusController extends Controller
{
    public function create()
    {
        return view('form');
    }

    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'show_name' => 'required|max:255',
            'series' => 'required|max:255',
            'lead_actor' => 'required|max:255',
        ]);
        Disneyplus::create($validatedData);
   
        return redirect('/disneyplus')->with('success', 'Disney Plus Show is successfully saved');
    }
}

So, in the above file, first, we have shown the form file, and then inside the store function, we check for validation and then store the data into the database.

Also, add the fillable fields inside the Disneyplus.php model file.
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Disneyplus extends Model
{
    protected $fillable = ['show_name', 'series', 'lead_actor'];
}

Now, go to this route: https://ift.tt/2Lvph4g or http://localhost:8000/disneyplus

You will see one form. Try to save the data, and if everything in the code is right, then, you will see one entry in the database.

Step: 7 Create a view file for display the data.

Before we create a view file, we need to add one route inside the web.php.

// web.php

Route::get('disneyplus/list', 'DisneyplusController@index')->name('disneyplus.index');

Now, create a view file called list.blade.php file. Add the following code.

@extends('layout')
@section('content')
<table class="table table-striped">
  <thead>
    <th>ID</th>
    <th>Show Name</th>
    <th>Series</th>
    <th>Lead Actor</th>
    <th>Action</th>
  </thead>
  <tbody>
    @foreach($shows as $show)
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    @endforeach
  </tbody>
</table>
@endsection

Now, add the code inside the index() function of DisneyplusController.php file.

public function index()
{
        $shows = Disneyplus::all();

        return view('list', compact('shows'));
}

Now, go to the http://laravel6.test/disneyplus/list or http://localhost:8000/disneyplus/list

You will see the listing of the shows.

Step 8: Create Exports class

You may do this by using the make:export command.

php artisan make:export DisneyplusExport --model=Disneyplus

The file can be found in app/Exports directory.

The file DisneyplusExport.php is following.

<?php

namespace App\Exports;

use App\Disneyplus;
use Maatwebsite\Excel\Concerns\FromCollection;

class DisneyplusExport implements FromCollection
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        return Disneyplus::all();
    }
}

If you prefer to create a export manually, you can build the following in app/Exports.

Step 9: Write the export function

Inside the DisneyplusController.php file, add the following code.

// DisneyplusController.php

use App\Disneyplus;
use App\Exports\DisneyplusExport;
use Maatwebsite\Excel\Facades\Excel;

public function export() 
{
        return Excel::download(new DisneyplusExport, 'disney.xlsx');
}

So, our final file looks like below.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Disneyplus;
use App\Exports\DisneyplusExport;
use Maatwebsite\Excel\Facades\Excel;

class DisneyplusController extends Controller
{
    public function create()
    {
        return view('form');
    }

    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'show_name' => 'required|max:255',
            'series' => 'required|max:255',
            'lead_actor' => 'required|max:255',
        ]);
        Disneyplus::create($validatedData);
   
        return redirect('/disneyplus')->with('success', 'Disney Plus Show is successfully saved');
    }

    public function index()
    {
        $shows = Disneyplus::all();

        return view('list', compact('shows'));
    }

    public function export() 
    {
        return Excel::download(new DisneyplusExport, 'disney.xlsx');
    }
}

Finally, add the route to be able to access the export:

// web.php

Route::get('export', 'DisneyplusController@export');

Also, add the link to the Export inside the list.blade.php file.

@foreach($shows as $show)
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td><a href="">Export</a></td>
    </tr>
@endforeach

Okay, now finally go to the https://ift.tt/32B5QMQ, and now you can see one link called Export.

Click on the Export link, and you will see the disney.xlsx file inside your Download folder.

Exporting collections in CSV in Laravel 6

By default, the export format is determined by the extension of the file.

public function export() 
{
        return Excel::download(new DisneyplusExport, 'disney.csv');
}

It will download the CSV file.

If you want to configure the export format explicitly, you can pass it through as 2nd parameter.

You can find more details about export in different formats on this link.

Finally, How To Export Data In Excel and CSV In Laravel 6 | maatwebsite/excel 3.1 is over.

The post How To Export Data In Excel and CSV In Laravel 6 | maatwebsite/excel 3.1 appeared first on AppDividend.

via Planet MySQL
How To Export Data In Excel and CSV In Laravel 6 | maatwebsite/excel 3.1