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

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
Forwarded from 任桑 今天开始做魔王
所以抄个别的语言的代码套在py上,我是否可以理解为你既不熟悉scheme也不熟悉py呢,不然你干嘛要抄
Forwarded from dnaugsuz
只是习惯了,好比我之前写过 Haskell,所以喜欢用 for x in xs: 一些,谁能因此断言 for 一定是 Haskell way (forM_) 或者 x/xs 一定是 Python way?
Forwarded from dnaugsuz
其实我上面喷的单纯是那个必须 explicit 的 self 参数,在 Rust 这样“多范式”的语言里往往才是这样(事实上,Rust 是有 impl 的,不需要显式写 self 参数)

以及一个 str.join 的小问题——别的语言都是 iter.join,Python 给搞个 str.join,还是“面向对象”语言

给人感觉设计上不够坚定,把 re module 不和 built-in str 结合在一起可以认为是“工程”的,可 a join xs 这种命名方法完全是过分模拟自然语言语序,虽然 Python 是很早就诞生的“脚本语言”所以有些问题很正常,我觉得作者的设计水平还是感觉一般
Forwarded from LightQuantum
import this
Forwarded from dnaugsuz
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Forwarded from dnaugsuz
看来 Python 的 core devs 还是一群文艺青年,我还以为导入这个模块可以提供 this 字面名呢
Forwarded from dnaugsuz
Complex is better than complicated.
是啊,可是 self 哪里比 implicit this (实际上有点像作用域策略) 更 *不* complicated 的了?
duangsuse::Echo
上等讨论是交流观点,中等讨论是谈论事件,低等讨论是评判个人。 ——浅谈价值表达
第三次,我居然一句话没说(叮~counter+1),麻木了吗?还是我本来就不应该考虑那些事情?
我……真的不能写应用? 🤔
刚才我看到了 https://azul.rs/ 的 button counter 示例程序,默写下? #code

//use ...

struct Counter {
count: i32
}
impl Layout for Counter {
fn layout(self: Counter, _info: &LayoutInfo) -> Dom {
let label = Label::new(format!("{}", self.count)).dom();
let button = Button::new("+1")
.clicked(Callback(onIncClicked));
Dom::div()
.add(label).add(button)
}
fun onIncClicked(self: Counter) -> ScreenUpdate {
self.count += 1
Redraw
}
}


第二次
extern create azul;
use azul::{ prelude::*, label::Label, button::Button }

struct AppState {
counter: usize
}
impl Layout for AppState {
fun layout(&self, _info: LayoutInfo<Self>) -> Dom<Self> {
let label = Label::new(format!("{}", self.counter));
let btn_inc = Button::new("+1").handle("click", Callback(onIncClicked));
Dom::new().with_child(label).with_child(btn_inc);
}
fun onIncClicked(&mut self) -> ScreenUpdate {
self.counter += 1
Redraw
}
}
extern create azul;
use azul::{ prelude::*, widget::{ label::Label, button::Button } };

