This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main.go b/main.go | |
index 606c863..08d7580 100644 | |
--- a/main.go | |
+++ b/main.go | |
@@ -1,37 +1,58 @@ | |
package main | |
import ( | |
+ "context" | |
"log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main.go b/main.go | |
index 638af00..af15140 100644 | |
--- a/main.go | |
+++ b/main.go | |
@@ -2,6 +2,7 @@ package main | |
import ( | |
"log" | |
+ "time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main.go b/main.go | |
index 5c20c9f..638af00 100644 | |
--- a/main.go | |
+++ b/main.go | |
@@ -8,7 +8,7 @@ func producer(strings []string) (<-chan string, error) { | |
outChannel := make(chan string) | |
go func() { | |
- | |
+ defer close(outChannel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
) | |
func producer(strings []string) (<-chan string, error) { | |
outChannel := make(chan string) | |
for _, s := range strings { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main.go b/main.go | |
index 92bcd33..5c20c9f 100644 | |
--- a/main.go | |
+++ b/main.go | |
@@ -7,9 +7,12 @@ import ( | |
func producer(strings []string) (<-chan string, error) { | |
outChannel := make(chan string) | |
- for _, s := range strings { | |
- outChannel <- s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env nix-shell | |
#! nix-shell -p ghcid -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [])" -i "ghcid -c 'ghci -Wall' -T main" | |
-- Run this with | |
-- $ chmod +x ./file.hs | |
-- $ ./file.hs | |
-- | |
-- See this thread https://discourse.haskell.org/t/how-to-restrict-function-to-certain-constructors/2785/7 | |
-- for a discussion of the problem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getSessionFromDb :: SQLite.Connection -> ByteString -> IO (Maybe Session) | |
getSessionFromDb conn id = | |
SQLite.query conn "SELECT expires,userid FROM sessions WHERE id = ?" [id] | |
>>= \dbResult -> case dbResult of | |
[s :: Session] -> return $ Just s | |
[] -> return Nothing | |
other -> throwString $ "unexpected DB result: " <> show other | |
getRolesFromDb :: SQLite.Connection -> Int -> IO (Maybe [Role]) | |
getRolesFromDb conn userId = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '[{"name":"v1.22.10","zipball_url":"https://api.github.com/repos/yarnpkg/yarn/zipball/v1.22.10","tarball_url":"https://api.github.com/repos/yarnpkg/yarn/tarball/v1.22.10","commit":{"sha":"785cda8020aa5f513d6f60b8349bca8dab9dd79b","url":"https://api.github.com/repos/yarnpkg/yarn/commits/785cda8020aa5f513d6f60b8349bca8dab9dd79b"},"node_id":"MDM6UmVmNDk5NzA2NDI6cmVmcy90YWdzL3YxLjIyLjEw"}]' | tr ',' '\n' | awk -F'":"' '{ version; gsub(/"/, "", $2); if ($1 ~ /name/ ) { version = $2; } if ($1 ~ /tarball/) { gsub(/v/, "", version); print version, $2; } }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '[{"name":"v1.22.10","zipball_url":"https://api.github.com/repos/yarnpkg/yarn/zipball/v1.22.10","tarball_url":"https://api.github.com/repos/yarnpkg/yarn/tarball/v1.22.10","commit":{"sha":"785cda8020aa5f513d6f60b8349bca8dab9dd79b","url":"https://api.github.com/repos/yarnpkg/yarn/commits/785cda8020aa5f513d6f60b8349bca8dab9dd79b"},"node_id":"MDM6UmVmNDk5NzA2NDI6cmVmcy90YWdzL3YxLjIyLjEw"}]' | tr ',' '\n' | awk -F'":"' '{ version; | |
gsub(/"/, "", $2) | |
if ($1 ~ /name/ ) { version = $2 } | |
if ($1 ~ /tarball/) { gsub(/v/, "", version); print version, $2 } }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vanillaFn = (notes) => { | |
const grouped = {}; | |
notes.forEach((note) => { | |
const { | |
author: { id: currentId }, | |
content, | |
section, | |
} = note; | |
if (!grouped[section]) grouped[section] = { len: 0, data: {} }; |