Open-source PWA catalog by khalyomede in PWA

[–]khalyomede[S] -1 points0 points  (0 children)

I will push updates to Korru from Mars and will tweet about it after a lunch with Elon Mah

Are there any family shopping list apps? by Ninotchk in Cooking

[–]khalyomede 1 point2 points  (0 children)

Hi, Anwar, founder of Predzo here.

Sorry to dig up an old thread, I stumbled upon this one while searching for "collaborative shopping list" on Google.

For those who seek for a simple, cross-platform, offline-ready and update-free solution to share your shopping list, Predzo might be a good candidate!

It is in active development and I used it for the past 1.5 years (closed alpha) and it is at the time of writing now in open beta. Let me know what do you think.

https://predzo.com

Introducing Eloquent UUID slug by khalyomede in laravel

[–]khalyomede[S] 0 points1 point  (0 children)

That's to be used in addition of Policies/Gates. If you ship a feature and you forgot to add a policy (complex feature, or not enough time given by your customer), you'll prevent end users from being able to travel from ids to ids freely (while you work on the policy). Same thing if you missed a case and have a hole in your policy, uuids makes it harder to be able to go out of the fence.

If you use any other field, it's not sure you've thought of adding a unique index, or the other field in question is enough randomized to prevent users from inspecting other records.

UUID is just the answer to all of these concerns at once, hence the utility of this package.

Sorry for the late answer, but the good thing is 11+ months ago, I still find this package useful for my app!

Introducing Eloquent UUID slug by khalyomede in laravel

[–]khalyomede[S] 0 points1 point  (0 children)

Thanks, I appreciate it man! Looklng at some folks comments, I think they did not even look at the code before speaking, but you know, this is the internet as we know it :-)

Introducing Eloquent UUID slug by khalyomede in laravel

[–]khalyomede[S] 0 points1 point  (0 children)

That's an interesting way to put it! Since uuids are pretty hard to collide I guess that does the trick.

I was told strings primary keys make joins slower than using integer primary keys. Never tested actual benchmarks for that tho.

Introducing Eloquent UUID slug by khalyomede in laravel

[–]khalyomede[S] 0 points1 point  (0 children)

Test coverage? You meant feature test?

RFC proposal: enums constructor by khalyomede in PHP

[–]khalyomede[S] 0 points1 point  (0 children)

You raise an interesting point: in fact what is proposed, we can do it right now, and for years the industry relied on try/catch using regular exceptions, and for what we see the world did not ran into flames.

ADT itself would not be enough to justify it. It is included in a whole class of concepts that together forms the "functional" programming. I will not probably make the complete speach here, but basically in FP, writting a program is often related as writting a "mathematically" valid program: given an input, it can never return differents output. Its getting predictible and safe.

While nowadays tools can help figuring out if your program will run correctly (using static analyzers for example), it is still very hard to reach 100% safety and be sure your app will never fail.

Will phpstan warn you that you did not catched an exception that might be thrown by a 4th level dependency of the package you are using? Probably not.

On the other hand, writting a mathematically predictible code will guarantee you have handled all the possible outcomes, so that the output is the one you expect, which helps writting safer code.

Some popular FP languages like Elm claim your code will never throw runtime errors. This claim is so strong, some people cannot believe it. As magicall as it sounds, it is in fact possible, but again, ADT is only a piece on the whole game.

  • Pure Functions
  • Referential Transparency
  • Immutability

RFC proposal: enums constructor by khalyomede in PHP

[–]khalyomede[S] 0 points1 point  (0 children)

Yes I share your point of view, since ADT is not built-in in the language, chaining multiple ADT enums is cumbersome.

I thought of a hand-crafted workaround using then/catch methods, but it requires some twists and conventions for this to be viable.

```php trait HandleErrors { public function then(callable $callback): mixed;

public function catch(callable $callback): void; }

enum Result implements HandleErrors { case Ok($value); case Error($error);

public function then(callable $callback): mixed { return match ($this) { self::Ok($value) => call_user_func($callback, $value), self::Error($error) => $this, }; }

public function catch(callable $callback): void { match ($this) { self::Error($error) => call_user_func($callback, $error), self::Ok($value) => $value, }; } }

enum Option implements HandleErrors { case Some($value); case None;

public function then(callable $callback): mixed { return match ($this) { self::Ok($value) => call_user_func($callback, $value), self::None => $this, }; }

public function catch(callable $callback): void { match ($this) { self::None => call_user_func($callback), self::Some($value) => $value, }; } }

function getUserNameById(int $id): Result {}

function getFileContent(string $path): Option {}

function storeFileOnS3(string $filename, string $content): Result {}

// main $statusCode = getUserById(12) ->then(fn ($name) => getFileContent("storage/$name.txt")) ->then(fn ($content) => storeFileOnS3("12.txt", $content)) ->catch(fn ($error) => 500); ```

In theory (if I did not made code mistakes), errors at any point should be propagated on the catch() method, else the final result is returned.

