作者归档:ning

“卷”可能存在中国人的基因里

“卷”可能存在中国人的基因里

中华民族地少人多,却存在了几千年,作为地球上现存有文明流传最长的民族,我们能生存的原因,可能就是因为卷,因为忧患意识足够。这种忧患意识造就了我们,也限制了我们。

先天下之忧而忧,后天下之乐而乐。

安得广厦千万间,大庇天下寒士俱欢颜。

兴,百姓苦,亡,百姓苦。

王师北定中原日,家祭无忘告乃翁。

王侯将相宁有种乎。

水能载舟,亦能覆舟。

我劝天公重抖擞,不拘一格降人才。

多少文人志士,多少英雄豪杰,多少明君昏主,多少无名之辈。。。前仆后继。。。

当我们喊卷想润之时,不妨想一想,我们自己为这个国家做过的贡献是哪些?这个国家究竟是我们的还是他们的!

忧患意识造就了我们,也限制了我们,但是我们还有办法!

我们觉得卷,是因为我们承担了太多,而这些承担很多是大可不必的,也从来不必害怕卷。在这个充满不安的环境中,劣币驱逐良币的事情时刻在发生,我们永远不要忘记“天无绝人之路”,我们还可以“深度思考,另辟蹊径”。

当大家卷读书的时候,不要忘记学校通识教育带来的知识是共知的,而共知的往往是增值较低的,稀缺才能高溢价。

当大家卷房子的时候,不要忘记房价与经济发展、人口增长以及科技发展的关系。

当大家卷累了的时候,你仍然可以选择躺平,也可以选择润(感谢你为大家挪地方),还可以选择与人斗其乐无穷—-每一份不满都是动力。

散户最简单的抄底技巧

  • 只有出现底背离的时候再抄
  • 抄底还要结合股票基本面、市场情绪氛围、消息面
  • 抄底要搞清楚自己是投机还是投资,投机就是短期,见好就收,投资就是长期持有,不要将投机变成投资
  • 一定要设置止损、止盈
  • 在支撑位底部附近建仓,跌破支撑止损,在压力位附近跌破压力位清仓,涨破压力位加仓
  • 盈利时,利润回撤超过一半清仓
  • 盈亏比例一定要超过1:3,这样你亏2次赚一次也能回本,33%的胜率也能赚钱
  • 如有自己的移动止损止盈策略更好。

为什么股票和基金不能越跌越买

看到 V2 这么多人一年亏损 20%以上,觉得有必要普及一些常识,首先就是不能越跌越买:

  • 大家来股市都是赚钱的,资本也是一样,跌得越多资本想拉起来的资金越多,拉起来的时候散户容易一点盈利就跑,最终导致无法拉高,人家赚不到钱,出不了货,所以拉大跌的股就是不划算的事情。不如做龙头,一天赚 10,20 个点,一个月就能翻倍。

  • 跌是有原因的,比如新能源,虽然汽车卖的好,但是产能过剩利润低,而且已经炒过一波了,很多散户在高位等着人去解套,资本不傻,他就不会上去为你解套,然后他自己套住。

  • 时间成本,不停的在抄底,永远不会知道低在什么时候,正如 1,2 点资本一定是等大家都放弃手上筹码了,才会去拉,先磨掉你得耐心,再假拉几次,然后加速下跌,然后横盘几个月,然后再加速下跌,然后在搞几个假动作,让你完全失去信心,丢掉自己筹码,再开始正式拉升,这起码得几个月甚至上年,你能等得起吗?

  • 最好的买点不是最低点,趋势永远无法预测,所以我们不要去预测低点。而是利用趋势的另外一个特点,就是趋势一旦形成就较难改变,所以最好的买点是趋势确认已经形成的那一刻,这样资金利用率最高。

宝塔Postgresql扩展安装

以pg_stat_statements为例

编译扩展

cd /usr/local/pgsql/contrib/pg_stat_statements/
make && make install

启用扩展

切换为postgres用户sudo su - postgres,运行sql命令行psql,启用扩展

CREATE EXTENSION pg_stat_statements;

修改postgresql.conf

进入宝塔面板,修改postgres配置

shared_preload_libraries= 'pg_stat_statements'

重启postgresql

T0ETF基金

513180 恒生科技
513330 恒生互联网
159941 纳指
513060 恒生医疗
511380 可转债
518880 黄金
513090 证券
159920 恒生
513120 创新药
513500 标普500
513360 教育
513520 日经
162411 油气
513530 红利
159980 有色
513310 半导体
159981 能源化工
513970 消费
159850 国企
513030 德国
164824 印度
161128 标普科技
162719 石油
513080 法国
162415 美国消费
501025 银行