struct DataModel {
counter: usize
}
impl Layout for DataModel {
fn layout(&self, _info: LayoutInfo<DataModel>): Dom<DataModel> {
let label = Label::new(format!("{}", self.counter));
let btn_inc = Button::with_label("+1").add_action(On::MouseUp, Callback(onIncClicked));
Dom::div().with_child(label).with_child(btn_inc)
}
fn onIncClicked(info: EventInfo<DataModel>) -> ScreenUpdate {
info.state.data.counter += 1
Redraw
}
}
duangsuse::Echo
extern create azul; use azul::{ prelude::*, widget::{ label::Label, button::Button } }; struct DataModel { counter: usize } impl Layout for DataModel { fn layout(&self, _info: LayoutInfo<DataModel>): Dom<DataModel> { let label = Label::new(format!("{}"…
extern crate azul;

use azul::{prelude::*, widgets::{label::Label, button::Button}};

struct DataModel {
counter: usize,
}

impl Layout for DataModel {
fn layout(&self, _info: LayoutInfo<Self>) -> Dom<Self> {
let label = Label::new(format!("{}", self.counter)).dom();
let button = Button::with_label("Update counter").dom()
.with_callback(On::MouseUp, Callback(update_counter));

Dom::div()
.with_child(label)
.with_child(button)
}
}

fn update_counter(event: CallbackInfo<DataModel>) -> UpdateScreen {
event.state.data.counter += 1;
Redraw
}

fn main() {
let mut app = App::new(DataModel { counter: 0 }, AppConfig::default()).unwrap();
let window = app.create_window(WindowCreateOptions::default(), css::native()).unwrap();
app.run(window).unwrap();
}

这是真实代码

fun main() {
let mut app = App::create(DataModel { counter = 0 }).unwrap();
let win_main = Window::create(WindowOptions::default(), css:native).unwrap();
app.run(win_main).unwrap()
}


fun main() {
let mut app = App::new(DataModel { counter = 0 }, AppOptions::default()).unwrap();
let win_main = app.create_window(WindowOptions::default(), css::native).unwrap();
app.run(win_main).unwrap();
}

unwrap()
几乎写到手软,记得当初信 Rust 教的时候,对这个名词相当困扰,不知道它是 Option<T> 上的一个操作……
Forwarded from dnaugsuz
啊,很老很老的 Intel x86 架构手册,一般只有编译器后端的工程师才会看的那种
Forwarded from dnaugsuz
对我来说,如果一个人有学姐的名号,就是要向请教的晚辈主动提供些信息的
现在不少的大佬,带着权威的性格,却一个字也不会给提问的人透露
Forwarded from SCP-079-LOGGING (SCP-079-WARN)
项目编号:WARN
用户 ID:302913115
操作等级:封禁用户
规则:群管自行操作
用户昵称:duangsuse
我想引用学姐的话杜撰一下:
在不知道对面的权利范围的时候跟对方说,你那个怎么样 简直就是在找封 #China #Telegram #Low #freedom
你是我的学姐,我就是你的学弟,长辈帮助晚辈,在自己的领域里天经地义。

上等讨论是交流观点,中等讨论是谈论事件,低等讨论是评判个人。
——浅谈价值表达

领英对行家的定义是,在自己的领域中,根据自身经验和知识,为他人答疑解惑,分享行业洞察,提供经验干货。简单来说,所谓的行家,就是善于思考,乐于发声的人。
——浅谈价值表达

我还记得,在肖战事件中,有位娱乐圈大腕曾经发话:
“某天一位当红流量明星来找我,希望我推荐他上欧美大音乐节和颁奖礼,我帮他推荐了,他问“我能帮你做什么?”我说“没有”。他说“那你为什么帮我?”我说我是江湖老腕儿,帮年轻人是分内之事,不需市恩市义。他问“腕儿和明星有啥区别?为啥腕儿能当那么久而明星三五年就过气了?”我说明星心里大约只想着自己和粉丝那一亩三分地,粉丝也觉得全行业都欠TA家明星的;腕儿心里爱江湖,希望大家都好,愿意为行业付出。他想了想说“好像是的”。我说希望你有一天能成为一个腕儿,心里不光有自己,也有行业和大家。你心里有江湖,江湖心里就会有你。不然流量明星就只能简称“流星”了。”

我当然知道那只是个称呼,但我从没感觉到大佬们对“菜鸡”有过一点关爱,哪怕是发个链接都太珍贵了。

有的时候突然从某处蹦出一个不常发言的大佬,指着我说:你太恶心了、你根本不尊重学术、你就是个分裂民科。
那你们的心里,又是否为自己的领域留下一个名叫热爱的位置呢?
小白的数目,实际上是由大佬的实际行动决定的。
如果你们不愿意改变,也请对他们不要那么反感。
#statement