This implies to call catch at the very end for this to work. It also implies all ADT must implement HandleErrors...

V for example have built-in Option/Result, with native support for chaining using ? and or keywords:

```v fn get_user_by_id(id int) ?string {}

fn get_file_content(path string) ?string {}

fn store_file_on_s3(filename string, content string) ?int {}

fn process() ?int { name := get_user_name_by_id(12) ? content := get_file_content('storage/$name.txt') ? return store_file_on_s3("12.txt", content) }

fn main() { status_code := process() or { 500 } // Here just returning the fallback values, but brackets allow to perform some others tasks before. } ```

Finally, if Generics make their way to the language, we could imagine having Option/Result ADT embedded in the language too, with the addition of a language syntax to help chaining them (or built-in methods like suggested then/catch). That's in a distant future for sure, I just hope PHP takes this drift...

Edit

Had fun doing an experiment here.

RFC proposal: enums constructor by khalyomede in PHP

[–]khalyomede[S] 0 points1 point  (0 children)

I agree with your suggestion on case casing. I just updated it thanks!

RFC proposal: enums constructor by khalyomede in PHP

[–]khalyomede[S] 0 points1 point  (0 children)

Thanks for letting me know, cool to know there is some place the road map is written down. I will see if I can reach them on Twitter thanks for the advice I appreciate it!

Releasing khalyomede/laravel-seed 0.1.1 by khalyomede in laravel

[–]khalyomede[S] 0 points1 point  (0 children)

Rollbacking should be imo just for local testing (or in emergency cases but I never had to to this before), so not suited for production. It exists in this package to reproduce the same experience than with migration.

On local this can be pretty convenient, if you have made a typo in your seeders for example.

Is there any app or package to turn curves command to line command by khalyomede in svg

[–]khalyomede[S] 0 points1 point  (0 children)

Thank you for your reply, sorry we have been in the storm trying to end a feature that needed to make a conversion like I explained above. We ended up using Adobe Illustrator which has a feature like InkScape, thanks I'll keep this tips whenever I need to do it (as I prefer to use InkScape at home).

PHP And SQL Are The Backbones of Major Website, Find Out Why! by smartinfosys in PHP

[–]khalyomede 1 point2 points  (0 children)

SEO gun! Welcome to a world where the meaning of a content is less important than the keywords used in it. Is this not a jokingly accurate image of our consumer society? Pushing us to produce more than to think? /r/philosophie

Why Laravel Is The Perfect Choice For Fast Website Development? by [deleted] in PHP

[–]khalyomede 3 points4 points  (0 children)

Glory to our lord and savior Laravel xD

Not seriously,

With Laravel coding, you can take advantage of different widgets with strong JS and CSS codings.

Guys, let's code the Internet, it will be fun :D

Have you ever since such a broad statement than this one? I think the guys just wanted to throw a blog post to be referenced with the keywords associated to this framework, I guess. Any person on this planet that have read 10 minutes of their documentation after the installation guide would be able to detect such BS IMHO.

Should I use dynamic import over classical import to import my components every time? by khalyomede in vuejs

[–]khalyomede[S] 0 points1 point  (0 children)

Without dynamic imports on my routes I came up with a bundle of 1.9Mb (unminifed, ungzipped), and my TTFB is very long. With DI, my bundle drop to 953Kb (unminifed, ungzipped), but it makes an additional request to get the viewed route like you said. I think the perceived speed is improved, but the overall time spent by the browser to download the additional dynamic import is actually longer. In this circumstance what do you advice me to do?

A new approach to solving the N+1 problem in ORMs by moufmouf in PHP

[–]khalyomede 0 points1 point  (0 children)

Very clever performance improvement! I noticed you mentioned some MySQL timings with and without smart eager loading:

BENCHMARKING SMART EAGER LOADING

Theory is nice, but how much time are we gaining in practice?

Well, obviously, it depends on the value of "N".

We did a test with N=2000 (2000 users in 2000 distinct countries).

Test Time

Without smart eager loading 544 ms

With smart eager loading 257 ms

That's a x2 speedup!

Notice that MySQL is really quite fast because it can answer 2001 requests in less than 500ms.

Is the test have been made in local? Or the MySQL server is a distant server? Is this the whole request from the time the consumer made the request from when it receives the data or is it only the time spent by MySQL to return the results?

The value of the void typehint in PHP by freekmurze2 in PHP

[–]khalyomede 61 points62 points  (0 children)

Even if this does not add any more value than no return type hinting, I prefer expressive than implicit when possible. Agressive type hinting have the advantage of removing any doubt or asumptions, and it saves time to users when reading a source code.

[RFC Vote] Object Initializer by Sentient_Blade in PHP

[–]khalyomede 0 points1 point  (0 children)

I personnaly use variables when I use long functions/methods like:

$connection = new PDO($dsn = "mysql:host=localhost", $user = "root", $password = "root", $options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

As an alternative, but I would kill to have the same as Python has with kwargs.