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

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

2019 Columbus Crime Data

2019 Columbus Crime Data

https://ift.tt/3leKZcP

I updated the Columbus Crime Statistics page with 2019 data, which is the latest year available. The data comes from what the city reported to the FBI’s Uniform Crime Reporting system.

2019 Violent Crime
-There were 5,350 incidents of violent crime in Columbus in 2019, down slightly from 2018’s 5,365. The rate per 100K people was 595.4, down from 2018’s 601.0.
-There is some discrepancy between the murders the city reported to the FBI- 81- and the total number of homicides it reported in its 2019 year-end report- 104. At 81 murders, it would be a rate of 9 per 100K, while 104 would be a rate of 11.6 per 100K. Even at 104, it would represent a drop from 2018’s 109.
-There were 882 reported rapes, down from 2018’s 894. There were 98.2 rapes per 100K, down from 2018’s 99.9.
-Robberies continued their years-long decline, with 1,810 total and a rate of 201.4 per 100K. Robberies have declined 53% since 2007.
-There were 1,788 aggravated assaults at a rate of 199.0 per 100K. Assaults were higher than 2018’s 1,615, but they are still down nearly 35% since they peaked in 1990.

Violent Crime Changes By Race 2010-2019
Other: -72.7%
Black: -34.6%
White: -21.3%
Unknown Race: -18.2%
Asian: +33.3%

Violent Crime Changes By Gender 2010-2019
Unknown Gender: -42.0%
Male: -35.2%
Female: +21.7%

Violent Crime Changes By Age Group 2010-2019
0 to 19: -41.2%
20 to 39: -33.9%
Unknown Age: -30.8%
40 to 59: +12.8%
60 and Over: +220.9%

Perhaps strangely, Asians, women and older people have seen their crime rates increase. In all 3 cases, the total crimes were relatively low in comparison to other groups, but the changes were significant enough to be noticeable.

2019 Property Crime
-There were 29,974 property crimes reported in 2019 for a rate of 3335.6 per 100K, down from 2018’s 3596.3.
Property crimes peaked in 2001 with 62,151, but have fallen nearly every year since. The 2019 total was 51.8% lower than in 2001.
-Larceny thefts reached 20,606 for a rate of 2293.1 per 100K. This is both down from 2018’s 2427.8 and 46.9% lower than their 2001 peak.
-Burglaries continued their dramatic fall in 2019. 5,809 were reported for a rate of 646.5 per 100K. This is down from 6,477 and 724.9 in 2018, and down nearly 62% just since 2010.
-There were 3,559 motor vehicle thefts for a rate of 396.1 per 100K in 2019, down from 3,962 and 443.7 in 2018. As with burglaries, motor vehicle thefts are down significantly in recent years, having fallen more than 58% just since 2004.

Property Crime Changes By Race 2010-2019
Other: -62.5%
White: -43.9%
Black: -27.7%
Unknown Race: +5.5%
Asian: +22.9%

Property Crime Changes By Gender 2010-2019
Male: -36.9%
Female: -23.3%
Unknown Gender: -0.9%

Property Crime Changes By Age Group 2010-2019
0 to 19: -48.7%
20 to 39: -33.1%
40 to 59: -25.5%
Unknown Age: +2.9%
60 and Over: +31.5%

Here are some additional crime-related links.
Columbus Police Department
National Crime Data Explorer

Like this:

Like Loading…

non critical

via All Columbus Data https://ift.tt/2ORoTMW

March 12, 2021 at 09:37AM

Report on COVID-related philanthropy credits MacKenzie Scott with powering 25% of U.S. giving

Report on COVID-related philanthropy credits MacKenzie Scott with powering 25% of U.S. giving

https://ift.tt/2PRK2vz

MacKenzie Scott. (Elena Seibert Photo)

A new report looking at the global philanthropic response to COVID-19 during 2020 credits MacKenzie Scott with singlehandedly powering 25% of the giving effort in the United States.

The report by the Center for Disaster Philanthropy and Candid looked at the sources of more than $20 billion awarded for pandemic-related causes, including corporations, foundations, public charities and high-net-worth individuals such as Scott.

By giving $4 billion of her Amazon-fueled wealth to 384 different nonprofits in December, Scott dramatically increased the proportion of giving by high-net-worth individuals. Of the $5.8 billion given by the group, Scott accounted for nearly three quarters of the amount.

The former wife of Amazon CEO Jeff Bezos took a more high-profile approach to her philanthropic giving in 2020. She keyed on the destruction caused by the COVID-19 pandemic, calling it a “wrecking ball in the lives of Americans already struggling” and saying that “economic losses and health outcomes alike have been worse for women, for people of color, and for people living in poverty.”

