duangsues.is_a? SaltedFish
60 subscribers
609 photos
6 videos
91 files
562 links
🌶🐔🐟 duangsuse 的日常
尤其喜欢发些奇奇怪怪的东西
和转载别人的东西
Download Telegram
Forwarded from dnaugsuz
不要 message 参数,在所有调用处
刚刚我还以为这个是成功消息(即有可能失败)
既然只是 message = "复制成功" 的默认值就没有必要弄了

有个比较疯狂的做法,但是行数短。

const el = (tag,conf,childs)=>{ let e=document.createElement(tag); conf(e); for (let ee of childs)e.appendChild(ee); return e; }, sets=(k,v)=>e=>{ e[k]=v },
withTempAppend=(e,e_dst,op)=>{
e_dst.appendChild(e); op(e); e_dst.removeChild(e);
};

copyToClip = (s) => { let e=el("input", sets("value",s)); withTempAppend(e, document.body, (it)=>{ it.select(); it.execCommand("copy"); }); }
Forwarded from dnaugsuz
还有一个正经行数短的。

const also = (op, x) => { op(x); return x },
copyStr = (s) => also(it => { it.select(); it.execCommand("copy"); it.remove(); }, document.body.appendChild(document.createElement("input")));
Forwarded from dnaugsuz
噢,原来递归类型就是编译期能解决类型检查…… 不对
这个和 C 的 tail=NULL 没有区别吧,只是用了 std:: u_ptr 和 variant

using List=std::variant<Cons,struct Nil>,
Cons=struct{int x, std::unique_ptr<List> xs};
struct Nil{};
auto Nil=std::make_unique<List>(Nil{});

List ll1 = Cons{2,Nil};
Forwarded from dnaugsuz
元函数元在哪里啊,这个字大概是「基础」的含义吧

template struct/func 都可以取 decltype ,那就是说能得到模板参数? lambda 不能,所以类型侧和程序侧都不能递归?(对了 有 f=>(f f) 的方法,但不能作参数没用)
#python #code #huawei 开始还以为 reduce 的 op/init args 顺序都是 acc,x ,没想到一个 acc,x 一个 xs,acc 啊……
from functools import reduce
def subst(sa,sb,sep=" "):
reps = list(zip(*(s.split(sep) for s in [sa,sb])))
return lambda s: reduce(lambda acc,ab: acc.replace(*ab), reps, s)
print(subst("Google Android", "Huawei Haromny")("Google's Android"))
Forwarded from dnaugsuz
def subst(sa,sb,sep=" "):
reps = list(zip(s.split(sep) for s in [sa,sb]))
return lambda s: reduce(lambda acc,ab: acc.replace(*ab), s, reps)
subst("Google Android", "Huawei Haromny")("Google's Android")
proc 写一篇博客?
when 选题:
选到简单的主题:
@简单@这么简单,大家都知道吧?没什么好写的……
link 退出
选到复杂的主题:
有点复杂,我还没全搞懂呢,没把握写好……
when 研究一下:
alt 一段时间后
搞明白了: link 简单
没搞明白:
when 继续研究?:
alt 算了,好的
@退出@不写了,结束
link 研究一下
🤔 考虑下…… graphviz
console.log(subExprs("zipReplace(...给定)(src) == expect", s=>eval(s))); // JS 是没有显式 binding ,只有 eval 调用处 caller 带 binding
呃……
#android #net #js replace 了下 XMLHttpRequest 的 open() 和 send()
Forwarded from BUG
我前天发现自己写的http框架在使用ssl时正常访问一些外网,Url.openConnection和okhttp、浏览器均不行,然后突发奇想接手webview的资源加载
Forwarded from BUG
Forwarded from BUG
get拦截可以采取页面加载时注入js hook原型
#Android #db
val query = MediaStore.Media.Image.run {
contentResolver.query(CONTENT_URI, projection, "${RELATIVE_PATH}=? and ${DISPLAY_NAME}=?", arrayOf(path,name), "${RELATIVE_PATH} ASC")
}


预计可用 DSL 写法:
import android.content.iss.onediaStore.Images.Media.*
fun queryPath(path,name) = contentResolver.queryURI { projection=projection; where(RELATIVE_PATH eq path and DISPLAY_NAME eq name); sorted(RELATIVE_PATH, asc=true) }
Forwarded from Perol
Forwarded from Luke
EROFS是一个完全由华为开源并贡献到Linux内核主线的文件系统,遵守GPLv2开源协议,也就是说,搭载EROFS的手机如果不遵守GPL协议开源的话,相当于窃取了华为的技术。