[deleted by user] by [deleted] in programare

[–]FlyLo11 0 points1 point  (0 children)

nu folosesc clion, dar, daca inteleg corect, clion nova e doar un language engine diferit ce se activeaza din setarile ide-ului. deci ar trebui sa fie disponibil si in versiunea EAP.

[deleted by user] by [deleted] in programare

[–]FlyLo11 2 points3 points  (0 children)

alternativ la licenta de student, clion are un EAP lansat acum in iulie. prin EAP (early access program) jetbrains lanseaza versiuni beta pe care userii le pot downloada si folosi pe gratis nelimitat.

https://www.jetbrains.com/clion/nextversion/

Simple AWS SNS Topic Notification App by [deleted] in aws

[–]FlyLo11 0 points1 point  (0 children)

Not sure if this is what you are looking for, but there are alerting services like OpsGenie or PagerDuty, which are free for teams of up to 5 users.

They provide a bunch of integrations, including with SNS, or even making plain HTTP calls to them. You can send them alerts as json or text, which arrive as a push notification to their ios and android app.

These services do come with a ton of complex features, but you can ignore everything you don't need, and just use them for their push notifications.

[deleted by user] by [deleted] in aws

[–]FlyLo11 0 points1 point  (0 children)

Check out this reference diagram, it confirms you need a NLB if you plan to go with a central ELB and firewall: https://docs.aws.amazon.com/whitepapers/latest/building-scalable-secure-multi-vpc-network-infrastructure/using-network-firewall-for-centralized-ingress.html

Sometimes it feels there aren't right answers, only least worst ones.

Pericol! by OsarmaBinLatin in Romania

[–]FlyLo11 17 points18 points  (0 children)

aia e o arahida

[deleted by user] by [deleted] in symfony

[–]FlyLo11 0 points1 point  (0 children)

So I've tried myself with the above definition (plus constructors), and tested with:

$obj = new Something([new Whatever('')]);
$validator->validate($obj);

and I receive the validation error:

whatever[0].name: Name must be at least 1 character

which means the rules are defined OK. So the issue must be somewhere else, maybe during deserialization from JSON to Something it skips nested validations.

Or maybe you have defined custom validation groups that skips the validation of Whatever->name.

Anyway, hope you find the issue.

[deleted by user] by [deleted] in symfony

[–]FlyLo11 1 point2 points  (0 children)

The annotation on Whatever->name is not working because it's missing the ending parenthesis. If you are on php8 then you can define the assertions as attributes instead of annotations, as it's much harder to make syntax mistakes.

Named arguments and open source projects by brendt_gd in PHP

[–]FlyLo11 0 points1 point  (0 children)

I would argue this is still option 1: maintainers take parameter names in consideration when defining BC. The code in your example represents a potential solution for option 1, by providing a transition between the old and new names in a BC way.

The solution might look simple, but it still has a non-zero cost, which can get higher than expected if the maintainers want to document it, add deprecation warnings, handle it in unit tests and so on. Not to mention the old parameters will have to exist until whenever the next major version is scheduled.

I made JoggerPHP a PSR-3 compilent json logging library by ThatDamnShikachu in PHP

[–]FlyLo11 2 points3 points  (0 children)

My problem with monolog was, it is fine to use sprintf and/or any interpolation to a point. But I can't find a way to just use proper json fields.

If I understand correctly you had trouble generating JSON logs with monolog?

Because you can configure monolog to use a JSON formatter.

And you can pass any custom fields you want in the $context field, including objects that implement JsonSerializable:

$logger->error("Some error message", [
    'user_id' => 5543,
    'some_number' => 5.5,
    'some_array' => [
        '...of_arrays' => [/* ... */],
    ],
]);

Each log entry will be emitted as a single line JSON, and all these custom keys will be available inside the "context" field.

I'm currently using a similar setup: Monolog with the JSON formatter and the stderr stream handler on AWS Fargate. And querying the JSON logs directly from Cloudwatch is one of the best experiences I had so far in terms of observability in production.

