programme

Total 21 posts
πŸ“„ Rust Pass Input to Command Stdin
C:2023-06-26 M:2023-06-26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 use std::{process::{Command, Stdio}, io::Write}; fn copy_to_clipboard_wcopy(s: String) { let mut wcopy = Command::new("wc") .arg("-c") .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() .expect("Failed to spawn `xclip`: please ensure you have it installed."); let mut stdin = wcopy.stdin.take().expect("Failed to write to stdin"); std::thread::spawn(move || { stdin.write_all(s.as_bytes()).expect("Failed to write to stdin"); }); let output = wcopy.
πŸ“„ C Error Handling
C:2023-05-05 M:2023-05-05
use strerror (in string.h) to convert err number into error message the relationship between error number and error messages can be viewed by errno -l (also man 3 errno will give you some tips).
πŸ“„ Use Custom DNS Name Server
C:2023-04-26 M:2023-04-26
After finding that my school network provided DNS name server doesn't work on my laptop(specifically my Arch Linux system, not my Windows system), I set custom DNS name server for my Arch Linux system. I use NetworkManager to manage my computer network. It automatically query network provider(like a WiFi) and set DNS name server for me by modifying /etc/resolve.conf. To set custom DNS name server, the first step is disable NetworkManager's auto setting DNS behavior.
πŸ“„ Create an Emacs Major Mode
C:2023-04-06 M:2023-04-06
Tutorial ModeTutorial - EmacsWiki Emacs General Emacs Symbol Notation Regular Expression Rx Expression - Emacs Manual regular expression - EmacsWiki Syntax Table Syntax Table - Emacs Wiki Font Lock & Face Levels of Font Lock - Emacs Manual font-lock-keywords - Emacs Manual Faces for Font Lock - Emacs Manual Face Attributes Example Indentation Line Function Example: https://github.com/ziglang/zig-mode/blob/master/zig-mode.el (zig-mode-indent-line)
πŸ“„ Tomcat_configuration
C:2023-04-04 M:2023-04-04
Installation 1 sudo pacman -S tomcat10 Configuration follow archwiki Run use /usr/share/tomcat/bin/{startup.sh,shutdown.sh,..} to start and stop tomcat Web Application This is my web application project structure. 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 .
πŸ“„ Use ChatGpt to Write SQL
C:2023-03-21 M:2023-03-21
Get the information for a whole database change the string your_database_name to your database name 1 SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_KEY, EXTRA FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'your_database_name' ORDER BY TABLE_NAME, ORDINAL_POSITION; then you can use this information to question him. multiple lines version: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_KEY, EXTRA FROM information_schema.
πŸ“„ UML Relationship Explain
C:2023-03-18 M:2023-03-18
Hi, chatgpt. I want to draw class diagram using UML. When should I use `Inheritance`, `Composition`, `Aggregation`, `Association`, `Link (Solid)`, `Dependency, `Realization` and `Link (Dashed)`? Hello! I'd be happy to help you understand when to use various UML relationships in a class diagram. Here's a brief explanation for each relationship type: Inheritance: Use inheritance when you have a "is-a" relationship between classes, meaning one class is a more specialized version of another.
πŸ“„ Rust Import Module
C:2023-03-07 M:2023-03-07
Suppose we have two files src/main.rs and src/utils.rs, to use utils.rs in main.rs, there are two ways that work. Use mod keyword in main.rs 1 2 3 / main.rs mod crate::utils; / mod utils; / use relative path to import Use pub mod keyword in lib.rs create a lib.rs file in src directory. 1 2 / lib.rs pub mod utils; then add this in main.rs 1 use <packageName>::utils;
πŸ“„ Rust_libraries
C:2023-03-01 M:2023-03-01
Resources awesome-rust ζ—₯常开发第三方库精选 Rust Language Related Error crate description anyhow Flexible concrete Error type built on std::error::Error thiserror derive(Error) futures futures and streams featuring zero allocations, composability, and iterator-like interfaces Logging crate description log Offical, to show message, it needs a implementation, recommend env_logger tracing trace, better for async programming development Concurrency crate description tokio suitable for IO-intensive computing, not the
πŸ“„ Clash_on_linux_server
C:2023-02-27 M:2023-02-27
Tips Github Acceleration: https://ghproxy.com/ Steps Download clash core goto https://github.com/Dreamacro/clash/releases download corresponding releases into your server 1 2 3 # use github acceleration service wget https://ghproxy.com/https://github.com/Dreamacro/clash/releases/download/v1.13.0/clash-linux-amd64-v1.13.0.gz # or manual download it and use scp/rsync to transfer it to your server unarchive and install core change <clash> to the actual name of the downloaded file 1 2 3 4 gzip -d <clash>.gz mv <clash>.gz clash.gz chmod +x ./clash mv ./clash /usr/bin/clash Make clash configuration directory 1 sudo mkdir /etc/clash Config.
πŸ“„ rCore
C:2023-02-20 M:2023-02-20
Based on rCore-Tutorial-Guide 2023 ζ˜₯季学期 and rCore-Tutorial-Book η¬¬δΈ‰η‰ˆ Useful Command To show platforms based on RISC-V that rustc supports 1 rustc –print target-list | grep riscv Rust Note Cross Build (RISC-V) .cargo/.config [build] target = "riscv64gc-unknown-none-elf" No Std Besides remove std section, you can refer to smallest no std - The Embedonomicon. Notes Linker Script linker script specifications: info ld Scripts or you can read
πŸ“„ Hugo Syntax Highlighting for Org
C:2023-02-19 M:2023-02-19

Code are stolen from ruippeixotog/quicksort Inline hl_lines hl_lines 1

1
third
hugo exports this type of inline code block into actual code block :( Src Block Maybe hugo doesn't support hl_lines property to highlight certain lines in a src block in org. However, you can use hugo shortcodes to achieve this. Example Traditionally adding property 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 // #+begin_src rust :hl_lines 8 use std::io; use std::io::BufRead; fn quicksort(v: &mut [i32]) { if !

πŸ“„ Firefox Disable Ctrl-w
C:2023-01-16 M:2023-01-16
As a vim key mapping user, I found firefox ctrl-w close tab is really a annoying key shortcut. Since in vim, the key shortcut ctrl-w is defaultly mapped as deleting a word. Solution Create usr/lib/firefox/defaults/pref/autoconfig.js 1 2 3 pref("general.config.filename", "firefox.cfg"); / our configuration file is called firefox.cfg at the roor directory of firefox lib pref("general.config.obscure_value", 0); pref("general.config.sandbox_enabled", false); // after testing, it is needed to disable sanbox Create /usr/lib/firefox/firefox.cfg
πŸ“„ AUR Contribution Guide
C:2023-01-09 M:2023-01-09
Category:Package development - ArchWiki Notes on creating packages for the Arch User Repository (AUR)
πŸ“„ Hide Secrets in Your Dot Files on Public Repository
C:2023-01-09 M:2023-01-09
I am using dotdrop to manage my dot files. If you don't use it, it's fine, but you may need to do a some extra work to make things done. For those who manually copy and paste their dot files, I highly recommend you to try it out. It can automate your copy-paste flow, and it is highly customizable. It can save you a lot of time dealing with chores.
πŸ“„ Read Baby Git Source Code
C:2023-01-05 M:2023-01-05
I find a well-commented git source code(based on Linus Torvalds first commit version) on the Internet, which is named baby-git by the modifier. It should be a nice footboard for those people who want to contribute to the actual git project(including me Τ…(β‰–β€Ώβ‰–Τ…)). The baby-git project URL: https://bitbucket.org/jacobstopak/baby-git/src/master/. However, in my last visit to the website, the page is blank, but you can still clone the repository via the following command:
πŸ“„ Risc-V Learning Summary
C:2023-01-04 M:2023-01-04
Enjoying and Hating assembly. Recently, I self-learned the cs61c(su20) class, which requires you to write a risc-v program to make a simple neural network in the project 2. It could be annoying that you write some bug in the assembly since the debug condition is frustrating. After all, through the project I learned a lot about risc-v, especially the calling conventions(at the beginning I haven't paid much attention to it, and it had really caused a lot of problems to my work).
πŸ“„ Switch to Wayland
C:2022-12-22 M:2022-12-22
Switch to Wayland Installation I choose hyprland as my Wayland window manager(and compositor) which is based on wlroots, it is a really new compositor with a lot of great features, and also it is pretty stable(according to the office). Here is the stars over time charts for it: Hyprland Stars Over Time 1 2 3 4 5 6 7 # glfw-wayland is conflict with glfw-x11 paru -S hyprland-git xorg-xwayland xorg-xlsclients qt5-wayland glfw-wayland qt6-wayland paru -S dunst wireplumber pipewire polkit-kde-agent xdg-desktop-portal-hyprland-git # must-have (from hyprland-wiki) paru -S wev # xev paru -S wl-clipboard # xclip paru -S wtype # xdotool applications 1 2 3 4 5 6 paru -S hyprpaper # wallpaper manager under hyprland paru -S rofi-lbonn-wayland-git # rofi under Wayland paru -S waybar-hyprland-git # waybar hyprland (enhanced?
πŸ“„ Emacs lsp-java Project Settings
C:2022-12-21 M:2022-12-21
Update: 2023-2-25 use eglot instead(in the last of the article) Create a java project with third libriaries support lsp-java is an awesome package for lsp-mode to open a java project. However, after some testing, I found it has difficulty in importing third party libraries with pure java project(not use maven, Gradle). Moreover, it only has a limited ability to interact with a Gradle project. However, it has great support for maven project, which means we can use maven to import third party java libraries.
πŸ“„ If Else In Sed
C:2022-12-21 M:2022-12-21
If-else statement in linux command sed use t or T to control the sed workflow.(more) 1 2 sed -i "s/animations = true/animations = false/;t;\ s/animations = false/animations = true/" "$picom_config" Reference How to toggle a comment in a line using sed Sed/Branching-and-flow-control