Scott, who is currently No. 21 on the Bloomberg Billionaires Index of wealthiest individuals, impacted several categories across the report with her giving, including:

  • BIPOC communities: Of U.S. COVID-19 philanthropy to specified recipients, 35% of dollars was explicitly designated for Black, Indigenous and people of color (BIPOC) communities. High-net-worth donors in the data set designated a higher proportion of their funding for BIPOC communities (44 percent). This was almost entirely due to Scott’s grantmaking.
  • Health organizations: This group ranked second, accounting for 26% of dollars. Top health organizations included Gavi, the Vaccine Alliance, and the COVID-19 Therapeutics Accelerator. Easterseals (the national office combined with its affiliates) emerged in the top recipient list thanks to Scott’s $162 million award. The organization offers services and advocacy for people with disabilities.
  • Unrestricted or flexible support: This area dramatically increased in the second half of the year, with 39% of dollars and 21% of gifts to specified recipients described as unrestricted or flexible. Scott’s large, unrestricted grants accounted for the major shift.

The report lists Google as the top corporate donor, with 17 gifts totaling more than $1 billion.

The Bill and Melinda Gates Foundation was tops in funding by foundations, giving 398 gifts totaling $1.3 billion.

Scott made news earlier this week when it was revealed that she married Dan Jewett, a Seattle science teacher. Jewett signed on to The Giving Pledge, an initiative Scott previously committed to in which the ultra rich pledge to give their fortunes to charity.

In July 2020, Scott named 116 non-profits that were receiving $1.67 billion of her wealth.

geeky

via GeekWire https://ift.tt/2pQ6rtD

March 10, 2021 at 02:58PM

T-Mobile Is Taking All of Your Sweet, Sweet Data… Unless You Tell It to Stop

T-Mobile Is Taking All of Your Sweet, Sweet Data… Unless You Tell It to Stop

https://ift.tt/3vcsiLk


Photo: John MacDougall (Getty Images)

Heads up, fellow T-Mobile customers: You might want to take a look at your mobile carrier’s privacy policy.

As first spotted by the Wall Street Journal, the company’s latest update to its privacy policy is set to automatically enroll paying phone subscribers into an ad-targeting program that will see their data shared with unnumbered advertisers starting next month. It’s also worth noting here that the privacy policy update also carries over for any Sprint customers who were gobbled by T-Mobile during the two company’s mega-merger last year.

T-Mobile’s latest Privacy Notice lays out some of the specifics: Starting April 26, the company writes, it will begin a “new program” that shares some personal data—like the apps you download or the sites you visit—with third-party advertisers. T-Mobile also adds that it won’t share your precise location data “unless you give [T-Mobile] your express permission,” and won’t share information in a way that can be directly tied back to your device. But like we’ve written before, just because a dataset is “anonymized” doesn’t mean that you can take the company anonymizing it (T-Mobile, in this case) at its word.

T-Mobile is hardly the only major telco to pull these kinds of ad-targeting shenanigans. Verizon, for example, has an entire subsidiary—Verizon Media—that compiles data from its customers (along with a few third parties) to make its own different audience categories for targeted ads. AT&T’s had its own adtech subsidiary, Xandr, on hand since 2018 for similar purposes: pooling similar buckets of subscriber data together, and then pawning off that data to advertisers that might be interested in reaching, say, new moms, vegetarians, or luxury shoppers on their specific networks.

The company, for its part, promised the Wall Street Journal that it was defaulting to this new setting because “many say they prefer more relevant ads,” which is one of the most oft-repeated arguments people in the ad industry like to throw around to justify their invasive practices. In fact, there’s another reason that T-Mobile might be incentivized to throw this update out right now.

G/O Media may get a commission

The ongoing updates to Apple’s iOS 14 and the upcoming updates to Google’s Chrome browser have left some advertiser’s core data-collection tactics—like mobile ID’s and third-party cookies—in the dust. Some major companies in the data-brokering space have begun pitching their own sorts of data-hoovering tech that can circumvent these new roadblocks, and T-Mobile’s new policy seems to be another spin on that, just coming from your phone service provider.

T-Mobile’s policy page, for its part, has a pretty comprehensive guide describing how to opt-out of this new program at the bottom of its new notice here, which is something you should go do right now.

geeky,Tech

via Gizmodo https://gizmodo.com

March 9, 2021 at 04:42PM

Livewire Demo: Full-Page Components in a Reusable Structure

Livewire Demo: Full-Page Components in a Reusable Structure

https://www.youtube.com/watch?v=xY0O2tSO8v0

Today I’m doing a code review, but it’s more like a showcase of a project that was architecturally fully built on Livewire. Let’s see the details and discuss this approach, what do you think?

programming

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

March 9, 2021 at 04:48PM

T-Mobile will tell advertisers how you use the web starting next month

T-Mobile will tell advertisers how you use the web starting next month

https://ift.tt/3qu9bsJ


The logo of Deutsche Telekom, owner of T-Mobile, seen over a booth at the Mobile World Congress expo hall.
Enlarge /