A股重要的ETF

宽基

  • 沪深300 510300
  • 科创版 588000
  • 创业板 159915
  • 上证50 510050
  • 中证500 510500
  • 中证1000 159845

板块

  • 银行 515290
  • 酒 512690
  • 电力 159611
  • 证券 512880
  • 半导体 159995
  • 计算机 159998
  • 医药 512010
  • 医疗 512170
  • 家电 159996
  • 新能源 516160
  • 煤炭 515220
  • 基建 516970
  • 房地产 512200
  • 农业 159825
  • 钢铁 515210
  • 军工 512660
  • 旅游 159766
  • 有色 512400
  • 化工 159870
  • 人工智能 159819
  • 机器人 562500
  • 游戏 159869
  • 大数据 515400
  • 软件 159852
  • 教育 513360

PostgreSQL之json字符字段查找

根据字段值查找

SELECT t.*
FROM table_name t
WHERE json_field->>'type'='5' and  json_field->>'value'!=''

查找并替换

update
table_name d
set cover_content=(cover_content::jsonb || jsonb_build_object('cover_img_id',((select f.id  from file f WHERE  f.path = SUBSTRING(cover_content->>'value',44))  limit 1)::text)::jsonb)
where cover_content->>'type'='5' and  cover_content->>'value'!='' and cover_content->>'cover_img_id' is null;

数组里面的字段查找

字段里面存的是数组,数组里面存的对象,可以通过以下语句直接查询对象属性的值

select *
    from cart,
jsonb_array_elements(data::jsonb) as elem where ( elem->>'cover_img_id' is null or  elem->>'cover_img_id'='') order by created_at desc;

数组字段查找并替换

update cart set data= (
  SELECT jsonb_agg(
    CASE
      WHEN element->>'cover_img_url' <> '' THEN jsonb_set(element, '{cover_img_id}',
          ((((select f.id  from file f WHERE  f.path = SUBSTRING(element->>'cover_img_url',44))  limit 1)::text)::jsonb)
          )
      ELSE element
    END
  )
  FROM jsonb_array_elements(data::jsonb) AS element
)
where id in (
    select id
    from cart,
jsonb_array_elements(data::jsonb) as elem where elem->>'cover_img_url' <> '' and ( elem->>'cover_img_id' is null or  elem->>'cover_img_id'='') order by created_at desc
    );

多级数组查找替换

select id                                as cart_id,
       cart_user_id                      as user_id,
       elem ->> 'id'           as file_id,
       (updated_at + interval '30 days') as expired_at
from cart,
     jsonb_array_elements(data::jsonb) as elem
limit 10;

update file f
set expired_at=t.expired_at
from (select id                                as cart_id,
       cart_user_id                      as user_id,
       (elem ->> 'id')::int           as file_id,
       (updated_at + interval '30 days') as expired_at
from cart,
     jsonb_array_elements(data::jsonb) as elem)
         as t
where f.id = t.file_id
  and f.expired_at < t.expired_at;

GoldenDict字典下载以及配置

字典下载

推荐下载:

  • The Little Dict
  • LDOCE 5++ V2.15
  • 牛津高阶英汉双解词典(第9版)
  • 英汉大词典(第2版)

LDOCE 5++配置

自动显示中文

LM5Switch.js

showChineseAll(true); # 在下面两行前增加这一行
// trigger float logo
$(window).scroll();

开启音节默认显示

LM5style.css

.HWD .HYP {
    display: inline-block;
}

参考

数据库究竟存0还是null或者”有标准答案

存0的情况

  • 数值型但是需要统计:比如余额,订单总额

存null的情况

  • 外键可以为空:比如admin_user_id)如果为系统操作,可以为null,这时候存0必须取消数据库约束,或者不建外键约束,都不如存null好

存”的情况

  • 非必填且填写的字符串可以为空字符串:比如外国人的middle name,存”可以方便的拼接full name,这个时候如果不需要拼接,你还是可以存null.
  • 框架不支持修改时自动将null呈现为”,且保存时自动”改为null

Rust图形用户界面(GUI)推荐

iced

A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm.


struct Counter {
    // The counter value
    value: i32,
}

#[derive(Debug, Clone, Copy)]
pub enum Message {
    IncrementPressed,
    DecrementPressed,
}

use iced::widget::{button, column, text, Column};

