I hereby claim:
- I am xetera on github.
- I am xetera (https://keybase.io/xetera) on keybase.
- I have a public key whose fingerprint is DE0C C5B3 7058 805B 8DD8 E306 7FB1 9FBF D8E5 BBED
To claim this, I am signing this object:
| const chunk = (array, num) => array.reduce((array, current) => { | |
| const last = array[array.length - 1]; | |
| const init = array.slice(0, -1); | |
| if (!last) { | |
| return [...init, [current]] | |
| } | |
| if (last.length >= num) { | |
| return [...array, [current]] | |
| } | |
| return [...init, [...last, current]]; |
| {- | |
| Using Optimal Stopping for finding the highest number in a list | |
| 1. Generate an integer list of N size | |
| 2. Reveal the numbers of the first N/e elements | |
| 3. Keep revealing numbers until you find one bigger than the biggest revealed number | |
| 4. The chances of the first matching number being the highest number in the list will consistently be 1/e | |
| -} | |
| -- Games played: 1000 | |
| -- Games Won: 358 |
| makePattern :: [(a -> a)] -> a -> [a] | |
| makePattern funcs seed = scanl (\a f -> f a) seed (cycle funcs) | |
| -- makePattern [(*3), (+1)] 1 | |
| -- [1,3,4,12,13,39] |
I hereby claim:
To claim this, I am signing this object:
| data Stack a | |
| = Nil | |
| | Stack a (Stack a) | |
| instance Functor Stack where | |
| fmap f s = | |
| case s of | |
| Stack e next -> | |
| Stack (f e) $ fmap f next | |
| Nil -> Nil |
| const routeMethods = (router, url) => { | |
| const unwrap = () => router | |
| const makeRoute = method => handler => { | |
| router[method](url, handler); | |
| return routeMethods(router, url) | |
| } | |
| const methods = ['get', 'post', 'put', 'options', 'delete', 'patch', /* as many methods as you need here */] | |
| return methods.reduce((all, method) => ({ | |
| ...all, | |
| [method]: makeRoute(method) |
https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6
The website currently makes 3 separate API calls to retreive Death, Confirmed and Recovered cases, however ArcGIS supports multiple queries in one request so the API call has been optimized to retreive all 3 at once.
| :root { | |
| --rose-50: #fff1f2; | |
| --rose-100: #ffe4e6; | |
| --rose-200: #fecdd3; | |
| --rose-300: #fda4af; | |
| --rose-400: #fb7185; | |
| --rose-500: #f43f5e; | |
| --rose-600: #e11d48; | |
| --rose-700: #be123c; | |
| --rose-800: #9f1239; |
| #!/usr/bin/env bash | |
| # This backup file is run daily as a cronjob like: | |
| # 0 0 * * * bash ~/backup.sh >> /var/log/restic_backups.log 2>&1 | |
| restic_repository="your-s3-repository-url-here" | |
| # There is probably a way to do this conveniently through stdin but I don't know if | |
| # that's more efficient through a file because mongodb does some questionable stuff | |
| # with piping mongodump to stdout vs saving backups to a file | |
| backup_path="/path/to/emit/backup/file" |
| // Aggregates are a powerful mongodb tool that allows us to craft complex queries. | |
| // In this case it helps prevent repetition in a situation where we would have to | |
| // query a document with a filter, then use a duplicate `Array.find` logic to | |
| // extract the subdocument we were already expecting to find in the first place. | |
| // Example person document | |
| { | |
| name: "jason", | |
| pets: [{ | |
| type: "dog", |