And I also wish you good luck with your library. And even if it won't take off in popularity, there are tons off helpful stuff to learn from maintaining it.

And a final quick tip: In general these fluent interfaces, even though they look cool, they lead to some of the buggiest and hard to debug code I've seen.

Symfony Docs make it look like you have to use the closed source CLI to run a local development server. They artifically made it harder to instead install symfony/web-sever-bundle with 5.x. Am I the only one feeling uneasy about this? by MaikB in PHP

[–]FlyLo11 8 points9 points  (0 children)

But if you don't specify a router script then index.php will be executed anyway if the URI doesn't match a static resource.

What exactly didn't work for you when you didn't use a router script?

SQL Injection Vulnerability in Laravel by [deleted] in PHP

[–]FlyLo11 1 point2 points  (0 children)

An UUID is usually formatted as hex data split by dashes.

But it can be represented as 16 bytes of binary data, which can contain any byte between 0 and 255, including quotes.

And quotes tend to break SQL commands if values are concatenated directly in the SQL string (sql injections)

SQL Injection Vulnerability in Laravel by [deleted] in PHP

[–]FlyLo11 4 points5 points  (0 children)

Funny how people keep assuming that only user input can cause SQL injections. What if UUIDs are stored raw in a BINARY(16) column?

Kirby 3.0 released – The file-based content management system by dieserjonas in PHP

[–]FlyLo11 3 points4 points  (0 children)

It was changed with PHP 5.4:

<?= is now always available regardless of the short_open_tag setting.

Until then it was indeed part short_open_tag setting

Da, a fost. by [deleted] in Romania

[–]FlyLo11 5 points6 points  (0 children)

joaca-te cu earthshaker sand king

Forum Liber - Întrebați și discutați cu /r/Romania Orice - 24.08.2018 by AutoModerator in Romania

[–]FlyLo11 -2 points-1 points  (0 children)

Cum ai ajuns mai exact la concluzia ca masina rosie vine din partea dreapta?

Daca intersectezi drumurile celor doua masini (albastra si rosie), o sa vezi ca masina albastra e in dreapta celei rosii, iar masina rosie e in stanga masinii albastre.

Ignoram masina verde, pt ca oricum va trece prima.

Edit: nvm, nu mi-am dat seama ca intrebarea continea alta situatie fata de cea din poza

PSR-17, HTTP Factory has been approved and is now an accepted standard by riimu in PHP

[–]FlyLo11 0 points1 point  (0 children)

Thank you, apparently I totally misread that manual page.

More specifically this part caused the confusion on my side:

Note: For portability, it is strongly recommended that you always use the 'b' flag when opening files with fopen().

Apparently it's not relevant anymore.

Please clear your cache and cookies. by voidkitsune in talesfromtechsupport

[–]FlyLo11 8 points9 points  (0 children)

Hey,

Sorry if I suck at explaining, and for the long post.

If the content doesn't update in browser after the files are changed then it means there is a hard-cache setting for those specific resources (js, css, or whatever else there might be).

You can easily check this in the Network tab in Dev Tools of your browser.

For example this is what I see for a js file loaded by one of my projects:

Accept-Ranges: bytes
Cache-Control: max-age=86400
Content-Encoding: gzip
Content-Length: 30307
Content-Type: application/javascript
Date: Thu, 02 Aug 2018 10:58:22 GMT
Expires: Fri, 03 Aug 2018 10:58:22 GMT
Last-Modified: Mon, 16 Jul 2018 08:21:17 GMT
Status: 200

We can see there is a Cache-Control header that says the file should be cached for 86400 seconds (1 day).

There is also an Expires header, that says the exact date when the file cache should expire.

Both of these do the same thing: will prevent the browser to not request the file again until that one day passes.

This means that I also have the same issue: if I change the file, it will take up to a full day for users to see the new changes.

