duangsuse::Echo
583 subscribers
4.12K photos
118 videos
579 files
6.13K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
htmlPrint.zip
96.5 KB
顺手分享 #doc #share #cs 包含很多 PLT(依赖类型 Agda) 的内容和一个 PL 和编译原理的内容(R大 09 年的一个博客)
duangsuse::Echo
#Cplusplus #CV 🤔 讲真,我真的不喜欢 OpenCV 的动态属性,它把本来可以轻易自动补齐的东西变成了还要查会文档、本来可以更强类型的东西做成了一堆 int 不仅使用动态属性,还不对常见 prop (比如 fps, position) 做些辅助属性…… In [1]: from cv2 import CAP_PROP_POS_MSEC CAP_PROP_POS_AVI_RATIO CAP_PROP_POS_FRAMES CAP_PROP_POS_MSEC OpenCV…
之前记下的 API 都是什么情况…… 要完成这些,我必须得到按 行/字 迭代每帧像素的方法
https://docs.opencv.org/4.5.0/d8/dfe/classcv_1_1VideoCapture.html 找到官方文档了(话说一般 CV 都是 #Python 写应用……
https://docs.opencv.org/4.5.0/d3/d63/classcv_1_1Mat.html 还有这个,单帧图像接口

看了半天找到 opencv2/videoio.hpp, highgui/highgui.hpp 和 imread/imwrite, empty, cvNamedWindow,waitKey, CV_WINDOW_AUTOSIZE, imshow, VideoCapture, read, operator>>, Mat ,channels, at, Scalar,uchar,Vec3b,val[] 这样的符号 #cplusplus #api #doc 🤔
Mat img(/*.rows*/1920, /*.cols*/1080, CV_8UC3);
typedef cv::Point3_<uint8_t> Pixel;
for (int i=0; i<img.rows; i++) { // raw access
Pixel *p = image.ptr<Pixel>(i, 0), *p1 = p + image.cols;
for (; p!=p1; p++) { *p.x = 255; }
}
for (Pixel &p : cv::Mat_<Pixel>(img)) { p.x = 255; } // mat iter
img.forEach<Pixel>([](Pixel &pixel, const int* position) { p.x = 255; }); // parallel forEach
//C++11 lambda, old:
struct Operator { operator()/*^above*/ }
好了,找到了 Video 的 nextImage 和 Image 的 n[row/col], pixelAt 操作我就可以写了……