impl Counter {
    pub fn view(&self) -> Column<Message> {
        // We use a column: a simple vertical layout
        column![
            // The increment button. We tell it to produce an
            // `IncrementPressed` message when pressed
            button("+").on_press(Message::IncrementPressed),

            // We show the value of the counter here
            text(self.value).size(50),

            // The decrement button. We tell it to produce a
            // `DecrementPressed` message when pressed
            button("-").on_press(Message::DecrementPressed),
        ]
    }

    pub fn update(&mut self, message: Message) {
        match message {
            Message::IncrementPressed => {
                self.value += 1;
            }
            Message::DecrementPressed => {
                self.value -= 1;
            }
        }
    }
}

Features

  • Simple, easy-to-use, batteries-included API
  • Type-safe, reactive programming model
  • Cross-platform support (Windows, macOS, Linux, and the Web)
  • Responsive layout
  • Built-in widgets (including text inputs, scrollables, and more!)
  • Custom widget support (create your own!)
  • Debug overlay with performance metrics
  • First-class support for async actions (use futures!)
  • Modular ecosystem split into reusable parts:
    • A renderer-agnostic native runtime enabling integration with existing systems
    • Two built-in renderers leveraging wgpu and glow
      • iced_wgpu supporting Vulkan, Metal and DX12
      • iced_glow supporting OpenGL 2.1+ and OpenGL ES 2.0+
    • A windowing shell
    • A web runtime leveraging the DOM

dioxus

Dioxus 是一个可移植的、高性能的、符合人体工程学的框架,使用 Rust 语言构建跨平台的用户界面。

fn app(cx: Scope) -> Element {
    let mut count = use_state(cx, || 0);

    cx.render(rsx! {
        h1 { "High-Five counter: {count}" }
        button { onclick: move |_| count += 1, "Up high!" }
        button { onclick: move |_| count -= 1, "Down low!" }
    })
}

Dioxus 可用于生成 网页前端、桌面应用、静态网站、移动端应用、TUI程序、等多类平台应用。

如果你能够熟悉使用 React 框架,那 Dioxus 对你来说将非常简单。

独特的特性:

  1. 桌面程序完全基于本地环境运行(并非 Electron 的封装)
  2. 符合人体工程学的设计以及拥有强大的状态管理
  3. 全面的内联文档 – 包含所有 HTML 元素、监听器 和 事件 指南。
  4. 极快的运行效率和极高的内存效率
  5. 智能项目热更新和高效的项目迭代
  6. 一流的异步支持fire
  7. 更多内容请查看 版本发布信息.

tauri

Build smaller, faster, and more secure desktop applications with a web frontend.

Features

  • Desktop Bundler (.app, .dmg, .deb, AppImage, .msi)
  • Self Updater
  • App Signing
  • Native Notifications (toast)
  • App Tray
  • Core Plugin System
  • Scoped Filesystem
  • Sidecar

Security Features

  • localhost-free (:fire:)
  • custom protocol for secure mode
  • Dynamic ahead of Time Compilation (dAoT) with functional tree-shaking
  • functional Address Space Layout Randomization
  • OTP salting of function names and messages at runtime
  • CSP Injection

Utilities

  • Rust-based CLI
  • GH Action for creating binaries for all platforms
  • VS Code Extension

egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native

ui.heading("My egui Application");
ui.horizontal(|ui| {
    ui.label("Your name: ");
    ui.text_edit_singleline(&mut name);
});
ui.add(egui::Slider::new(&mut age, 0..=120).text("age"));
if ui.button("Click each year").clicked() {
    age += 1;
}
ui.label(format!("Hello '{}', age {}", name, age));

yew

A framework for creating reliable and efficient web applications.

use yew::prelude::*;

#[function_component]
fn App() -> Html {
    let counter = use_state(|| 0);
    let onclick = {
        let counter = counter.clone();
        move |_| {
            let value = *counter + 1;
            counter.set(value);
        }
    };

    html! {
        <div>
            <button {onclick}>{ "+1" }</button>
            <p>{ *counter }</p>
        </div>
    }
}

fn main() {
    yew::Renderer::<App>::new().render();
}

slint

Design Goals

We use the following design goals as a guide when developing Slint:

  • Scalable: Run on any screen connected to a device, from desktop computers to low end embedded systems.
  • Lightweight: Fit into a few hundred kilobytes of RAM and require little processing power.
  • Intuitive: Both developers and designers should feel productive and enjoy the design and development process. The APIs should be consistent and easy to use, no matter the target language.
  • Native: Slint apps should match the users’ expectations of a native application. Various target platforms such as embedded devices, desktops, mobile and web should be supported so that both the user and the developer feel comfortable on their platform of choice.