The 5 Best Mac Image Viewer Apps With Unique Features

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2021/03/xnview-mp-image-viewer-mac.png

Finder’s Gallery view lets you scroll through folders of photos on your Mac with an enhanced preview pane and rich metadata. Preview works fine for basic use, but it lacks navigation controls, superior viewing experience, and other features.

You don’t need an app like Apple Photos, Adobe Lightroom, or one that supports databases to update and organize your collection while displaying images. We’ll show you some of the best photo viewer apps with unique features for Mac and how you can use them.

1. XnView MP


XnView MP is a photo viewer, manager, and resizer for Mac. The built-in tools let you organize images in multiple ways and process them with an arsenal of editing tools while offering batch conversion modules and support for numerous image formats.

When you launch the app, you’ll see three panels.

The left sidebar is the Finder file system, with a section tabs—Folders, Favorites, and Categories Filter. It consists of pre-configured categories to aggregate and label your images.

The center panel shows a thumbnail preview of each photo. Navigate to View > View As and select Thumbnails + Labels to show the details. You can sort images by name, file size, EXIF date taken or modified, or even filter them by rating, comments, or tags.

On the right side, you’ll see a preview panel. Info lets you see file properties, histograms, and EXIF data. Switch to the Preview panel to check out the image.

Unique Features of XnView MP:

  • Support of old, non-standard, Photoshop, Corel, Autodesk, and HEIF image formats. Click Create to split or join images and create multipage image files.
  • It can handle RAW file format and uses the GPU to improve performance, caching, and processing. It also supports a full internal bit depth picture of 8, 16, or 32 bits per component.
  • Customize the layout of the app as per your needs. Navigate to View > Layout, or select Free to create a custom layout.
  • Integrates with XnConvert to convert images, resize batches of images, and apply adjustments like rotation, watermarks, filters, fancy effects, and more.
  • Lets you create custom slideshows with parameters for setting up a timer (or keyboard press), changing screen size, adding transition effects, and adding background music.

Download: XnView MP (Free)

2. ApolloOne


ApolloOne is an image viewer app for Mac to view and organize photos. The built-in camera RAW decoder can generate a preview of an image directly from the RAW file. With the Lanczos filter, it can scale your image back to its original quality.

To access your photos, click the Browser button in the toolbar. Then click the plus (+) button and select Folder. You can group related folders by adding a separator.

Double-click a photo to open it. Then press the left or right arrow keys to see your photos. Thumbnails are generated on the fly using a multi-core processing engine. For Macs with a GPU, the app can speed up the display of images and quality.

Head to Preferences > Advanced and turn on High quality image scaling option. You can zoom in or out of the photo. Press the Control key to instantly zoom to a particular magnification.

The Inspector panel shows you detailed shooting info from a camera JPEG or camera RAW file. To inspect any image, press Cmd + I or click the Inspector button in the toolbar. On a supported camera, the info page can reveal the serial number, shutter count, and other specifications.

Unique Features of ApolloOne:

  • It provides a glance view of images at the top of the viewer—like a film strip (Tools > Show Filmstrip).
  • ApolloOne lets you set the source of the metadata. It supports both macOS extended attributes (used by Finder searches) and XMP. Turn on Spotlight indexing to search images by different EXIF parameters.
  • It offers you an adjustment panel to help with the assessment of a RAW image. This includes exposure compensation, highlights and shadows adjustment, and an Auto Tone curve.
  • The built-in contact sheet mode (View > Contact Sheet) displays the thumbnails in a grid fashion. With it, you can perform file operations in bulk.
  • You can add a Smart Folder created by Finder to access your photos according to your needs. It even supports Finder tags and lets you use a combination of tags for further filtering. Here’s how to use smart folders on a Mac.

Download: ApolloOne (Free, premium version available)

3. qView


qView is a cross-platform, minimal image viewer app for Mac. On launch, you’ll see a black window. Navigate to File > Open and choose a folder to display its contents. Then, press the left or right arrow keys to navigate between the photos.

Scroll to zoom in or out and control-click any picture to access more options. You can rotate images, flip images, or switch to the original size and view them in detail.

Unique Features of qView:

  • qView supports GIFs, allowing you to increase or decrease the speed or save a specific frame as a PNG or JPEG.
  • View photos in slideshow mode (Tools > Start Slideshow). You can customize the slideshow direction, timer, and preload settings.
  • It offers you shortcuts to navigate and access different options, and usability. Check the Shortcuts tab in preferences.
  • By default, the title bar shows the file name. Head to Preferences > Windows and check the Verbose option under the Titlebar text to show you more details.

Download: qView (Free)

4. Picturama


Picturama is a modern-looking, electron-based, picture-viewing Mac app that lets you quickly view images. The app supports JPEG, PNG, TIF, WebP, HEIC, and HEIF. It also reads the RAW file for a bunch of cameras through the LibRaw libraries built into the app.

To get started, click the Settings button and choose a folder.

You can browse the photos by date using the stylish progress bar on the right. Choose a year and month, and directly navigate to your photos.

Press the i button to see the information and EXIF data of an image. Click the flag button to add that image to your favorites.

Unique Features of Picturama:

  • It can retrieve comprehensive EXIF, IPTC, MakerNotes, and XMP information of the detailed Info page.
  • You can add a tag, but it has no relation with the Finder.
  • Rotate and crop your photos. You can zoom in or out with the slider in the toolbar or mouse wheel.
  • Export photos in formats like JPEG, PNG, or WebP. When doing this, you can set the quality, size, and remove EXIF data.

