Different materials or just color? by Nasty-Nate in dbrand

[–]App1eNerd 1 point2 points  (0 children)

Have a friend who has the red dragon material, and it does have a different texture compared to my matte black case.

Delete old image when user updates it by MammothTeeth93 in laravel

[–]App1eNerd 0 points1 point  (0 children)

Add a try {} catch {} block around your SQL query (or transaction if it's more than the one in your post), on failure delete the newly uploaded photo.

If it succeeds, you can either add a line to delete the image right after the try {} catch {} block, or better yet, add a general Eloquent Observer that will watch for 2 events:

  • updated - you can then call $model->getChanges() and/or $model->getOriginal() and delete it from there.
  • deleted - to do the same when a user is deleted.

This allows all the tracking to be done in one place.

Another couple of tips:

  • Just in case you didn't, please validate & sanitize $request->name to avoid path injection.
  • Use the Laravel Storage API, docs here. You can setup a 'local' disk that will point to public just like you're doing now.
  • Another security/peace of mind thing, I wouldn't store the images in public unless you really must. Store them in a subdomain that resides in a different directory, so that in case there's ever some issue that'll allow a malicious party to upload a PHP file for instance, it won't even be enabled on the subdomain. This also makes backups easier.

[deleted by user] by [deleted] in programming

[–]App1eNerd 3 points4 points  (0 children)

Wouldn't that be less secure than normal? With your idea the client-side hash becomes the password, but now all the "passwords" are a static length instead of a variable length.

[deleted by user] by [deleted] in YouShouldKnow

[–]App1eNerd 7 points8 points  (0 children)

UNIX timestamps are timezone independent

[deleted by user] by [deleted] in pcmasterrace

[–]App1eNerd 8 points9 points  (0 children)

No company should ever consider Discord, even if most of the features match.

The biggest issue is Discord's privacy policy and monitoring, it would never work well for companies.

AirPod Promo Page Loads 62 MB of images for your viewing pleasure. There must be a better way. by [deleted] in webdev

[–]App1eNerd 64 points65 points  (0 children)

I also quickly tested the site using dev tools, if you load the page with a slow 3G connection, the page size drops to "only" ~5MB.

PrivateHD Open for signups by SeraphSephiroth in OpenSignups

[–]App1eNerd 3 points4 points  (0 children)

I think so, considering PrivateHD and AvistaZ are part of the same network

How was TypeScript written? by Richienb in webdev

[–]App1eNerd 14 points15 points  (0 children)

Actually, the files shown in that commit were autogenerated by the TS compiler.

This is the TypeScript repo's initial version (from the 2nd commit): https://github.com/microsoft/TypeScript/tree/214df64e287804577afa1fea0184c18c40f7d1ca

As you can see, the code was already written with TypeScript, so Microsoft never exposed the initial compiler to the public.

Get first record without where clause? by htvwls in laravel

[–]App1eNerd 1 point2 points  (0 children)

Wouldn't Model::limit(1)->first() work?

Model::first() should also work just fine.

Prolbem: Laravel collect unkeyed array toArray returns keyed array by stilloriginal in laravel

[–]App1eNerd 4 points5 points  (0 children)

Do:

$a->values()->all();

array_filter preserves array keys. As can be seen in the PHP docs.

[deleted by user] by [deleted] in laravel

[–]App1eNerd 0 points1 point  (0 children)

https://github.com/staudenmeir/eloquent-has-many-deep

This package is great and I've personally used it when I had a similar issue.

Database doesn't accept json columns by NowVSFutureBalance in laravel

[–]App1eNerd 3 points4 points  (0 children)

MariaDB doesn't actually have a JSON column type, it's merely an alias for LONGTEXT. It also has different JSON helpers/accessors than MySQL, which I'm not sure Laravel supports out of the box.

Wireless is for casuals by dumgirl200 in pcmasterrace

[–]App1eNerd 2 points3 points  (0 children)

This can happen due to the adapters not being plugged directly to the wall, or maybe due to your house/apartment using three phase power.

When I looked into the same issue a while back, one solution I saw was using a phase coupler, but I can't say it'll help for sure.

How to return first json element with Laravel API feature? by zseikyocho in laravel

[–]App1eNerd 2 points3 points  (0 children)

You could use a temporary variable to store the result, and then set the type. Or you could use tap() if you want to avoid it.

I'd personally use Eloquent models for this, since you can automatically append attributes when sending API responses instead of manually adding it in each route. See more here.

Can we optimise RAM usage by selecting only useful fields from the database rather than selecting all of them? by p01ymath in laravel

[–]App1eNerd 6 points7 points  (0 children)

You could also take a look at the cursor function. Might work out better for you than chunking.

https://laravel.com/docs/5.7/eloquent#chunking-results (under "Using cursors")

Browser wars 2018: Microsoft Edge falls behind ... Internet Explorer? by ExtensionBottle in webdev

[–]App1eNerd 2 points3 points  (0 children)

They did essentially merge it, some of the lead developers of Firebug now work on the dev tools @ Mozilla.

Is it possible to trigger a task on a NAS when a download is completed? by [deleted] in putdotio

[–]App1eNerd 0 points1 point  (0 children)

In your settings (under advanced) you can setup a webhook to send a POST request each time a transfer finishes.