British Museum launches revamped online collections database early with 1.9M images

British Museum launches revamped online collections database early with 1.9M images

https://ift.tt/2SnPBjM

On Tuesday, April 28, the British Museum announced that it is the latest institution to make digitized images of its various collections available for free online. The ‘revamped’ online collections database now contains 1.9 million images that are offered to the public under the restrictive Creative Commons BY-NC-SA 4.0 license, which allows for non-commercial use with attribution.

According to the announcement tweet from British Museum, its team expedited the release of this new online database so that the public can browse the museum’s collections while in quarantine at home. The launch follows similar big digitized collections launches from institutions like Paris Musées and The Smithsonian.

This revamp simplifies things for public users who are no longer required to register in order to use the images. Going forward, anyone can browse the online collections database and download any of the 1.9 million images for non-commercial use with attribution. Each image is scanned at a high-resolution; the online viewer enables users to zoom in on objects to view fine details.

According to the British Museum, this collection features two million years’ worth of history that spans six continents. The museum digitized nearly 4.5 million objects, making it the largest online collection of its kind. British Museum explains that its revamped interface not only provides access to these images for free but also makes it easier for the public to find the specific items they’re looking for.

The online collections are vast, including everything from ancient Egyptian sculptures to Assyrian artifacts, Greek objects, Iranian jewelry, artwork from the Roman Empire and much more. Viewers can sort through the content based on collection galleries, as well as searches using museum numbers, persons, places and keywords.

This launch is a welcomed addition to the growing body of digitized artifacts and other works made available to the general public online. However, the release isn’t without criticism. Unlike The Smithsonian and Paris Musées, both of which released their online collections with Creative Common 0 licenses, the British Museum’s collection is made available under the CC BY-NC-SA 4.0 license.

Author and activist Coro Doctorow highlighted some of the concerns related to this in a recent tweet thread, pointing out, among other things, that UK law states that copyrights can only subsist in cases where the work is ‘original in the sense that it is the author’s own ‘intellectual creation.” Among other things, the nation’s copyright law [PDF, page 3] notes that it’s ‘unlikely that what is merely a retouched, digitised image of an older work can be considered as ‘original.”

Critics have also pointed out that Wikimedia Commons only allows images that aren’t ‘subject to copyright restrictions which would prevent them being used by anyone, anytime, for any purpose,’ meaning the British Museum’s digitized collections can’t be included in the Commons catalog.

Despite these concerns, the revamped database is a step in the right direction. The British Museum has been commended for the effort it put into this launch — not just for the high-resolution images and scans of the content, but also the number of tools and information the museum provides for each listing.

The database includes the name(s) of the original excavator who discovered the items, where the object was found, the materials it is made from, the technique used to craft it, its size and weight, its present condition, where it was acquired, its registration number and more. The collection is available here.

Via: ianVisits

photography

via News: Digital Photography Review (dpreview.com) https://ift.tt/2burdFr

April 30, 2020 at 11:26AM

Robot Hummingbird Films Butterflies

Robot Hummingbird Films Butterflies

https://ift.tt/2SiHlkY

Robot Hummingbird Films Butterflies

Link

Nature photographers John Downer Productions flew a realistic, robotic hummingbird deep into a forest packed with hundreds of millions of monarch butterflies. The drone captured amazing footage of the swarm as they awoke from their long winter’s nap in Mexico. From the BBC Series Spy in the Wild.

fun

via The Awesomer https://theawesomer.com

April 30, 2020 at 11:15AM

What to Do With an Old Nintendo Wii: 12 Fun DIY Ideas and Projects

What to Do With an Old Nintendo Wii: 12 Fun DIY Ideas and Projects

https://ift.tt/2zAbh5w

Over 100 million Nintendo Wii consoles were bought between 2006 and 2013. As such, there’s a good chance you own one. Your old Nintendo Wii is probably stuck at the back of a cupboard or acting as a particularly expensive doorstop.

After all, so many new consoles have come along to replace it. But does your old Wii console really have to sit unused? No!

If you’ve been wondering what to do with your old Nintendo Wii, here’s a list of ways to repurpose it.

Install Homebrew on Your Old Nintendo Wii Console

Incredibly it’s not difficult to find new uses for your Nintendo Wii. After all, like any game console, it’s basically a computer hooked up to your TV. While this doesn’t mean much in normal circumstances—you’re locked to Nintendo-approved activities—jailbreaking the Wii extends the possibilities considerably.

Jailbreaking is remarkably simple. Our guide to installing the Homebrew Channel on the Wii with the LetterBomb hack shows you how. Once you’re done with that, head back here to find some new uses for your old Wii. Anything that can run on the Homebrew Channel can be installed from its repository of software, or downloaded to PC and copied to your Wii’s SD card.

