Deploy Hugo pages via GitHub Actions

 · 1 min · 124 words · ringsaturn

Geographic aggregation using the map tile index

When dealing with large amounts of scattered data, sometimes we need to provide a read-only query API to visualize on a map. When the amount of data is too large, say millions, it is not appropriate to return it all to the front end for processing on the browser. Some aggregation should be completed within the back-end service to return the aggregated search to the front end. Here’s how to do this with the MongoDB + tile index in Go. ...

 · 2 min · 369 words · ringsaturn

Computing AQI in Go

I write a package named aqi. Install: 1 go install github.com/ringsaturn/aqi For China’s HJ633-2012 standar: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 package main import ( "fmt" "github.com/ringsaturn/aqi" "github.com/ringsaturn/aqi/mep" ) func main() { algo := &mep.Algo{} inputs := []*aqi.Var{ { P: aqi.Pollutant_PM2_5_1H, Value: 16, }, { P: aqi.Pollutant_PM10_1H, Value: 88, }, { P: aqi.Pollutant_CO_1H, Value: 0.2, }, { P: aqi.Pollutant_SO2_1H, Value: 3, }, { P: aqi.Pollutant_NO2_1H, Value: 11, }, { P: aqi.Pollutant_O3_1H, Value: 75, }, } aqi, primaryPollutant, err := algo.Calc(inputs...) if err != nil { panic(err) } levelDesc, err := algo.AQIToDesc(aqi) if err != nil { panic(err) } fmt.Printf("aqi=%v as level=%v with primary pollutant as %v\n", aqi, levelDesc, primaryPollutant) } Output: ...

 · 1 min · 306 words · ringsaturn

Add Mathjax to Hugo

Code copy&paste from Ataias Pereira Reis’s PR adityatelange/hugo-PaperMod#140 with some modifed on toggle option. Creat two files under layouts/partials/. Create math.html: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 <script> MathJax = { tex: { inlineMath: [["$", "$"], ["\\(", "\\)"]], displayMath: [["$$", "$$"]], processEscapes: true, processEnvironments: true, tags: "ams", }, options: { skipHtmlTags: [ "script", "noscript", "style", "textarea", "pre", ], }, startup: { ready: () => { MathJax.startup.defaultReady(); // Fix <code> tags after MathJax finishes running const all = MathJax.typesetPromise(); all.then(() => { document.querySelectorAll(".MathJax").forEach( (el) => { el.parentNode.className += " has-jax"; }, ); }); }, }, }; </script> <script id="MathJax-script" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js" ></script> Create extend_head.html: ...

 ·  · 1 min · 181 words · ringsaturn