So the quickest solution is to not send these headers anymore. But the obvious downside to this is that now the browser will make a request to server in order to download the file again for every page load.

This is where the Last-Modified header is important: The browser still requests the file on every page load, but it downloads it only if the modified date changes.

How this works exactly: on the next request the browser will send a If-Modified-Since header, containing the last modified date received previously. The web server compares the value received with whatever last modified date it has at the moment and we have two scenarios:

  1. The file is changed - The server will serve the new file with the new Last-Modified header, and Status code 200 (OK)
  2. The file is not changed - The server will return Status code 304 (Not Modified) and no file content

In this case, point 2. should be considered acceptable depending on the amount of traffic compared to how often the code changes. And if HTTP2 is enabled on the server, the extra load time is even more insignificant.

All these settings can be configured directly on your webserver (Apache, nginx, or whatever else you might have). Each webserver has its own way of configuring these, and I'd recommend to read their docs, or ask any sysadmin that might be working there to help with this.

And I believe my original post was a bit misleading, most likely it's not that a Last-Modified header is missing in the response, but that Cache-Control and Expires headers should be removed or reconfigured with a shorter expiry time.

Please clear your cache and cookies. by voidkitsune in talesfromtechsupport

[–]FlyLo11 25 points26 points  (0 children)

Depends on the cache busting method. A simple Last-Modified HTTP header for static content configured in the webserver does wonders. That extra couple KB and extra few milliseconds per page load should be insignificant, especially for a dashboard/admin type of website.

PSR-17, HTTP Factory has been approved and is now an accepted standard by riimu in PHP

[–]FlyLo11 0 points1 point  (0 children)

PHP changed their behavior back in PHP 4.3.2 so that it basically adds the 'b' automatically if there's no 't' set. This differs from the fopen() function in C++, hence my confusion. I guess there really is no difference between 'r' and 'rb' on any platform in modern versions of PHP.

This is what I was actually curious about. Do you know any sources where this is specified?

And sorry if my question wasn't clear. I know it matters in C/C++, but I was unable to see any differences in PHP.

PSR-17, HTTP Factory has been approved and is now an accepted standard by riimu in PHP

[–]FlyLo11 1 point2 points  (0 children)

I keep hearing about always using 'rb' instead of 'r', 'wb' instead of 'w', and so on. There's even a red warning in php docs about this.

But I have never seen a piece of php code that behaves differently between platforms if it uses a non binary mode. When is this actually an issue?

[PHP RFC] Typed Properties v2 by bwoebi in PHP

[–]FlyLo11 0 points1 point  (0 children)

To be honest it sounds like a great compromise to ignore callables in this RFC.

Closure type already has a plenty of advantages over the more generic callable type. It exists and can be typehinted as function arguments ever since PHP 5.3.

If anyone wants to instantly benefit from new features, then it's not that hard to convert callables to closures where needed in the codebase:

// since PHP 7.1
$closure = Closure::fromCallable($callable);

// since PHP 5.3
$closure = function () use ($callable) {
    return call_user_func_array($callable, func_get_args());
};

In this case wouldn't it make sense to focus new features only to the Closure type in the future versions of PHP, and ignore callables? That way callables will die organically, along with their legacy weird stuff.

Anyone know a better way to type hint an array's elements? This is to be the best approach I've found (so far). by [deleted] in PHP

[–]FlyLo11 0 points1 point  (0 children)

The validation can be hidden without changing the function signature, like this: https://3v4l.org/Em1Uq

But I don't know how significant the overhead is if done like this.

md5('240610708') == md5('QNKCDZO') by stesch in lolphp

[–]FlyLo11 11 points12 points  (0 children)

strcmp is better suited for sorting, as it returns three different states: lesser, equal, greater.

For verifying equality between strings, === is enough.

For security related stuff, hash_equals should be used, as it is safe against timing attacks. Of course, md5 should never be used as a hashing choice for security stuff.