- Run
find ./content -iname '*-*-*.md' | tee filenames.txt - Remove newsletters and other folders you don't care about
- Run counts.py over it
- Make stacked bar chart in DataWrapper
| package main | |
| import ( | |
| "bufio" | |
| "cmp" | |
| "encoding/csv" | |
| "flag" | |
| "fmt" | |
| "maps" | |
| "os" |
| name: Go | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 |
| func Push[V any](consumer func(seq iter.Seq[V])) (yield func(V) bool, stop func()) { | |
| var in V | |
| coro := func(coroYield func(struct{}) bool) { | |
| seq := func(seqYield func(V) bool) { | |
| for seqYield(in) { | |
| if !coroYield(struct{}{}) { | |
| break | |
| } | |
| } |
| package csvutil_test | |
| import ( | |
| "bytes" | |
| "encoding/csv" | |
| "testing" | |
| ebcsv "github.com/earthboundkid/csv/v2" | |
| "github.com/gocarina/gocsv" | |
| "github.com/jszwec/csvutil" |
I changed my GitHub username from @carlmjohnson to @earthboundkid (actually, this was a revert because my username was originally @earthboundkid). Because Go uses URLs for package management, this means that existing packages will continue to use github.com/carlmjohnson/requests (for example) and be automatically redirected to github.com/earthbound/requests. There was a discussion about adding package forwarding to Go, but as of now, this has not been implemented. If package forwarding is added to a future version of Go, the URLs of my repositories may change at that time. I may also choose to change URLs if there is a breaking change to the API of a package. The current plan is to migrate package URLs along with a change to /v2 in order to prevent broken go mod upgrades. Thank you for bearing with this transition.
| 祇園精舎の鐘の聲、 | Gion shōja no kane no koe |
| 諸行無常の響あり。 | shogyō mujō no hibiki ari. |
| 娑羅雙樹の花の色、 | Shara sōju no hana no iro |
| 盛者必衰のことわりをあらはす。 | jōsha hissui no kotowari o arawasu. |
| おごれる人も久しからず、 | Ogoreru hito mo hisashikarazu, |
| 唯春の夜の夢のごとし。 | Tada haru no yo no yume no gotoshi. |
| たけき者も遂にほろびぬ、 | Takeki mono mo tsui ni horobinu. |
| 偏に風の前の塵に同じ。 | Hitoe ni kaze no mae no chiri ni onaji. |
The second problem in Project Euler is
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
Nine years ago, I wrote a blog post that showed how to solve this in Python using iterators and in Go using channels. The Go code started simple, but ended up a bit complicated because it also had stop channels to allow early exit. See euler.py for the Python code, and channel.go for the Go code using channels.
Go issue #61405 proposes to add a new function-based iterator protocol to Go. To test it, I rewrote the Go code using push function iterators. See functional.go. The code is notably simpler and shorter than the channel based code.
| export default function createElement( | |
| tag = "div", | |
| { classList = [], attrs = {}, children = [], ...props } = {} | |
| ) { | |
| let el = document.createElement(tag); | |
| for (let c of classList) { | |
| el.classList.add(c); | |
| } | |
| for (let attr in attrs) { | |
| el.setAttribute(attr, attrs[attr]); |
| function secureRand(min, max) { | |
| let range = max - min; | |
| if (range < 2) { | |
| return min; | |
| } | |
| let bits_needed = Math.ceil(Math.log2(range)); | |
| if (bits_needed > 31) { | |
| throw new Error("cannot generate numbers larger than 31 bits."); | |
| } |