Download: Picturama (Free)

5. Lyn


Lyn is a Mac photo viewer and organizer. It supports non-standard, old, and RAW image formats. With the built-in support of camera models and multi-threading, it can progressively scale high-resolution images.

The left sidebar displays all your folders (including Smart Folders), photo libraries, devices, and mounted volumes.

The viewer displays the image and has view options like—Icon, Strip, List, and Map view mode. The map layout mode uses Apple Maps with GPS data to provide visual location information. And the list view mode shows the image thumbnail, detailed information, and metadata.

At the right, you’ll see the Inspector panel. It displays information like type, color space, EXIF, makernote, IPTC, GPS, and more.

Browse your photos either using strip view mode or by double-clicking a picture and using the left or right arrow keys. You can use different zoom methods and use shortcuts to magnify the image at the cursor level.

Lyn can also sort the photos in many ways, like name, date, color label, tags, and rating. Or it can filter them by name, extension, and tags in the search field.

Unique Features of Lyn:

  • This app uses ColorSync color management technology, from source to printing. It can detect the color profile (through ICC) from the image, embedded profile, EXIF, or camera makernote.
  • You can rate, assign keywords, or tags to your photos. It’s also possible to create a smart folder with tags, so you can easily find files. Under the Search For tag, you’ll find all your Smart Folders.
  • When you connect a camera, expand the Devices section and start importing your photos. It can even import from a card reader, hard disk, or NAS.
  • Lyn includes a non-destructive filtering engine to adjust color, exposure, contrast, enhance the shadows, apply a sepia filter, convert to black and white, and more. You can even straighten or crop an image and later revert them.
  • Publish your photos directly to Flickr, Dropbox, and SmugMug. The user interface is built into the app itself.

Download: Lyn ($29.99, free trial available)

Free and Paid Image Editors

Although viewing images seems like a simple operation, people may have a variety of use cases for it. The apps discussed in this article cover a wide range of options for different professionals and edge cases. Try out these apps yourself to see which one fits your needs best.

If you’re looking to edit these images, then you require an image editor. All these image viewers have the option to Open with an image editor of your choice. If this interests you, take a look at the best free and paid image editors for Mac to find the best option.

MUO – Feed

Creating an API with Laravel in the proper way

https://dev.to/social_previews/article/638454.png

Starting with Laravel is easy and creating your first endpoint will take you just a few minutes. But, if you want to do it in the proper way to get a reusable, scalable and testable code you must read this before starting.

👉 Post disponible en español 🇪🇸


Before starting, just let you know that I had made a video talking about this with a step-by-step guide showing how to refactor your code without breaking anything and, this way, getting a more clean code. (In 🇪🇸 Spanish)


Ok! Let’s start with this post.

Usually, an endpoint in Laravel have three parts:

  1. The firs block of code in our controller is to validate the incoming request or getting some model from the URL.
  2. Next we do something with this data, for example, creating a user, sending an email, or whatever.
  3. Finally, we give to our API client a response in JSON.

This is a usual structure of an endpoint and a bad endpoint have all this part in the same controller file making all the code not reusable so, taking this into account, we are going to make our endpoint step-by-step.



TOC



Validate the request

In Laravel, we have a lot of different ways to use the validator class and check the entry data from the request but the best you can do, on a controller, it’s to use a custom request object.

You can create this by simply run artisan make:request UserStoreRequest. This will create the file app/Http/Requests/UserStoreRequest.php with a content similar to:

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserStoreRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [];
    }
}

Enter fullscreen mode

Exit fullscreen mode

As you can see, we have two main methods: one to check if the current user is authorized to perform this action or not.

You can use Auth() class here to get current user and check permissions if needed.

And the other method is used to pass validation rules to the request.

With that, you can use this class in your controller and the input data gets validated.

<?php

namespace App\Http\Controllers;

use App\Http\Request\UserStoreRequest;