Before you start, make sure you have a USB keyboard attached. This will help you to make the most of these new Nintendo Wii projects.

1. Install Homebrew Wii Games and Apps

One of the main reasons to use Homebrew is to install additional software. Among the list of titles available is a host of games. Some of these are original creations, while others are ports of open source games from other platforms.

Simply browse the list in the Homebrew Channel (HBC) and install the software. Moments later, it will be ready to use.

2. Develop Your Own Homebrew Games

You don’t have to rely on software already created by the community—you can make your own. A vast collection of homebrew games is available in HBC, and anyone can develop their own to share.

For details, check the list of Wii development tools available to download and install. These typically run on Windows or Linux PCs, with a few supporting Macs. When you’re done, upload games (or other software) to the HBC community for others to use.

3. Turn Your Old Wii Console Into a Children’s Media Center

Your Wii is permanently hooked up to your television; your computer probably isn’t. So why not use your Wii to play videos on your TV? These days media center apps (such as YouTube and Netflix) aren’t available for the Wii—but you can use WiiMC.

A media center suite for the Wii, WiiMC is easily set up via the Homebrew Browser. WiiMC can browse media shared over a network or stored on a SD card or USB hard drive. Note that WiiMC has limitations, however.

High definition (HD) video won’t play on the Nintendo Wii due to hardware shortcomings. Other drawbacks include a lack of 5.1 surround sound. This makes a Nintendo Wii running WiiMC more suitable for children than adults.

4. Use Your Wii to Play DVDs

With WiiMC installed you can also play DVDs on your Nintendo Wii. This will not work on newer Wiis, but if you bought an early model you’ve got yourself a DVD player.

This is significant because by default the Nintendo Wii doesn’t play DVDs. Despite using DVD data discs and having all of the necessary hardware to read DVD videos, the feature was disabled.

Resolutions of up to 1280×720 will play on the Wii, depending on video format. Note that while DVDs can play, CDs won’t.

5. Turn Your Wii Into a PC With Wii-Linux

Another amazing way to take advantage of the HBC on your Wii is to turn the console into a PC.

Wii-Linux can be installed via the Homebrew Channel, allowing PowerPC-compatible Linux applications to run. Many distributions for the Wii are available, including ones based on Debian, Gentoo, and Arch Linux.

For the best results (including Wi-Fi and USB support) Wii-Linux should be installed using the BootMii exploit.

Wii-Linux is also known as GC-Linux and as such can run on a Nintendo GameCube.

Not keen on Linux? The Wii can also run FreeBSD.

6. Install Minecraft Server on Your Old Wii

Not only can your old Wii run Linux, it can also host a Minecraft server. Want to play Minecraft network games? You’ve already got the hardware to do it!

This video outlines how the Minecraft server Java edition can be installed on the Nintendo Wii. Surprisingly, the result is a smooth hosting experience, although we expect that multiplayer would be limited to under 10 players.

It’s not a massive surprise that Minecraft server can run on the Wii. The modest Raspberry Pi can also host Minecraft network games.

Own multiple Wiis? You can also install a dedicated version of Minecraft, called WiiCraft.

7. Control Your PC with WiiVNC

VNC is one of the easiest ways to control one computer with another.

It’s not just limited to computers, however. You can install VNC on tablets and phones, for example. You can also stick it on your Wii if you’ve installed the Homebrew Channel.

Think WiiMC is too limited as a media player? Simply run content on a PC, VNC to it, and stream the content to your TV through the Wii. This project uses WiiVNC, available to install from HBC.

8. Use Your Wii as an Alarm Clock

An old Nintendo Wii can even get you up in the morning. The Strobe Alarm Clock is a homebrew project that lets you run a clock in full screen view.

Just remember to leave the Wii and your display switched on at bedtime!

9. Keep Time With a Wii Metronome

If you’re a musician, having a metronome to hand might be useful. While you can get metronome mobile apps, one running on your Wii is easier to control thanks to the Wiimote.

Metronome lets you specify a custom beat, from 30 to 300BPM. Simple and easy to use, this is a great idea that is effectively implemented.

10. Explore the World With WiiEarth

Love exploring the world using software like Google Earth? With WiiEarth you can do the same thing from your couch, using only your WiiMote.

This service uses map data from both Google Maps and Bing. Cycle between the options using the 2 button on your WiiMote to if something isn’t working. It’s a great way to quickly show someone directions or explore what your town looks like from the sky.

11. Install Emulators to Play Classic Games

