From e82a21c339ca485a3c83a9b09a3f2e3a24388126 Mon Sep 17 00:00:00 2001 From: Rolan Date: Wed, 22 Feb 2023 11:03:33 -0500 Subject: [PATCH 1/2] Small error in cron example. Extra 0. --- source/_posts/cron.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_posts/cron.md b/source/_posts/cron.md index a2f323c..049b9b3 100644 --- a/source/_posts/cron.md +++ b/source/_posts/cron.md @@ -65,8 +65,8 @@ Min Hour Day Mon Weekday | `15 2 * * 1L` | At 2:15am on the last monday of every month | | `15 0 * * 4#2` | At 00:15am on the second thursday of every month | -| `0 0 0 1 * *` | Every 1st of month (monthly) | -| `0 0 0 1 1 *` | Every 1st of january (yearly) | +| `0 0 1 * *` | Every 1st of month (monthly) | +| `0 0 1 1 *` | Every 1st of january (yearly) | | `@reboot` | Every reboot
_(non-standard)_ | From a5d0481a7ac929492c4e628d3aad519eeacde00b Mon Sep 17 00:00:00 2001 From: nityam01 Date: Sat, 25 Feb 2023 22:13:38 +0530 Subject: [PATCH 2/2] Add Fake http request with Promise snippet in Javascript --- source/_posts/javascript.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source/_posts/javascript.md b/source/_posts/javascript.md index 2bd6891..c29f749 100644 --- a/source/_posts/javascript.md +++ b/source/_posts/javascript.md @@ -1366,6 +1366,29 @@ promise.then(res => { }); ``` +### Fake http Request with Promise + +```javascript +const mock = (success, timeout = 1000) => { + return new Promise((resolve, reject) => { + setTimeout(() => { + if(success) { + resolve({status: 200, data:{}}); + } else { + reject({message: 'Error'}); + } + }, timeout); + }); +} +const someEvent = async () => { + try { + await mock(true, 1000); + } catch (e) { + console.log(e.message); + } +} +``` + JavaScript Async-Await {.cols-2}