class UserController extends Controller
{
    /**
     * Store a new user.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(UserStoreRequest $request)
    {
        $valid = $request->validated();

        //
    }
Enter fullscreen mode

Exit fullscreen mode



Creating application services

When all our input data is validated, and we have an expected and valid request we have to do something with that data.

A bad practice it’s to work with this data inside the controller. In our controller we have code that belongs to the infrastructure layer and this use cases must be in our application layer in order to make this code reusable and easy to test.

So, my recommendation it’s to create a service inside the folder app/Services. Something like this:

<?php

declare(strict_types=1);

namespace App\Services;

use App\Mail\UserSignUpMail;
use App\Models\User;

final class UserStoreService
{
    public function __invoke(
        string $email, 
        string $name, 
        string $password
    ): User {
        $password = \Hash::make($password);

        return User::create([
            'email' => $email,
            'name' => $name,
            'password' => $password
        ]);
    }
}
Enter fullscreen mode

Exit fullscreen mode

As you can see, we are only hashing the password and creating the user in the invoke method. But, doing this in a service file instead of doing inside the controller allow us to write a simple unit test to check that the service it’s doing what we expect and also, we can reuse this code and calling it from another place, not only the controller.

For example, if we want to create a user from a Laravel Command we can use this same service and trigger the same use case without changing anything in our service code.

In our controller we just need to call this new service.

<?php

namespace App\Http\Controllers;

use App\Http\Request\UserStoreRequest;

class UserController extends Controller
{
    private UserStoreService $storer;

    public function __construct(UserStoreService $storer)
    {
        $this->storer = $storer;
    }

    /**
     * Store a new user.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(UserStoreRequest $request)
    {
        $user = ($this->storer)(
            $request->get('email'),
            $request->get('name'),
            $request->get('password')
        );
    }
Enter fullscreen mode

Exit fullscreen mode



Dispatching events

As you can see, our service it’s really simple, but in the real world that will never happen. Usually, when we create a user we must send an email, we need to create some configurations, send some notifications or whatever and that’s why we should use events and avoid overcomplicating our service.

If we use events we can listen to this event and trigger different actions in different parts of our code to keep each service and listener as simple as possible.

In Laravel, it’s really simple to trigger some events and listen to them and trigger some actions when needed.

The first thing we need it’s to create our event with artisan make:event UserCreated. This event will receive the created user in the constructor.

Something like this:

<?php

namespace App\Events;

use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class UserCreated
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $user;

    public function __construct(User $user)
    {
        $this->user = $user;
    }
}
Enter fullscreen mode

Exit fullscreen mode

And then, we create our listener to send a welcome email to the user after creating it. In our console we should run artisan make:listener SendWelcomeMail --event=UserCreated and inside the handle method we send our custom email.

And finally, you need to register the event in your User model in order to trigger it automatically every time a new user it’s created.

<?php

// ...

class User extends Authenticable
{
    // ...

    protected $dispatchesEvents = [
        'created' => UserCreated::class,
    ];
}
Enter fullscreen mode

Exit fullscreen mode

Remember that you also need to register the event and the listner in your EventServiceProvider. You have more information inside Laravel documentation



Formatting the response

The last part of a good controller just need to get the result of the service we created before (if we are returning something) and transforming it in a valid JSON.

Usually, in Laravel, I found a lot of application that are just returning a model. This works, because Laravel can transform this models into a valid JSON but, if we have something else than a really simple API this it’s not a good idea.

The problem of doing this is that we are not customizing or defining anything and Laravel it’s returning our model with all fields all the time.

If you need more control, and you are going to need this sometime, you will need to create and return and API resource.

This API resources let you to customize the response by adding conditional fields but also relations, pagination and metadata.

This is the best you can do if you plan to create a good API full of services, endpoint and different kind of responses.

Laravel News Links

80 Laravel Interview Questions

https://res.cloudinary.com/practicaldev/image/fetch/s–rTABY4Xn–/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncsx47qc7lsozzv2omj4.jpg

Hi everybody. If you’ve recently been invited to a Laravel interview, or you want to improve your skills about this framework, in 80 questions, we are going to discover more about Laravel. 😉



A Friendly Tip

These questions improve your general and technical knowledge about Laravel and prepare you for interviews. In this series we are going to explore something like Event/Listeners briefly. Knowing these items doesn’t guarantee that you will pass the interview! Passing the interview is hugely depends on how you are going to implement these items. For example you may be asked to make a program using Job/Queue.

Laravel has a lot of features and no one can claim that he/she knows everything about Laravel and is able to implement everything in the best way. Even it’s main developers!

So the best approach is to grasp basic knowledge about most Laravel features and be able to implement only some of these features in the best way. Companies aren’t looking for a person who knows everything. And the one who claims that he/she knows everything, will be likely rejected because of being overqualified which means he/she is good more that expectations.

So don’t worry if you don’t know everything. The thing is, you must know a few things like a hero 💪

Ok, let’s start.



What are we going to explore?

In this series we are going to answer these 80 questions:



Part 1:

  1. What do you know about Laravel?
  2. What are differences between Laravel and Lumen?
  3. Name a few important directories of the framework
  4. What does bootstrap directory do?
  5. What is the usage of middleware?
  6. What is Artisan?
  7. What are differences between has and filled methods in the Request class?
  8. What is ORM?
  9. What is Eloquent?
  10. Name some important Laravel relationships



Part 2:

Will be added soon



Part 3:

Will be added soon



Part 4:

Will be added soon



Part 5:

Will be added soon



Part 6:

Will be added soon



Part 7:

Will be added soon



Part 8:

Will be added soon

Laravel News Links

Securely Copy Files in Linux With the Scp Command

There are times when you want to transfer files between your local system and a remote server. Several protocols and methods are available that allow you to handle file transmissions in a secure manner.

The scp command in Linux is one such tool that helps a user in sharing files remotely between local and remote hosts. In this article, we will discuss the scp command in detail, along with its usage and some additional features of the command.

What Is the Scp Command

Scp, an acronym for Secure Copy, is a command-line utility in Linux-based operating systems that allows a user to copy files between remote and local hosts. Since the command transfers files over a network to some other host, SSH access is required. SSH (Secure Shell) is a protocol that allows you to handle network services securely over any network.

The scp command also supports some additional features such as specifying authentication parameters, changing the port, transferring directories, and more.

Why Scp Is Better Than Other Methods

Scp is usually preferred over other file transfer methods because, during the transfer, the connection between the two hosts is encrypted. The SSH protocol is responsible for encrypting the files, passwords, and any other sensitive details.

Other transfer methods such as Telnet or FTP do not have any encryption. Also, the user/password keypair is also saved in plain text which is not a good practice at all. A cracker can easily access your information by sniffing your network.

How to Securely Transfer Files Using Scp

Using the scp command, you can transfer files between:

  1. A local host and a remote host
  2. A remote host and a local system
  3. Two remote hosts

Basic Syntax

The basic syntax of the scp command is:

scp [options] [source] [destination]

Transfer From Local Host to a Remote System

If you are a server administrator, then transferring files between a local host and remote hosts might be useful to you. To upload a file named document.txt to a remote host:

scp /home/document.txt user@remote-host:/home/document.txt

Note that the source is the path of the file on your local storage. And the destination is the path of the file on the remote host. You have to specify the username and domain name of the remote server as well. In the above command, user is the username and remote-host is the domain name.

The destination path is separated from the remote host details using the colon character (:). Keep in mind that the user must exist on the remote server if you want to transfer the files successfully. Also, the user should have write access to the directory in which you want to save the file.

After issuing the above-mentioned command, the system will ask you for the remote user’s password. Type the password and press Enter.

user@remote-host's password:

If the password is valid, the file transfer will initialize. If you entered an incorrect password, an error will occur.

Before trying to copy the file using the scp command, ensure that the remote host details and the password are correct by logging in to the server using SSH.

From a Remote Host to Local Host

To copy files from a remote host to a local host, just interchange the source and destination path in the scp command.

scp user@remote-host:/home/document.txt /home/document.txt

The system will ask you for the remote user’s password once again. Enter the password to confirm the transfer process.

Between Two Remote Hosts

To copy files between two remote servers, both the source and destination paths must be directories on the remote hosts.

scp user1@remote-host1:/home/document.txt user2@remote-host2:/home/folder/document.txt

Again, a prompt will appear asking you to enter the password for each of the two users.

Scp Command-Line Options

Apart from simply transferring the files from source to destination, scp has some additional options that can be invoked using specific arguments.

Change the Port

By default, the scp command works on port 22. However, you can always overwrite the default configuration and change the port. The -P flag allows you to do the same.

To use some other port number while copying files from a local host to a remote host:

scp -P 35 /home/document.txt user@remote-host:/home/document.txt

The aforementioned command will ensure that the scp command uses port 35 for transferring files.

Preserve File Timestamps

You might know that Linux sets timestamps for each file to store the modification time, access time, and change time associated with the file. When you transfer the file to another location using scp, the timestamps of the destination file are overridden by the current time.

If for any reason you want to preserve these timestamps, use the -p flag. Notice that -P and -p flags are different from each other.

scp -p /home/document.txt user@remote-host:/home/remote/document.txt

Copy Directories

If you want to copy directories instead of files, use the -r flag to transfer directories recursively.

scp -r user@remote-host:/home/videos /home/videos

Suppressed Mode

When you enter the scp command in order to transfer files, the terminal displays the progress bar and other related information on the screen. However, you can choose not to view this information using the -q flag.

scp -q user@remote-host:/home/document.txt /home/document.txt

Use a Keypair File for Authentication

If you want to authenticate the remote host connection using a keypair file, specify the path of the file using the -i flag.

scp -i /home/keypair.pem /home/document.txt user@remote-host:/home/document.txt

Chaining Multiple Flags Together

Just like any other Linux command, you can chain multiple arguments together to make the scp command more effective.

For example, to change the port and transfer files in suppressed mode:

scp -P 34 -q user@remote-host:/home/document.txt home/document.txt

If you want to use a keypair file for authentication and need to copy directories to the destination path:

scp -i /home/secret/keypair.pem -r /home/folder user@remote-host:/home/folder

File Transfer Between Linux Systems

In the world of the internet, transferring files between systems has become an essential task. For those who are administrating Linux servers, sometimes it is important to take a backup of the server before issuing a specific command. In situations like this, the scp command comes in handy.

Similarly, the cp command helps in copying the files from one location to another in a local system. There are many basic commands that are a must if you’re just getting started with Linux.

MUO – Feed

How Fishing Line Is Made

https://theawesomer.com/photos/2021/03/how_fishing_line_is_made_t.jpg

How Fishing Line Is Made

Link

Some fishing lines are monofilament, while others are braided from multiple strands. Science Channel takes us inside a factory that produces braided line, combining numerous microfibers into a single strong one, then bathing them in dye for color. They show how they make a smooth line that’s been coated in resin.

The Awesomer

Lansky Releases New Handy Compact Knife Sharpener Combo Kit

Lansky Releases New Handy Compact Knife Sharpener Combo Kit

https://ift.tt/3bMQoEU

I don’t know if there is anyone out there like me but I absolutely abuse the hell out of my knives. Not just the daily carry ones but every blade I have has probably seen more than its fair share of abuse. With that being said, I’m constantly needing to sharpen my knives on a regular basis and luckily Lansky has come out with a brand new knife sharpening kit for 2021.

Lansky Releases New Handy Compact Knife Sharpener Combo Kit

Lansky Releases New Handy Compact Knife Sharpener Combo Kit

The Lansky C-Clip Combo Knife Sharpening Kit

The Lansky C-Clip Combo Knife Sharpening Kit comes with three of Lansky’s well-regarded knife sharpening tools that are all small enough to take with you on the go. Whether this means stowing them in your vehicle, backpack, pocket, or even carrying them on a key chain, these knife sharpeners will always be ready to go when your blades go dull. The combo kit includes the Lansky C-Clip, “Mini” Knife Sharpener, and Eraser Block rod cleaner that has some other useful functions as well.

C-Clip Knife Sharpener

Lansky Releases New Handy Compact Knife Sharpener Combo Kit

The C-CLIP Knife Sharpener can be used to sharpen knives, fishhooks, darts, arrowheads, tools, needles, surgical-type tools, and more. At home, camping, fishing, hunting, boating, at work—The C-Clip is the most convenient solution.

This knife sharpener would work for some good all-around sharpening. I would probably keep a sharpener like this in my glove box or camping backpack for my general sharpening needs. From what I can tell it looks like you can store the sharpening rods underneath the clip and then stuff it in your pocket.

“Mini” Knife Sharpener

Lansky Releases New Handy Compact Knife Sharpener Combo Kit

The “Mini” Knife Sharpener can be carried on its keychain, on a belt hook, or like loose change in a pocket. You can keep this sharpener with you at all times!

The name says it all, this mini knife sharpener would probably go great on any keychain and with as much as I sharpen my dull knives, I’d probably get the most use of this one than either of the other two tools.

Eraser Block

Lansky Releases New Handy Compact Knife Sharpener Combo Kit

It’s more than a ceramic rod cleaner! Eraser Block works right out of the package to keep your ceramic rods clean and sharpening at peak efficiency…and it can erase hard to remove stains and spots on practically any surface, including sports equipment!

I only recently became aware that ceramic sharpening rods needed to be cleaned regularly and the Eraser Block does exactly that as well as a few other neat things like cleaning stains off of walls and desks. Definitely useful beyond its intended design. The eraser block also apparently works really well at removing rust from metal tools.

If you’re interested in purchasing the Lansky C-Clip Combo Kit or any of Lansky’s other products you can either visit their website directly or check out their Amazon store page here.



We are committed to finding, researching, and recommending the best products. We earn commissions from purchases you make using the retail links in our product reviews.

Learn more about how this works

.

guns

via The Firearm Blog https://ift.tt/2JX8W99

March 15, 2021 at 11:21AM

Python’s Top 29 Built-In Functions with Examples

Python’s Top 29 Built-In Functions with Examples

https://ift.tt/3vqzfsw

Python comes with many built-in functions you can use without importing a library. There are 64 of them. In this article, you’ll get an overview of the most important ones.

Let’s dive into the most important 29 Python built-in functions next!

help()

Python’s built-in help() function launches Python’s help system. Without an argument, help() starts an interactive session. With a string argument, help(name) looks up the name and prints a help page to the shell. With a non-string argument, help(object) prints a help page on object.

>>> help(list)             # Prints the documentation of list
>>> help(dict)             # Prints the documentation of dict
>>> help(int)              # Prints the documentation of int
>>> help('help')           # Prints the documentation of help()
>>> help()                 # Opens an interactive "help" session

input()

Python’s built-in input() function reads a string from the standard input. The function blocks until such input becomes available and the user hits ENTER. You can add an optional prompt string as an argument to print a custom string to the standard output without a trailing newline character to tell the user that your program expects their input.

>>> s = input()
42
>>> s
'42'

print()

Python’s built-in print() function prints a string representation of any number of objects to the standard output. The print() function has many advanced arguments to customize the behavior—such as the separator argument to set a custom separator string between the printed objects, the end argument to set a custom ending string, or the file argument that even allows you to print a string into a file object.

>>> print('hello')
hello
>>> print('hello world')
hello world
>>> print(42)
42
>>> print(1, 2, 3)
1 2 3
>>> print('hello', 'world', sep = '\n')
hello
world
>>> print('hello', 'world', sep = '\n', end = '\n-----\n')
hello
world
-----

format()

Python’s built-in format(value, spec) function transforms input of one format into output of another format defined by you. Specifically, it applies the format specifier spec to the argument value and returns a formatted representation of value. For example, format(42, 'f') returns the string representation '42.000000'.

>>> format(42)
'42'
>>> format(42, 'f')
'42.000000'
>>> format(42, '.10f')
'42.0000000000'
>>> format(42, '.2f')
'42.00'

exec()

Python’s exec() function executes the Python code you pass as a string or executable object argument. This is called dynamic execution because, in contrast to normal static Python code, you can generate code and execute it at runtime. This way, you can run programmatically-created Python code.

>>> program = 'print("hello world")'
>>> exec(program)
hello world
>>> exec('x=2; y=4; print(x+y)')
6

Every Python master understands the basics very well. Python built-in functions are the very foundation your whole coding career stands on. For a full course on all 64 Python built-in functions, check out the Finxter Computer Science Academy:

eval()

Python eval(s) parses the string argument s into a Python expression, runs it, and returns the result of the expression. This poses a security risk because a user can use it to run code on your computer. For example, if you allow eval(input()), a user could type os.system('rm -R *') to delete all files in your home directory.

>>> eval('2+2')
4
>>> eval('[1, 2, 3]*3')
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> eval('[x for x in range(10)]')
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> eval('"Alice".replace("e", "")')
'Alic'

compile()

Python’s built-in compile() method returns an executable code object as an “Abstract Syntax Tree” represented as an ast object. By passing this code object into the exec() or eval() functions, you can run it dynamically in your Python code. This way, you can programmatically create source code and execute it at runtime. To use the function, pass the string code to be executed, the filename, and the execution mode. For example compile('print("hi")', '<string>', 'exec') creates a code object consisting of one line print("hi").

# 1. Read code from file
f = open('filename.py', 'r')
code = f.read()
f.close()

# 2. Compile code string
code_obj = compile(code, 'filename.py', 'exec')

# 3. Run the code object (ast)
exec(code_obj)

abs()

Python’s built-in abs(x) function returns the absolute value of the argument x that can be an integer, float, or object implementing the __abs__() function. For a complex number, the function returns its magnitude. The absolute value of any numerical input argument -x or +x is the corresponding positive value +x.

# POSITIVE INTEGER
x = 42
print(abs(x))


# NEGATIVE INTEGER
x = -42
print(abs(x))


# POSITIVE FLOAT
x = 42.42
print(abs(x))


# NEGATIVE FLOAT
x = -42.42
print(abs(x))

divmod()

Python’s built-in divmod(a, b) function takes two integer or float numbers a and b as input arguments and returns a tuple (a // b, a % b). The first tuple value is the result of the integer division a//b. The second tuple is the result of the remainder, also called modulo operation a % b. In case of float inputs, divmod() still returns the division without remainder by rounding down to the next round number.

# divmod() with integers
>>> divmod(10, 2)
(5, 0)
>>> divmod(10, 3)
(3, 1)
>>> divmod(10, 4)
(2, 2)
>>> divmod(10, 5)
(2, 0)
>>> divmod(10, 10)
(1, 0)

round()

Python’s built-in round() function takes two input arguments: a number and an optional precision in decimal digits. It rounds the number to the given precision and returns the result. The return value has the same type as the input number—or integer if the precision argument is omitted. Per default, the precision is set to 0 digits, so round(3.14) results in 3.

>>> round(3.14)
3
>>> round(3.14, ndigits=1)
3.1
>>> round(3.13, ndigits=-1)
0.0
>>> round(4458.1242, ndigits=-1)
4460.0
>>> round(3.14159, ndigits=3)
3.142

hash()

Python’s built-in hash(object) function takes one object as an argument and returns its hash value. As the hash value is calculated based on the object’s data, two different but equal objects must have the same hash value. It doesn’t follow, though, that two objects with the same hash value are equal—they can have the same hash value and still be different.

>>> hash(42)
42
>>> hash('42')
-7286207279771019371

callable()

Python’s built-in callable(object) returns True if you could call the object argument like a function with the trailing parentheses in object(). You can make any object callable by implementing the instance’s __call__() method. For example, callable(callable) returns True because callable is a function object. But callable(3) returns False because an integer is not a function you can call.

>>> callable(callable)
True
>>> callable(3)
False

iter()

Python’s built-in iter() function returns an iterator for the given object. For example, iter([1, 2, 3]) creates an iterator for the list [1, 2, 3]. You can then iterate over all elements in the iterator, one element at a time, in a for or while loop such as: for x in iter([1, 2, 3]).

customers = ['Alice', 'Bob', 'Carl', 'Dave', 'Elena', 'Frank']
iterator = iter(customers)

print(next(iterator))
print(next(iterator))

for x in iterator:
    print(x)

''' OUT:
Alice
Bob
Carl
Dave
Elena
Frank
'''

Every Python master understands the basics very well. Python built-in functions are the very foundation your whole coding career stands on. For a full course on all 64 Python built-in functions, check out the Finxter Computer Science Academy:

next()

The next(iterator) function is one of Python’s built-in functions—so, you can use it without importing any library. It returns the next value from the iterator you pass as a required first argument. An optional second argument default returns the passed default value in case the iterator doesn’t provide a next value.

users = ['Alice', 'Bob', 'Carl', 'David']

# convert the list to an iterator
users_iterator = iter(users)

x = next(users_iterator)
print(x)
# Output: 'Alice'

x = next(users_iterator)
print(x)
# Output: 'Bob'

x = next(users_iterator)
print(x)
# Output: 'Carl'

x = next(users_iterator)
print(x)
# Output: 'David'

list()

The Python range() function creates an iterable of subsequent integers within a given range of values. You can pass either only a stop argument in which case the range object will include all integers from 0 to stop (excluded). Or you can pass start, stop, and step arguments in which case the range object will go from start to step using the given step size. For example, range(3) results in 0, 1, 2 and range(2, 7, 2) results in 2, 4, 6.

>>> x = [1, 2, 3]
>>> y = list(x)
>>> x is y
False
>>> x == y
True

range()

The Python range() function creates an iterable of subsequent integers within a given range of values. You can pass either only a stop argument in which case the range object will include all integers from 0 to stop (excluded). Or you can pass start, stop, and step arguments in which case the range object will go from start to step using the given step size. For example, range(3) results in 0, 1, 2 and range(2, 7, 2) results in 2, 4, 6.

>>> range(10)
range(0, 10)
>>> print(range(10))
range(0, 10)
>>> print(*range(10))
0 1 2 3 4 5 6 7 8 9
>>> range(1, 10, 3)
range(1, 10, 3)
>>> print(*range(1, 10, 3))
1 4 7

len()

Python’s built-in function len() returns the length of the given string, array, list, tuple, dictionary, or any other iterable. The type of the return value is an integer that represents the number of elements in this iterable.

>>> friends = ['Alice', 'Bob', 'Carl', 'Ann']
>>> len(friends)
4
>>> friends.extend([1, 2, 3])
>>> len(friends)
7
>>> len('hello world')
11
>>> len('hi')
2
>>> len((1, 2, 3))
3
>>> len({42, 21})
2
>>> age = {'Alice': 18, 'Bob': 21}
>>> len(age)
2
>>> age['Carl'] = 33
>>> len(age)
3

max()

The max() function returns the maximum of the provided arguments. You can pass either an arbitrary number of values, comma-separated, or an iterable as arguments. An optional key function argument allows you to customize the calculation of the maximum by explicitly defining the weight of each value in the iterable that is used as a basis of comparison.

>>> max(1, 2, 3)
3
>>> max(1, 2, 3, key = lambda x: -x)
1

min()

The min() function returns the minimum of the provided arguments. As arguments, you can either pass a number of comma-separated values, or a single iterable. An optional key function argument allows you to customize the calculation of the minimum by explicitly defining the weight of each value in the iterable that is used as a basis of comparison.

>>> min(1, 2, 3)
1
>>> min(1, 2, 3, key = lambda x: -x)
3

Every Python master understands the basics very well. Python built-in functions are the very foundation your whole coding career stands on. For a full course on all 64 Python built-in functions, check out the Finxter Computer Science Academy:

sum()

To help you accomplish this task in a concise, readable, and efficient way, Python’s creators have added the built-in sum() function. It sums over all elements in a Python list—or any other iterable for that matter.

lst = [1, 2, 3, 4, 5, 6]

print(sum(lst))
# 21

print(sum(lst, 10))
# 31

slice()

Python’s built-in slice() function returns a new slice object you can use to slice over sequences such as lists, strings, or tuples.

>>> lst =list(range(20))
>>> lst
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> s = slice(10)
>>> lst[s]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> lst =list(range(20))
>>> s = slice(2, 10, 2)
>>> lst[s]
[2, 4, 6, 8]

enumerate()

Python’s built-in enumerate(iterable) function allows you to loop over all elements in an iterable and their associated counters. Formally, it takes an iterable as an input argument and returns an iterable of tuples (i, x)—one per iterable element x. The first integer tuple value is the counter of the element x in the iterable, starting to count from 0. The second tuple value is a reference to the element x itself. For example, enumerate(['a', 'b', 'c']) returns an iterable (0, 'a'), (1, 'b'), (2, 'c'). You can modify the default start index of the counter by setting the optional second integer argument enumerate(iterable, start).

fruits = ['apple', 'banana', 'cherry']
for counter, value in enumerate(fruits):
    print(counter, value)

# OUTPUT:
# 0 apple
# 1 banana
# 2 cherry

reversed()

Python’s built-in reversed(sequence) function returns a reverse iterator over the values of the given sequence such as a list, a tuple, or a string.

>>> list(reversed([1, 2, 3]))
[3, 2, 1]
>>> tuple(reversed([1, 2, 3]))
(3, 2, 1)

Every Python master understands the basics very well. Python built-in functions are the very foundation your whole coding career stands on. For a full course on all 64 Python built-in functions, check out the Finxter Computer Science Academy:

sorted()

The sorted() function takes a specified iterable input and returns a sorted list

>>> x = [4, 1, 2]
>>> sorted(x)
[1, 2, 4]

filter()

Python’s built-in filter() function is used to filter out elements that pass a filtering condition. It takes two arguments: function and iterable. The function assigns a Boolean value to each element in the iterable to check whether the element will pass the filter or not. It returns an iterator with the elements that pass the filtering condition.

lst = [8, 2, 6, 4, 3, 1]

# Filter all elements <8
small = filter(lambda x: x<8, lst)
print(list(small))


# Filter all even elements
even = filter(lambda x: x%2==0, lst)
print(list(even))

# Filter all odd elements
odd = filter(lambda x: x%2, lst)
print(list(odd))

map()

>>> m = map(lambda x: 42, [1, 2, 3])
>>> type(m)
<class 'map'>

any()

The zip() function takes an arbitrary number of iterables and aggregates them to a single iterable, a zip object. It combines the i-th values of each iterable argument into a tuple. Hence, if you pass two iterables, each tuple will contain two values. If you pass three iterables, each tuple will contain three values. For example, zip together lists [1, 2, 3] and [4, 5, 6] to [(1,4), (2,5), (3,6)].

# Boolean list with False value
print(any([True, False, True, True]))
# True


# Boolean list without False value
print(any([True, True]))
# True


# Integer list with 0 value
print(any([1, 2, -1, 0]))
# True


# Integer list without 0 value
print(any([1, 2, -1]))
# True


# Nested list with empty inner list
print(any([[], [1, 2, 3]]))
# True


# Nested list with two empty inner lists
print(any([[], []]))
# False


# Empty List
print(any([]))
# False

all()

The zip() function takes an arbitrary number of iterables and aggregates them to a single iterable, a zip object. It combines the i-th values of each iterable argument into a tuple. Hence, if you pass two iterables, each tuple will contain two values. If you pass three iterables, each tuple will contain three values. For example, zip together lists [1, 2, 3] and [4, 5, 6] to [(1,4), (2,5), (3,6)].

# Boolean list with False value
print(all([True, False, True, True]))
# False


# Boolean list without False value
print(all([True, True]))
# True


# Integer list with 0 value
print(all([1, 2, -1, 0]))
# False


# Integer list without 0 value
print(all([1, 2, -1]))
# True


# List of Lists with empty inner list
print(all([[], [1, 2, 3]]))
# False


# List of Lists without empty inner list
print(all([[1, 2, 3], [4, 5]]))
# True


# Empty List
print(all([]))
# True

zip()

The zip() function takes an arbitrary number of iterables and aggregates them to a single iterable, a zip object. It combines the i-th values of each iterable argument into a tuple. Hence, if you pass two iterables, each tuple will contain two values. If you pass three iterables, each tuple will contain three values. For example, zip together lists [1, 2, 3] and [4, 5, 6] to [(1,4), (2,5), (3,6)].

lst_1 = [1, 2, 3]
lst_2 = [4, 5, 6]

# Zip two lists together
zipped = list(zip(lst_1, lst_2))
print(zipped)
# [(1, 4), (2, 5), (3, 6)]


# Unzip to lists again
lst_1_new, lst_2_new = zip(*zipped)
print(list(lst_1_new))
print(list(lst_2_new))

Every Python master understands the basics very well. Python built-in functions are the very foundation your whole coding career stands on. For a full course on all 64 Python built-in functions, check out the Finxter Computer Science Academy:

The post Python’s Top 29 Built-In Functions with Examples first appeared on Finxter.

Python

via Finxter https://ift.tt/2HRc2LV

March 15, 2021 at 06:11AM

This New Falcon and the Winter Soldier Clip Is a Minute of Pure Delight

This New Falcon and the Winter Soldier Clip Is a Minute of Pure Delight

https://ift.tt/2Oj82aE


Sam (Anthony Mackie) and Bucky (Sebastian Stan) take a break from giving each other crap.
Image: Disney

Okay, honestly? It’s only 54 seconds long. But if you watch this amazing new clip from the show, it’s going to be the best 54 seconds of your day, guaranteed.

It features what Sam “Falcon” Wilson (Anthony Mackie) and Bucky “Winter Soldier” Barnes (Sebastian Stan) do best, which is banter with each other, flex at each other, and give each other shit. But this isn’t mere masculine posturing, it’s something far more sublime:

I can’t decide what’s better: Sam’s sudden realization that a sorcerer is just a wizard without a hat (which honestly may be the best, most succinct definition of a sorcerer I’ve ever heard), or Bucky acting smug about having read the beloved children’s fantasy book The Hobbit back when it was first published in 1937 as if that meant absolutely anything, other than maybe someone who’s devoted enough to Tolkien they’ve learned to speak Elvish, which Sam very clearly has not.

By the way, if you want to delve into Bucky’s idea of the “Big Three” foes as androids, aliens, and wizards, I don’t think he’s wrong there, either. Yes, various Marvel cinematic heroes have tussled with all sorts of bad guys in their individual movies, but when it comes to (external) threats that actually require the Avengers—the “big” problems, as it were—they’ve included two alien invasions (the Chitauri in Avengers, then Thanos and his armies in Infinity War) and an android uprising during the Age of Ultron. As for wizards, Sam may be referring to the Scarlet Witch, but I don’t believe so because it would be weird for him to then omit Quicksilver. I think he’s referring to Loki, because I bet it’s hard for most humans in the MCU to accept Thor and the other Asgardians as literal gods, as their divinity would challenge most humans’ religious and scientific worldviews. Plus, Loki does have some straight-up magic powers, enough for Sam (or anyone, frankly) to classify him as a wizard. My point is the “Big Three” are definitely a thing, to quote Sam himself.

G/O Media may get a commission

If this clip is at all indicative of The Falcon and the Winter Soldier series—and by all other clips and accounts, it is—we’re going to have a very good day when it premieres on Disney+ on March 19.


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

geeky,Tech

via Gizmodo https://gizmodo.com

March 12, 2021 at 03:12PM

Woman Attempts to ‘Mask-Shame’ Dude, Quickly Discovers Truth (Updated)

Woman Attempts to ‘Mask-Shame’ Dude, Quickly Discovers Truth (Updated)

https://ift.tt/38AFMXJ

UPDATE: Apparently I’m the one who got pranked. Here’s the original video that is "for entertainment purposes only." Personally, I still think it’s funny as hell.

Wearing a mask of yourself wearing a mask wrong is the trend America needs. It makes sense when you think of it. There are people in this country, silly, somewhat unhinged people, who think it’s their job to play mask police. If they see you maskless in public, you will be shamed! They feel it’s their "patriotic" duty. Plus, think of all the likes and retweets they can get on Twitter! Panic porn-addicted, overzealous mask advocates love the smell of each other’s flatulence.

When really, the truly patriotic thing to do is to f*** with these people. The last guy we saw do it, the other person at least had a sense of humor about it. This broad, not so much. The story starts with her smartphone out to document the alleged maskless person.

"I mean, I don’t understand why you would wear a mask like that."

You. People like YOU are why he would wear a mask like that. People who see someone not as masked up as the CDC says to be, and their first instinct ISN’T to mind their own beeswax. People’s whose first instinct is to lecture strangers in the store. People like YOU are the exact reason why someone would wear a mask like that.

Lady, take the L. You got caught in a prank. You’re not the only one with your smartphone out. In this instance, you were in fact the a-hole. Admit it. Laugh it off. Say, "You got me, dawg." Move on to the next aisle. Maybe you can spot two people only standing five feet and ten inches away from each other.


CAUGHT ON CAMERA! Entire Oakley School Board RESIGNS | Louder With Crowder

youtu.be

fun

via Louder With Crowder https://ift.tt/2pjixJJ

March 12, 2021 at 07:42AM