Via the Virtual Console, Wii users already have access to a vast library of classic console and arcade games. Want more titles? With a little work you can emulate classic consoles including the NES and Game Boy Advanced.

MAME arcade emulators, PlayStation 1, and all Sega consoles can also be emulated on a Nintendo Wii running Homebrew.

Check our list of the best emulators you can run on the Nintendo Wii for full details.

12. Run DOS Software on Your Wii

It isn’t just retro console games you can run on a Nintendo Wii with the HBC. A version of DOSBox has been released for the Wii, which means hundreds of classic PC games will run.

So long as you have a keyboard and mouse connected to your Wii, these games should work with little issue. You’ll mostly be limited to mouse-driven adventures and strategy games—first person shooters don’t run too well in DOSBox on the Wii. Fortunately, most of the ones you want to play will run straight from HBC.

Check the DOSBox Wii compatibility list for full details about which games you should take the time to install.

12 Awesome Things You Can Do With an Old Wii

This is only a sample of what your Wii can do, of course: there is a lot more quality homebrew software out there, and if you know what you’re doing as a programmer you could probably make more. The only real limit is imagination.

  1. Install independent homebrew community games
  2. Develop your own indie projects
  3. Turn your Wii into a media center
  4. Play DVDs on the Wii
  5. Install Linux and use the Wii as a PC
  6. Host Minecraft network games
  7. Remotely control your PC over VNC
  8. Use the Wii as an alarm clock
  9. Install a metronome for music practice
  10. Explore with WiiEarth
  11. Play classic console games
  12. Run old PC games

It’s a good idea to regularly visit the WiiBrew wiki page for the latest homebrew releases for the Nintendo Wii. Meanwhile, if you also have the Wii’s successor, find out how to make the Wii U useful with homebrew.

Image Credit: Carlos Gutierrez/Flickr

Read the full article: What to Do With an Old Nintendo Wii: 12 Fun DIY Ideas and Projects

non critical

via MakeUseOf.com https://ift.tt/1AUAxdL

April 29, 2020 at 01:02PM

8 Inexpensive Upgrades for the Remington 870

8 Inexpensive Upgrades for the Remington 870

https://ift.tt/2yPnrr2

With more than 11 million built, it is safe to say the Remington 870 is a very popular shotgun choice.

This does not mean it comes from the factory perfect or exactly how you want it.

Below, you will see a list of eight ways to upgrade your 870 without hurting your credit card.

1. Magpul MOE M-LOK Replacement Forend

This drop-in forend has three great benefits. It is lighter, with much greater texture for more sure manipulation.

Both the front and rear have positive stop points to keep your hand from sliding off under stiff actuation, especially in wet weather.

Lastly, the M-LOK slots allow for direct mounting of accessories if that is a desire.

2. Uncle Mike’s Swivel Cap Set

Most 870’s do not have a simple option for mounting a sling. For a few dollars, it becomes a lot simpler to transport your shotgun on your shoulder.

Anyone who has turkey hunted without a sling, knows how much of a juggling act it can be with your seat, your pack, your assortment of calls and the shotgun.

This swivel cap set makes life a whole lot simpler.

Uncle Mike's Shotgun Swivel Cap

3. Aimtech Scope Mount

This is a must-have for those wanting an optic on a Remington 870 that is not drilled and tapped.

Whether you are turkey hunting, deer hunting with slugs or mounting a red dot for home defense, on those guns without the option, this is a simple fix.

Aimtech Remington 870 Scope Mount
 

4. Remington Supercell Recoil Pad

This recoil pad has a tough outer skin for long life. Below that skin, is a thick, highly aerated foam that is full of millions of little air bubbles.

These air bubbles act as mini shock absorbers as they each flatten under recoil, spreading the load and increasing the duration of the impulse.

Remington claims up to a 54 percent decrease in felt recoil.

My shoulder is not calibrated that finely, but my sight re-acquisition times improved greatly and the recoil impulse feels much more like a push than a punch, even with three-inch slugs.

Remington 870 SuperCell Recoil Pad

5. HiViz Front Sight Shotgun Bead

For those of us with less than perfect vision, this is a replacement for the front bead on those shotguns with a screw-in bead.

Check your shotgun first to confirm this, as some are and some are not. But if applicable, this “bead” jumps out at you and greatly improves both accuracy and acquisition time.

HiViz Screw In Shotgun Bead Sight
 

6. Carlson’s Seven-Shot Magazine Extension

This magazine extension is a plus-three extension. It brings the capacity up from 4+1 to 7+1.

Whether you are running your 870 in 3-Gun or a home defense scenario, this is a welcome increase in round count.