The logo of Deutsche Telekom, owner of T-Mobile, seen at Mobile World Congress in February 2019 in Barcelona, Spain.

Getty Images | NurPhoto

T-Mobile next month will start a new program that gives customers’ web browsing and device usage data to advertisers unless customers opt out of the data sharing.

“[S]tarting April 26, 2021, T‑Mobile will begin a new program that uses some data we have about you, including information we learn from your web and device usage data (like the apps installed on your device) and interactions with our products and services for our own and 3rd party advertising, unless you tell us not to,” T-Mobile said in a privacy notice. “When we share this information with third parties, it is not tied to your name or information that directly identifies you.”

For directions on how to opt out of the expanded data sharing, see the first section of the T-Mobile privacy notice.

T-Mobile, which completed its purchase of Sprint in April 2020, said that the new advertising “program changes the way Sprint offered choices for sharing in the past, as this data was previously used only if you indicated that it was OK with you first.”

It’s not clear exactly how big a change this is for non-Sprint customers of T-Mobile. An August 2020 version of the privacy policy said that T-Mobile collects “websites and URLs visited” but did not list smartphone customers’ web browsing data in the list of information shared with third parties. However, that August 2020 version said that T-Mobile sold “device identifiers and Internet and electronic network activity to facilitate certain advertising activities commonly deployed by online and technology companies.” A similar disclosure was in T-Mobile’s privacy policy before the Sprint acquisition as well.

T-Mobile says in another webpage describing its advertising and analytics program that it collects “addresses of websites visited; types of websites visited, like sports sites, music sites, etc.; applications, content, and features used—including how much time you spent using them, and information from servers that host these apps, content, and features.”

Advertising IDs used instead of customer names

In order to anonymize data before it’s sold to third parties, T-Mobile said that it ties the information “to your mobile advertising identifier or another unique identifier” instead of the customer’s name. But you’ll have to take T-Mobile’s word on just how anonymous the anonymized data actually is. “[P]rivacy groups say those IDs can be linked back to people by comparing different data sets,” The Wall Street Journal noted in an article on the T-Mobile changes today.

“It’s hard to say with a straight face, ‘We’re not going to share your name with it,'” Electronic Frontier Foundation lawyer Aaron Mackey told the Journal. “This type of data is very personal and revealing, and it’s trivial to link that de-identified info back to you.”

Before the merger with T-Mobile, “Sprint had previously shared similar data only from customers who opted into its third-party ad program,” the Journal wrote. ”We’ve heard many say they prefer more relevant ads so we’re defaulting to this [opt-out] setting,” a T-Mobile spokesperson told the Journal.

We asked T-Mobile several questions about the data-sharing changes and for details on how exactly it ensures that data can’t be linked to individual customers, and we’ll update this article if we get a response.

AT&T and Verizon data-sharing doesn’t go as far

The Journal article said that T-Mobile is being more aggressive in sharing individual customers’ Internet usage data with advertisers than AT&T and Verizon:

AT&T automatically enrolls wireless subscribers in a basic ad program that pools them into groups based on inferred interests, such as sports or buying a car. An enhanced version of the program shares more-detailed personal information with partners from customers who opt into it.

Verizon likewise pools subscriber data before sharing inferences about them with advertisers, with a more-detailed sharing program called Verizon Selects for users who enroll. Its separate Verizon Media division shares data gathered through its Yahoo and AOL brands.

AT&T says on this webpage that “We don’t share information about your individual web browsing or TV viewing” in its “relevant advertising” system, but offers an “enhanced relevant advertising” system that shares additional information only with customers’ “prior explicit consent.”

Verizon says on a relevant mobile advertising FAQ that “Information Verizon Wireless has about web activity from your mobile device is not used in the program.” The program does use “mobile and online web browsing information” collected by Verizon’s Yahoo and AOL subsidiaries, but this apparently wouldn’t cover browsing to non-Verizon websites. Customers can opt out of this targeted advertising program.

In 2016, Verizon agreed to pay a $1.35 million fine and give users more control over “supercookies” that identify customers in order to deliver targeted ads. Verizon’s previous use of the supercookies without properly notifying users violated an FCC rule that required Internet providers to disclose accurate information about network management practices to consumers.

Carriers sold location data without consent

T-Mobile and the other major carriers were previously caught selling their customers’ real-time location data to third-party data brokers without customer consent, violating a law banning sales of phone-location data. The Federal Communications Commission in February 2020 proposed a fine of $91 million for T-Mobile, the biggest for any of the major carriers, but T-Mobile said it would fight the penalty.

The Obama-era FCC tried to require home Internet and mobile broadband providers to get consumers’ opt-in consent before using, sharing, or selling Web browsing and app usage histories, but a Republican-controlled Congress and then-President Trump killed the rule in 2017 before it took effect.

geeky

via Ars Technica https://arstechnica.com

March 9, 2021 at 05:38PM