相关链接:
[Linux Terminal has the capability of displaying 8-bit colour, so why not play something on it?](https://gist.github.com/Trumeet/fd4e93d69d78dc4ac14d5cac42dfff7e)
[OpenCV - Colored Images to GrayScale - Tutorialspoint](https://www.tutorialspoint.com/opencv/opencv_colored_images_to_grayscale.htm)
[OpenCV: cv::VideoCapture Class Reference](https://docs.opencv.org/4.5.0/d8/dfe/classcv_1_1VideoCapture.html)
[Tutorial 6 - Assessing the pixel values of an image OpenCv C++ | ProgTpoint](https://progtpoint.blogspot.com/2017/02/tutorial-6-assessing-pixel-values-of.html)
[duangsuse-valid-projects/Essay-DIP-BMP-SIMD-Operation: C11 BMP Image Reading / Writing, SIMD using GCC xmminstric.h operations like AND / XOR / Dense](https://github.com/duangsuse-valid-projects/Essay-DIP-BMP-SIMD-Operation#my-machine)
[duangsuse-valid-projects/Essay-CSharp-DIP.Performance.Parallel: 🐔 versus 👨🏻‍🎓: WHO is faster? Is CSharp &quot;slow&quot;?](https://github.com/duangsuse-valid-projects/Essay-CSharp-DIP.Performance.Parallel/)
#Web #doc #Mozilla 大胜利🦊🌝
#lib #doc #js ACE code editor
https://ace.c9.io/index.html#nav=howto
https://mivik.gitee.io/compress
https://file.xecades.xyz/Linux/GetKeyDown.html

https://stackoverflow.com/questions/8832320/how-can-i-highlight-code-with-ace-editor
https://medium.com/@jackub/writing-custom-ace-editor-mode-5a7aa83dbe50
https://github.com/ajaxorg/ace#features
https://stackoverflow.com/questions/18614169/set-value-for-ace-editor-without-selecting-the-whole-editor 'editor.setValue() does selectAll, forgot to unselect it'

啊... 感觉 ACE 真的好草啊
设计上大概就是 replace, getValue 这些常用"UI"功能放 root object
replace(range,text), setValue 放 .session
getSelectedText(), insert(s) 放 .selection

但是它的 cursor 真的好难弄啊,为什么是 {line, column} 的形式呢(Range 也是这种,四元形式...),而且都只有 cursor/selection Left/Right/Up/Down 的无参函数,估计只是给 UI 绑定的
那你定义个鸡毛啊! 就这?! 要知道不管什么文本存储后端, LRUD 四向的代码几乎都差不多,你暴露接口,而且不支持 length 只能为 1? 也没有元编程便利性 API 辅助?
而且 ace.edit(selector, options) 居然没有用,非得 editor.setOptions 才行
无了无了

https://stackoverflow.com/questions/23278238/ace-code-editor-set-language-dynamically
https://stackoverflow.com/questions/20869962/what-are-the-requirements-for-mode-html-in-ace-editor
https://www.xspdf.com/resolution/54957281.html
session() 也挺有意思的,但凡桌面应用都要有撤销重做的能力,这个是 .setMode("ace/mode/sql") 都能重做一样
#linux #Learn #Java #math #build #bash fix for Desoms (Kt, Java:Algebra)
1. Java Desmos 求解后端
git clone https://github.com/galbar07/Desmos.git DesmosJ &&cd DesmosJ
sed 's/import org.junit.jupiter.api.BeforeEach;//;s/@BeforeEach//;' -i tests/Functions_GUITest.java
javac -cp `ls JAR/gson-*.jar`:`ls ~/.m2/repository/junit/junit/4.0/junit-*.jar` ex1/*.java tests/Functions_GUITest.java
java -cp . ex1.StdDraw
#java -cp ".:`ls JAR -m|sed 's/, /:/g'`" tests.Functions_GUITest
java -cp `find JAR -type f -printf '%p:'`. tests.Functions_GUITest
因为 mvng 没有写完不能用脚本生成 POM 修复了 emm ,当然有 IDE 就能直接用(不过这年头 只会用 IDE 建项目 对细节一无所知的人真的有创造力吗 😑

2. Kotlin Desmos 简单重写
手动复制粘贴 https://paste.ubuntu.com/p/Q4DnzrZ37Z/ 或(源地址)到 Window.kt ,因为 国内 #China 许多地方不仅 #GitHub raw 连 pastebin 都连不上 🌚🌝 #freedom
mvn archetype:help
#mkdir DesmosKt &&cd DesmosKt
#mvn archetype:generate -DgroupId=com.example - DartifactId=desmos -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

mvn archetype:generate -DgroupId=me.nanjingchj -DartifactId=DesmosKt -DarchetypeArtifactId=kotlin-archetype-jvm -DarchetypeGroupId=org.jetbrains.kotlin -DarchetypeVersion=1.4.21 -DinteractiveMode=false
cd DesmosKt
mkdir -p src/main/kotlin/me/nanjingchj/desmos/
cat>`find -type d -name desmos`/Window.kt
mvnDeps=`python -c 'from lxml import etree,builder; s="org.mariuszgromada.math:MathParser.org-mXparser:4.4.2";E=builder.E;e=E("dependency", *(E(k, v) for v,k in zip(s.split(":"), "groupId artifactId version".split(" ")))); print(etree.tostring(e).decode())'`
sed "38i\ ${mvnDeps}" -i pom.xml
echo 'object Main{@JvmStatic fun main(vararg a:String){System.setProperty("sun.java2d.opengl","True"); me.nanjingchj.desmos.Window()} }'>`find -type d -name kotlin|head -n1`/Main.kt


然后 mvn package exec:java -Dexec.mainClass=Main 即可
感觉 maven 依赖这么多插件 archetype, install, exec 完成日常任务,有点不平衡吧……
此外还看到了生成本地文件依赖的 Maven #doc https://stackoverflow.com/questions/6704813/maven-generating-pom-file mvn install:install-file

#parser https://github.com/mariuszgromada/MathParser.org-mXparser 我草这玩意又不支持逆向计算,有啥好吹的
还夸张地弄了那么多图,太那啥了
http://scalarmath.org/wp-content/uploads/2019/01/scalar-promo-screens.png 弄个心型函数还要用户自己推导正向公式, 就凭这? 一个 evaluator 和 Python, JS eval 之类的东西有什么区别
不愧是 Java EE 搞出来的混乱怪物,就喜欢一些毫无意义的老套封装
#TypeScript #lib #doc https://util.liuli.moe/@liuli-util/async/ 有一大堆 concatMap, debounce, wait 等操作的 async 组合库

https://util.liuli.moe/@liuli-util/array/ 包含 swap, groupBy, segment(即 chunked), diffBy, uniqueBy 等处理函数 ,还有 arrayToMap(即 associate)
https://util.liuli.moe/@liuli-util/string/#StringValidator.isEmail 非常实际的一个值验证
https://util.liuli.moe/@liuli-util/dom/ 包含一些下载 ArrayBuffer 之类的处理,不过没有复制到剪贴板的

https://util.liuli.moe/@liuli-util/other/#EventEmitter EventTarget 一类对象实现
https://util.liuli.moe/@liuli-util/test/#countTime 这个就是 measureTime { } ,要是能写成 Python timeit 的形式就好了
此外还有 tree 库,支持 treeEach 后序遍历树结构,treeToList (即 flatten , 还有 treeFilter 的变体)
#doc #life #tech Git 文件库版本控制软件
#huawei #doc https://tttttt.me/berd_channel/2618?single 5G 秘诀:搜索设置项 "SA" (GLES MSAA 抗锯齿) 🌝🤔
duangsuse::Echo
#js #web #DontKnow DOM 小提示! 😘 1. with(e.parentNode){ insertBefore(e1, e); removeChild(e) }可以用 e.replaceWith(e1) 替换 2. e.remove() 等于 e.parentNode.removeChild(e) 3. children, firstChild, prevElementSibling 不会获取到 text node 而 childNodes, parentNode, nextSibling…
#html #dom #API #doc #dontknow
https://duangsuse-valid-projects.github.io/Share/HTMLs/school/ 🌝新写了个弹球动画,我真是 HIGH 到不行,赛高哩HIGH哒≈

https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats

还有之前的剪贴板我也查了
document.querySelectorAll("[contenteditable]").forEach(e=>e.onpaste=(ev)=>{ e.execCommand("paste",false,ev.clipboardData.getData("text/plain")); })

[在线Html编辑器粘贴过滤技术详解(一)_weixin_33910460的博客-CSDN博客](https://blog.csdn.net/weixin_33910460/article/details/89910701)
[JavaScript如何获取粘贴事件的剪贴板数据(跨浏览器)? - 问答 - 云+社区 - 腾讯云](https://cloud.tencent.com/developer/ask/186776)

另外在找的时候我发现一个 1k star 的 JS DOM 变动静态库,思想挺有意思的,不用 MutationObserver 和 NodeIterator,TreeWalker (document.createXXX(e).nextNode() ) 什么的,而是利用了自定义 @keyframes 的事件 animationStart 。 API 类似 inotify , on(selector,op) 这样

https://github.com/muicss/sentineljs
然并暖,到 DevTools events/debugger 面板看看 DOM Events 的归类就能发现有一大堆 DOM 变动的事件支持嵌套次序🌚
$0.addEventListener("DOMSubtreeModified",console.log); $0.getRootNode().body.setAttribute("contenteditable","")
稍有常识的人不难看出,如果我们的 API 继续前进,类似的魔法还能有价值吗?