Installation is as simple as unscrewing the stock magazine cap, removing the stock spring and follower, replacing with the new spring and follower and screwing the extension into place.

I would suggest the addition of the next item as well, but that is optional.

Carlson's Remington 870 Magazine Tube Extension

7. GG&G Replacement Aluminum Follower

One of the most common failure points of the Remington 870 is caused by the degradation of the plastic follower.

When it gets gouges or the plastic starts to deteriorate due to age or use, it doesn’t follow properly.

When it gets off-kilter, jams happen. This replacement follower has a stainless steel exterior for a lifetime of gouge resistance.

The red center portion is aluminum and is painted bright red for quick visibility.

8. Wilson Combat Jumbo Head Safety

The factory safety is very functional, but is slow and requires fine motor skills.

The Wilson Combat upgrade greatly increases the surface area of the safety and makes the manipulation a gross motor skill for increased speed when it really counts.

Wilson Combat Jumbo Remington 870 Safety

Remington 870 Upgrades: Conclusion

It certainly isn’t mandatory to purchase all of these options. Some make for more convenient use, such as the sling and magazine extension tube.

Others make it easier to hit, like the fiber-optic bead or the scope mount. Yet others make for a safer shooting environment, like the over-sized safety and recoil-reducing butt pad.

Who doesn’t want the more reliable functionality of the steel and aluminum follower?

For those of you who broke your wooden forend and need to put a laser on the replacement, Magpul’s forend has you covered too.

While not exactly as mix and match as the AR platform, the Remington 870 has these and dozens of other options to enhance your shotgun shooting fun.

What upgrades have you added to your favorite shotgun? Why? Let us know in the comments below.

Get the Best Deals on Guns, Ammo & Gear sent 3 days a week.


guns

via The Shooter’s Log https://ift.tt/2VbyLGM

April 28, 2020 at 08:47AM

Fictional Land Vehicle Comparison

Fictional Land Vehicle Comparison

https://ift.tt/3cNDqEs

Fictional Land Vehicle Comparison

Link

Thanks to MetaBallStudios, we know how big starships and robots are relative to one another. Now, we can see how earthbound vehicles stack up in this comparison video, which looks at the sizes of everything from Ant-Man’s microscopic van to the wheeled city of London in Mortal Engines. We had no idea that an AT-AT was bigger than Gundam.

fun

via The Awesomer https://theawesomer.com

April 27, 2020 at 04:15PM

MySQL Workbench 8.0.20 has been released

MySQL Workbench 8.0.20 has been released

https://ift.tt/35ajLMs

Dear MySQL users,

The MySQL developer tools team announces 8.0.20 as
our General Availability
(GA) for MySQL Workbench 8.0.

For discussion, join the MySQL Workbench Forums:
http://forums.mysql.com/index.php?152

The release is now available in source and binary
form for a number of
platforms from our download pages at:

http://dev.mysql.com/downloads/tools/workbench/

Enjoy!

technology

via Planet MySQL https://ift.tt/2iO8Ob8

April 27, 2020 at 10:50AM

Learn How to Draw From Disney Animators Through These Free Videos

Learn How to Draw From Disney Animators Through These Free Videos

https://ift.tt/2VCbihX

Image: YouTube/ Disney Parks

If you’ve been using some of your at-home time to learn how to draw, Disney Parks has a number of videos that might help.

The Park’s “How to Draw” series on YouTube offers videos on how to draw everyone from Elsa and Anna from Frozen to classic characters like Donald Duck and Goofy.

Each video is hosted by an actual Disney animator. Some of the videos are around five minutes, while other more complicated characters can take over 20 minutes to learn. Participating just requires you have a piece of paper and something to draw with.

In total, the playlist has 42 different character videos, so there’s a ton of variety to choose from. you can check out the full list here.

Instructions are presented in a way that they could be done by older kids as well as adults, so it could make for a fun afternoon for aspiring younger artists in your home as well.

I watched a handful of these today, and a number of the animators, especially the guy doing that Elsa video, have a Bob Ross quality to them that make them relaxing to watch, even if your finished drawings end up being better suited for the garbage can than the big screen.

geeky,Tech,Database

via Lifehacker https://lifehacker.com

April 26, 2020 at 03:29PM

Laravel Jobs and Queues – Configuring, Sending Mail, Dispatching Jobs

Laravel Jobs and Queues – Configuring, Sending Mail, Dispatching Jobs

https://ift.tt/2VxbWgU

It has been a lot of time since I started using Laravel Queues. During earlier days back than learning complex technologies on own was not easy and I somehow managed guts to learn them and apply in real-time projects.

