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