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/internal/markdown/markdown.go b/internal/markdown/markdown.go | |
index a729b9f..94d29c1 100644 | |
--- a/internal/markdown/markdown.go | |
+++ b/internal/markdown/markdown.go | |
@@ -13,8 +13,11 @@ import ( | |
"bytes" | |
"github.com/yuin/goldmark" | |
+ "github.com/yuin/goldmark/ast" | |
"github.com/yuin/goldmark/parser" |
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
200 constant max-line | |
create line max-line allot \ Buffer for read-line | |
wordlist constant counts \ Hash table of words to count | |
variable num-uniques 0 num-uniques ! | |
\ Allocate space for new string and copy bytes, return new string. | |
: copy-string ( addr u -- addr' u ) | |
dup >r dup allocate throw | |
dup >r swap move r> r> ; |
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
"""Quick performance tests comparing "match" with "if...elif". | |
See: | |
https://benhoyt.com/writings/python-pattern-matching/ | |
https://news.ycombinator.com/item?id=28601616 | |
# Enum switch with match: | |
$ python3.10 -m timeit -s 'import mt' -c 'mt.enum_match(mt.FileType.FILE)' | |
1000000 loops, best of 5: 356 nsec per loop | |
$ python3.10 -m timeit -s 'import mt' -c 'mt.enum_match(mt.FileType.SYMLINK)' |
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 client | |
func IntPtr(n int) *int { return &n } | |
type FooArgsPtr struct { | |
UserID *int | |
User string | |
GroupID *int | |
Group string | |
} |
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
static void* prog[] = { | |
- // loop: | |
&&i_pushvar0, // pushvar i | |
&&i_pushnum, (void*)100000000, // pushnum 100000000 | |
&&i_jge, (void*)5, // jge end | |
+ // loop: | |
&&i_pushvar0, // push i | |
&&i_addvar1, // addvar s | |
&&i_incvar0, // incvar i | |
- &&i_jmp, (void*)((long long)-10), // jmp loop |
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
# NOTES | |
"before" is Go version go1.19-dd97871282, before the switch jump tables commits | |
"after" is Go version go1.19-78bea702cd, after the switch jump tables commits | |
# GOAWK'S GO MICROBENCHMARKS | |
$ benchstat -sort=delta -geomean benchmarks_before.txt benchmarks_after.txt | |
name old time/op new time/op delta | |
IncrDecr-8 141ns ± 1% 160ns ± 2% +13.59% (p=0.008 n=5+5) | |
IfStatement-8 147ns ± 1% 157ns ± 2% +6.59% (p=0.008 n=5+5) |
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 ( | |
"fmt" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
if len(os.Args) != 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
BEGIN { | |
FS = "," | |
} | |
{ | |
nf = csvify(fields) | |
for (i=1; i<=nf; i++) { | |
printf "|%s|\n", fields[i] | |
} |
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 ( | |
"fmt" | |
"net/http" | |
"strconv" | |
) | |
func main() { | |
http.HandleFunc("/multiply", func(w http.ResponseWriter, r *http.Request) { |
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
import collections, random, sys, textwrap | |
# Build possibles table indexed by pair of prefix words (w1, w2) | |
w1 = w2 = '' | |
possibles = collections.defaultdict(list) | |
for line in sys.stdin: | |
for word in line.split(): | |
possibles[w1, w2].append(word) | |
w1, w2 = w2, word |