Today I’m happy that I took that decision. While learning Laravel Framework I got introduced to a lot of intermediate and high-level programming concepts and one concept or say feature on this framework caught my attention was Queues because of its ability to run jobs or tasks in the background.

From the day I learnt queues in started to use it in each of the projects I do in laravel.

Table of Contents

What are Laravel Queues?

Consider you have a heavy processing task to be performed by application this may be generating large data for reporting, blasting emails for a large number of users or such notifying people when their task gets completed.

These are some of the examples and as they are time-consuming you cannot execute these task is normal manner such are on button click or page submit. So to properly handling these task laravel provides queue functionality where tasks data is storing in a database and then the queue will automatically detect any jobs and execute them in background.

Create a Fresh New Laravel Project

Laravel provides two different options for creating a fresh project.

Before you execute below command you must navigate to your directory where you would like to create this project and open the terminal from that particular path.

Using Laravel Installer

This installer is downloaded through composer. Before running this command composer must be installed on your computer.

composer global require laravel/installer
 

Then you can create a new project by typing below command.

laravel new your_project_name
 

Directly creating a project through composer command

This is another method and I always go through this method because it doesn’t need the additional installer to be installed other than a composer and also I can specify project version at the end.

composer create-project --prefer-dist laravel/laravel your_project_name "6.*"
 

At the end 6.* specifies which version you would like to install. You can visit Laravel versions and support policy page for more information.

Note

Directly creating project second option will take a few minutes. So don’t cancel the process.

Database Connections

In the root directory of the freshly created project, theirs an .env file which contains all the environment setting for the project.
There is an option for adding database connection which username and password.

DB_CONNECTION=mysql
 DB_HOST=127.0.0.1
 DB_PORT=3306
 DB_DATABASE=laravel_queues
 DB_USERNAME=root
 DB_PASSWORD=
 

laravel_queues is our database name and then goto PHPMyAdmin and create a database of laravel_queues name.

Note

For demonstration purpose we are using MySql are database. You more robust performance laravel also provides drivers for Redis, Amazon SQS, Beanstalkd etc for more information you can visit drivers and prerequisites of laravel queues.

 

Queue Configuration and Settings

Since we are telling laravel to use our database as queue driver there is just a simple step to do.

That is to go to .env file and replace below code.

#Replace this line.
 QUEUE_CONNECTION=sync 
 
 #With this line.
 QUEUE_CONNECTION=database
 

Note

You can also take a look at queue.php inside config a directory which contains an array of all available drivers.

 

Database Migration

Database migration takes place by creating a migration class inside the folder database/migrations. It contains the schema description of the table and can be migrated to the database.
But before start migration, you must inform laravel to create a migration class for queue table for this use below command.

php artisan queue:table
 

A migration file is created inside database/migrations folder.

Schema::create('jobs', function (Blueprint $table) {
 $table->bigIncrements('id');
 $table->string('queue')->index();
 $table->longText('payload');
 $table->unsignedTinyInteger('attempts');
 $table->unsignedInteger('reserved_at')->nullable();
 $table->unsignedInteger('available_at');
 $table->unsignedInteger('created_at');
 });
 

Now all these migrations must be migrated to the database for that run below command.

php artisan migrate
 

Laravel php artisan migrate command output

By switching to PHPMyAdmin you can see that tables are created in the database.

Laravel database after running migrations

For testing, purpose let us also create two new tables they are countries_census, states_census.

Note

countries_census the table holds the total population of the country.
states_census the table holds the total population of each state which is then mapped to the country table through country_id column.

php artisan make:migration create_countries_census_table --create=countries_census
 
 php artisan make:migration create_states_census_table --create=states_census
 

database/migrations/2019_08_19_000000_create_countries_census_table.php.

<?php
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
 
 class create_countries_census_table extends Migration
 {
 /**
 * Run the migrations.
 * 
 * @return void
 */
 public function up()
 {
 Schema::create('countries_census', function (Blueprint $table) {
 $table->bigIncrements('country_id');
 $table->text('country_name');
 $table->unsignedInteger('total_population');
 $table->timestamp('updated_at')->nullable();
 });
 }
 
 /**
 * Reverse the migrations.
 *
 * @return void
 */
 public function down()
 {
 Schema::dropIfExists('countries_census');
 }
 }
 
 

database/migrations/2019_08_19_000000_create_states_census_table.php.

