diff --git a/content/authors/DianaWebdev.md b/content/authors/DianaWebdev.md new file mode 100644 index 0000000..53246ea --- /dev/null +++ b/content/authors/DianaWebdev.md @@ -0,0 +1,5 @@ +--- +username: DianaWebdev +name: Di +avatar: 'https://pbs.twimg.com/profile_images/1437883999955869707/9Pz4IAhZ_normal.jpg' +--- diff --git a/content/threads/weekly-thread-2021-01.md b/content/threads/weekly-thread-2021-01.md new file mode 100644 index 0000000..650db90 --- /dev/null +++ b/content/threads/weekly-thread-2021-01.md @@ -0,0 +1,11 @@ +--- +slug: weekly-thread-2021-01 +title: 'Weekly thread #01 of 2021' +tweet_id: '1471864631312404492' +author_username: archtechx +created_at: 2022-01-07T12:56:47+00:00 +links: { } +--- +🔥 This week's code tips for Laravel developers + +A weekly thread 🧵 \ No newline at end of file diff --git a/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md b/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md new file mode 100644 index 0000000..5f6ac5c --- /dev/null +++ b/content/tips/adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance.md @@ -0,0 +1,13 @@ +--- +title: 'Adding WHERE scopes which use an indexed column to a query that''s primarily filtered by another column is a great way to speed up DB performance' +tweet_id: '1471864653491974151' +thread_slug: weekly-thread-2021-01 +author_username: tobias_petry +images: + - 'https://pbs.twimg.com/media/FGafd_JXMAEDgP5.jpg' +created_at: 2021-12-17T15:27:33+00:00 +slug: adding-where-scopes-which-use-an-indexed-column-to-a-query-thats-primarily-filtered-by-another-column-is-a-great-way-to-speed-up-db-performance +--- +⚡️ Database Tip + +Sometimes you have seldom used queries and you can't add an index on columns for these queries. A nice trick is to use another indexed condition so the rows are filtered by the indexable column first and afterwards again for the more limiting condition. \ No newline at end of file diff --git a/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md b/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md new file mode 100644 index 0000000..70c3f7d --- /dev/null +++ b/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md @@ -0,0 +1,13 @@ +--- +title: 'Use match () or switch () statements to conditionally scope database queries based on query strings in the request' +tweet_id: '1471864655710670854' +thread_slug: weekly-thread-2021-01 +author_username: archtechx +images: + - 'https://pbs.twimg.com/media/FGmQH5nXEAs4mnv.jpg' +created_at: 2021-12-17T15:27:34+00:00 +slug: use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request +--- +Remembered this great tip recently, and it's nice to see how fast PHP evolves + +The exact same behavior can be implemented using match () with a default value, which also removes the need for the second callback ⚡️ https://twitter.com/reinink/status/1233017064492761088 \ No newline at end of file diff --git a/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md b/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md new file mode 100644 index 0000000..ddb53b1 --- /dev/null +++ b/content/tips/use-retry-for-callbacks-that-may-randomly-fail.md @@ -0,0 +1,15 @@ +--- +title: 'Use retry() for callbacks that may randomly fail' +tweet_id: '1471864638199451648' +thread_slug: weekly-thread-2021-01 +author_username: alexjgarrett +images: + - 'https://pbs.twimg.com/media/FGP3MSQWQAYKjSm.jpg' +created_at: 2021-12-17T15:27:30+00:00 +slug: use-retry-for-callbacks-that-may-randomly-fail +--- +.@laravelphp out here helping me again, with its helpers! + +I was hitting a shaky API that sometimes failed. + +Here, the retry function tries the callback 3 times, with a 2 second interval in-between retries. \ No newline at end of file diff --git a/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md b/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md new file mode 100644 index 0000000..5708cab --- /dev/null +++ b/content/tips/you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser.md @@ -0,0 +1,18 @@ +--- +title: 'You can add a --refresh flag to the artisan down command to send a refresh header to the browser' +tweet_id: '1471864676652826626' +thread_slug: weekly-thread-2021-01 +author_username: DianaWebdev +images: { } +created_at: 2021-12-17T15:27:39+00:00 +slug: you-can-add-a-refresh-flag-to-the-artisan-down-command-to-send-a-refresh-header-to-the-browser +--- +#WeirdDevReadsDocs + +Did you know? + +You can add a --refresh flag to the artisan down command to send a refresh header to the browser. I think that's helpful for well visited apps where you trying to keep perceived downtime as low as possible! + +https://laravel.com/docs/8.x/configuration#maintenance-mode + +@laravelphp \ No newline at end of file diff --git a/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md b/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md new file mode 100644 index 0000000..0bf31f8 --- /dev/null +++ b/content/tips/you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements.md @@ -0,0 +1,15 @@ +--- +title: 'You can refactor cluttered if () conditions using lookup tables, match statements, and switch statements' +tweet_id: '1471864664661311488' +thread_slug: weekly-thread-2021-01 +author_username: archtechx +images: + - 'https://pbs.twimg.com/media/FGVrAKdVgAIWfwk.jpg' +created_at: 2021-12-17T15:27:36+00:00 +slug: you-can-refactor-cluttered-if-conditions-using-lookup-tables-match-statements-and-switch-statements +--- +🔥 Three ways you can refactor cluttered if () conditions + +First: lookup tables 👇 + +These are great for refactoring complex conditions with lots of else if () cases \ No newline at end of file diff --git a/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md b/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md new file mode 100644 index 0000000..adbe5df --- /dev/null +++ b/content/tips/you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function.md @@ -0,0 +1,17 @@ +--- +title: 'You can use the array spread syntax to pass an array of arguments to another function' +tweet_id: '1471864644562305025' +thread_slug: weekly-thread-2021-01 +author_username: freekmurze +images: + - 'https://pbs.twimg.com/media/FGepj8mWQAUf2R_.jpg' +created_at: 2021-12-17T15:27:31+00:00 +slug: you-can-use-the-array-spread-syntax-to-pass-an-array-of-arguments-to-another-function +--- +🔥 You can use array spreading to pass an array as arguments to another function. #php + +Here’s a self-contained example where we spread the array output of sys_getloadavg. That function returns an array with three elements. + +https://github.com/spatie/cpu-load-health-check/blob/70f387d5167c24d4000d825a5bddab2504d557fb/src/CpuLoad.php#L17 + +#php \ No newline at end of file