<?php
 
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
 
 class create_states_census_table extends Migration
 {
 /**
 * Run the migrations.
 * 
 * @return void
 */
 public function up()
 {
 Schema::create('states_census', function (Blueprint $table) {
 $table->bigIncrements('state_id');
 $table->text('state_name');
 $table->unsignedInteger('country_id');
 $table->unsignedInteger('state_population');
 });
 }
 
 /**
 * Reverse the migrations.
 *
 * @return void
 */
 public function down()
 {
 Schema::dropIfExists('states_census');
 }
 }
 
php artisan migrate
 

Laravel new tables countries census and states_census created through migration

Creating models for countries_census and states_census tables.

Laravel models are the representation of the database table which contains tables schematic information as well as one table to another table relationship description.

To create model use below command.

php artisan make:model CountryPopulationModel
 

In app/CountryPopulationModel.php a new model has been created.

<?php
 
 namespace App;
 
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\Log;
 
 class CountryPopulationModel extends Model
 {
 protected $table="countries_census";
 protected $primaryKey = 'country_id';
 protected $fillable = ['country_name', 'total_population'];
 
 public function states()
 {
 return $this->hasMany(CountryStatePopulationModel::class, 'country_id', 'country_id');
 }
 }
 

$table is database table name of than model.
$primaryKey is database table primary.
$fillable is columns of database table except for primary key.

Similarly, let us create a model for states_census.
In app/CountryStatePopulationModel.php.

<?php
 
 namespace App;
 
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\Log;
 
 class CountryStatePopulationModel extends Model
 {
 protected $table="states_census";
 protected $primaryKey = 'state_id';
 protected $fillable = ['country_id', 'state_name', 'state_population'];
 
 public function country()
 {
 return $this->belongsTo(CountryPopulationModel::class, 'country_id', 'country_id');
 }
 }
 

Dummy data is also added into both the tables and before running jobs, these tables look like below.
Laravel countries census table data before running jobs

Creating a controller for handling logic

Command to create a new controller.

php artisan make:controller CountryController
 

app/Http/Controllers/CountryController.php

<?php
 
 namespace App\Http\Controllers;
 
 use App\CountryPopulationModel;
 use App\Jobs\ProcessCountriesPopulation;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Log;
 
 class CountryController extends Controller
 {
 public function process(Request $request){
 
 }
 }
 

Routing

routes/web.php

Route::get('countries-census/process', 'CountryController@process');
 

Creating New Job for Queue

Use php artisan the command for creating a new job class.

php artisan make:job ProcessCountriesPopulation
 

ProcessCountriesPopulation class is created inside the application root directory app/Jobs/ProcessCountriesPopulation.php path.
This job class will periodically check for population data for different countries, sum them and update the latest population of the country in countries_census table.

The ProcessCountriesPopulation job class looks like below.

<?php
 
 namespace App\Jobs;
 
 use App\CountryPopulationModel;
 use App\CountryStatePopulationModel;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
 use Illuminate\Support\Facades\Log;
 
 class ProcessCountriesPopulation implements ShouldQueue
 {
 use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
 
 /**
 * Create a new job instance.
 *
 * @return void
 */
 public function __construct()
 {
 
 }
 
 /**
 * Execute the job.
 *
 * @return void
 */
 public function handle()
 {
 
 }
 } 
 

Pre-made methods __construct and handle are available.

Note

__construct() the method is used for passing dynamic data to the job.

handle() the method is executed whenever a new job is dispatched. This dispatch event is listened by command queue:work.

<?php
 
 namespace App\Jobs;
 
 use App\CountryPopulationModel;
 use App\CountryStatePopulationModel;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
 use Illuminate\Support\Facades\Log;
 
 class ProcessCountriesPopulation implements ShouldQueue
 {
 use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
 protected $country_census;
 
 /**
 * Create a new job instance.
 *
 * @return void
 */
 public function __construct(CountryPopulationModel $country)
 {
 Log::info('Entered Job ProcessCountriesPopulation __constructor method');
 $this->country_census = $country;
 }
 
 /**
 * Execute the job.
 *
 * @return void
 */
 public function handle()
 {
 Log::info('Entered Job ProcessCountriesPopulation handle method');
 $country_states_population_sum = CountryStatePopulationModel::where(["country_id" => $this->country_census["country_id"]])->sum('state_population');
 
 $country = CountryPopulationModel::find($this->country_census["country_id"]); 
 $country->total_population = $country_states_population_sum;
 $country->save();
 
 Log::info('Exited from Job ProcessCountriesPopulation handle method');
 }
 }
 

In the above job, the class constructor method __construct(CountryPopulationModel $country) takes an object which is of type CountryPopulationModel as an argument. This object is then assigned to a class variable $this->country_census.
Log::info logs the message in the log file which is placed in the path laravel_queues/storage/logs/laravel.log.

Note

Background logic is always performed in handle() method of job class this place where the jobs are inserted to the job table.

Dispatching Jobs to Queue

app/Http/Controllers/CountryController.php

<?php
 
 namespace App\Http\Controllers;
 
 use App\CountryPopulationModel;
 use App\Jobs\ProcessCountriesPopulation;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Log;
 
 class CountryController extends Controller
 {
 public function process(Request $request){
 Log::info('Entered Job CountryController process method');
 
 $country = CountryPopulationModel::find(101);
 
 ProcessCountriesPopulation::dispatch($country);
 
 Log::info('Exited Job CountryController process method');
 }
 }
 

In ProcessCountriesPopulation::dispatch($country); the static dispatch() method passed $country object to job class constructor.

Running Queue Workers on Development Machine

php artisan queue:work
 

This command will detect any pending jobs is jobs table and executes them one by one.

After going to route countries-census/process in browser. You can see that a new row is already been inserted in jobs table. And below log message appears in laravel_queues/storage/logs/laravel.log a file.

[2020-04-09 11:48:54] local.INFO: Entered Job CountryController process method 
 [2020-04-09 11:48:54] local.INFO: Entered Job ProcessCountriesPopulation __constructor method 
 [2020-04-09 11:48:54] local.INFO: Exited Job CountryController process method 
 [2020-04-09 11:48:55] local.INFO: Entered Job ProcessCountriesPopulation handle method 
 [2020-04-09 11:48:55] local.INFO: Exited from Job ProcessCountriesPopulation handle method 
 

Jobs Table before running queue.

Laravel job table before running queue work command
When the job is processed queue automatically remove the completed job rows.

Population data inside the database table countries_census is also updated.
Laravel country census table after running queue work command

Processing of queued jobs.
laravel processing of queued jobs in command line

Using Laravel Queues for sending mail

Here you’ll see a simple example of sending an email using queues.

For creating new email class.

php artisan make:mail WelcomeEmail
 

In laravel_queues/app/Mail/WelcomeEmail.php

public function build()
 {
 return $this->from('abc@gmail.com')->view('emails.welcome-email');
 }
 

If you want to send email using SMTP then you must specify below credentials in .env file

MAIL_DRIVER=smtp

MAIL_HOST=smtp.googlemail.com

MAIL_PORT=587

MAIL_USERNAME=*****@gmail.com

MAIL_PASSWORD=

MAIL_ENCRYPTION=tls

For sending emails use Mail class and inside send() method pass the name of the email class you would like to send.

Mail::to("to-email@gmail.com")->send(new WelcomeEmail());
 

Running Queue Workers on Production Server

Use cron job option provided by servers and set the frequency to each minute. Which means that the cron job will execute the artisan console command schedule method each minute which is placed at the path laravel_queues/app/Console/Kernel.php.

I have created a personalized script while using executing job command inside console which I’ll be sharing with you.

$schedule->command('queue:restart')->everyFifteenMinutes()->withoutOverlapping();
 
 $schedule->command('queue:work --sleep=3 --tries=3')->everyMinute()->sendOutputTo(storage_path() . '/logs/queue-jobs.log')->withoutOverlapping();
 

First command queue:restart will restart the processing job listeners, every fifteen minutes. The withoutOverlapping method will prevent the same jobs from overlapping with each other.

Laravel has also provided a detailed overview of the Overlapping of tasks.

Caution

Running jobs without overlapping will be draining servers physical memory can also leave server hanged up.

Next command queue:work will listen to new jobs every minute. You can also specify flags which have different purposes.
Flag --sleep will send queue to sleep mode for specified seconds once all jobs are processed.
Flag --tries will attempt to try executing queued for a specified number of times before sending them for failed_jobs.

How to handle failed jobs in Queues?

Queued jobs which were unable to execute even after many attempts are sent to failed_jobs the table. This table consists of information such as connection type, payload, exception information and date-time when a job has failed.

Larael failed queue jobs table

For re-attempting, these failed jobs use below command.

php artisan queue:retry all
 

Command queue:retry all will retrieve a list of all jobs that are failed and will try to execute them. You can also specify which job to executed by specifying its primary key number like php artisan queue:retry 2 this will execute the job with primary key 2.

List failed jobs

To see all the jobs which are failed use php artisan queue:failed command. This will display all the failed jobs in the terminal.

Laravel show table of failed jobs in terminal

Queueing Jobs by Priorities

Queue executes jobs on default occurrence. But you can specify the priority of a job during dispatching stage.

dispatch((new ProcessCountriesPopulation($country))->onQueue('high'));
 

Conclusion

Time has come to say goodbye. Coming to the end of this post you have all the basic and intermediate information and examples of working and queues in the development and production stage. This post was regarding Laravel Jobs and Queues – Configuring, Sending Mail, Dispacting Jobs and were are happy to have taken time to go read this post. Support us by sharing this post which will help us grow and comment if you have any doubts we will reach you soon.

Popular Posts

programming

via Laravel News Links https://ift.tt/2dvygAJ

April 23, 2020 at 09:42AM

The Mandalorian Documentary’s First Trailer Goes Behind the Scenes on Bringing Baby Yoda to Life

The Mandalorian Documentary’s First Trailer Goes Behind the Scenes on Bringing Baby Yoda to Life

https://ift.tt/2VQyecn

Baby Yoda, once again star of the show.
Image: Lucasfilm

Trailer FrenzyA special place to find the newest trailers for movies and TV shows you’re craving.

You guys: Werner Herzog wanted to direct that baby so much. Give him a whole episode!

Disney has dropped the first trailer for Disney Gallery: The Mandalorian, a surprise eight-part documentary series that will launch this Star Wars Day, May 4, on Disney+. Going behind the scenes on the first season of the hit Small Green Child show, the series will provide insight from roundtables featuring the directors, producers, and cast of the show, as well as behind-the-scenes footage from the production.

Which means yes, even more Baby Yoda footage to gawk at.

Does it rob a little of the magic of Baby Yoda to see the puppet in action, all its strings (well, metaphorical ones in the age of modern puppetry) attached for us to see? Maybe, but then you get director Deborah Chow recalling how Werner Herzog—who played the Imperial Remnant known only as “The Client” in the first season—would be directing the puppet itself like it was a real baby during his scenes, and your heart melts all over again.

Disney Gallery: The Mandalorian’s first episode will release on Disney+ May 4, alongside the final episode of Star Wars: The Clone Wars. Meanwhile, here’s a new poster for the documentary:

See, you know it’s behind the scenes because you can see a camera.
Image: Lucasfilm

Because when you’re Star Wars, even your behind-the-scenes footage gets a poster.


For more, make sure you’re following us on our Instagram @io9dotcom.

geeky,Tech

via Gizmodo https://gizmodo.com

April 23, 2020 at 10:42AM

Ruger’s New PC Charger

Ruger’s New PC Charger

https://ift.tt/2KuL4re

In keeping with the current firearms market rage over pistol carbine type guns, Ruger has introduced the innovative new PC Charger. This provides shooters with another exciting option for everyday carry, a truck gun, or for home or personal defense.

The PC Charger is a handheld pistol with an AR type pistol grip and a large magazine well for offhand gripping with a hand stop up front at the muzzle. Though the PC is a handgun, it’s not exactly compact with a threaded 6.5-inch barrel and overall length of 16.5 inches . It is considered a pistol for all legal aspects. The PC’s weight is 5.2 pounds.

Chambered for the street standard 9mm Luger, the PC comes from the factory ready to handle proprietary Ruger magazines, but can be converted with included parts to switch it over to use Glock magazines. This is a handy feature for sure. The Ruger Security 9 magazine holds 17 rounds, enough to start a good shooting round at the range or ward off any threat at home or on the road.

This PC pistol has the capability to take down by locking back the bolt and pushing a recessed lever, allowing the two sections to be twisted until they release and pull apart. One can quickly imagine the utility of being able to take this firearm apart into two subassemblies for easy carry and secure carry or storage.

The PC has a blue finish with the handguard assembly finished in a Type III hard coat anodized finish for tough wear durability and resistance to outdoor elements. The handguard is equipped with M-LOK slots in the 3-6 and 9 o’clock positions. This provides a number of options for adding accessories. The top rail has a built in Picatinny section for mounting a variety of optic options.

The Ruger PC Charger’s chassis is constructed of a glass filled polymer. The rear portion of the frame has an integrated QD cup to allow a quick connection of a QD cup sling. This would permit a single point sling attachment for shoulder carry in a variety of modes. Other features and specifications can be seen at www.ruger.com.

Some may inquire or question as to what the utility is of such a weapon as the PC Charger. That of course is up to the users themselves. Certainly this firearm can fit roles in personal defense, property security, travel security, or just plain and simple shooting fun. Check with your local firearms dealer to see when they expect the PC Charger to be available. It retails at $799.

The post Ruger’s New PC Charger appeared first on AllOutdoor.com.

guns

via All Outdoor https://ift.tt/2yaNKUu

April 23, 2020 at 11:33AM