Skip to content

Instantly share code, notes, and snippets.

View araraloren's full-sized avatar
🍊
Thinking...

loren araraloren

🍊
Thinking...
View GitHub Profile
@araraloren
araraloren / website.txt
Created August 30, 2024 08:44
A website list of blog
STYLE: https://github.com/Jihadist/qt-stylesheets
pprof-rs: https://rustcc.cn/article?id=f5d9a1ad-e463-4ae4-91bf-ed11b8c0cbf0
MACRO: https://github.com/tfpk/macrokata
EMBEDDED: https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials
INTERPRET: https://rust-hosted-langs.github.io/book/introduction.html
STUDY: https://github.com/rust-lang-cn/rustlings-cn
PAPER: https://arxiv.org/pdf/2301.02308.pdf
DB: https://github.com/pjtatlow/jammdb
Lifetime: https://tfpk.github.io/lifetimekata/chapter_4.html !OVER!
ARGPARSER: https://github.com/rosetta-rs/argparse-rosetta-rs
@araraloren
araraloren / var_with_ref.rs
Last active August 28, 2024 13:15
Variable length arguments with lifetime
pub trait Inner<'a, T> {
fn inner(&self) -> &'a T;
}
/// Implement the trait if your want use your type in the
/// [`Callback`](super::Callback) of [`InvokeService`](crate::ser::InvokeService).
pub trait ExtractCtx<'a, V, S>
where
S: Inner<'a, V>,
Self: Sized,
@araraloren
araraloren / websocket.rs
Created July 30, 2024 11:45
Access websocket services using fastwebsockets create by deno.
use std::future::Future;
use std::sync::Arc;
use bytes::Bytes;
use color_eyre::Result;
use fastwebsockets::FragmentCollector;
use fastwebsockets::Frame;
use fastwebsockets::OpCode;
use http_body_util::Empty;
use hyper::header::CONNECTION;
use neure::{ctx::re_policy, prelude::*};
const DATA: &str = include_str!("../input.txt");
fn main() -> Result<(), Box<dyn std::error::Error>> {
let key = re::array(['&', '=']).not().repeat_one_more();
let val = re::array(['\'', '&', '=']).not().repeat_one_more();
let query = key.sep_once("=", val).sep("&");
let url = '?'.not().repeat_one_more().sep_once("?", query);
let key = re::array(['\'', ':']).not().repeat_one_more();
@araraloren
araraloren / calc_parser.rs
Created March 19, 2024 13:13
A parser example for calcuate expression.
use std::iter::once;
use neure::{neu::digit, prelude::*, re::rec_parser};
#[derive(Debug)]
pub enum Expr<'a> {
Int(i64),
Op(&'a str),
@araraloren
araraloren / main.rs
Created February 26, 2024 12:02
Using specialization take item from tuple
pub trait TakeOut<T, R> {
type Rem;
fn take_out(self) -> (T, Self::Rem);
}
pub struct __First;
impl<Head, Tail> TakeOut<Head, __First> for (Head, Tail) {
type Rem = Tail;
@araraloren
araraloren / main.py
Created February 24, 2024 15:54
Python using PySide6 in vscode
import sys
from pathlib import Path
from PySide6.QtGui import QGuiApplication
from PySide6.QtCore import QUrl, QObject, Slot
from PySide6.QtQml import QQmlApplicationEngine, QmlElement
QML_IMPORT_NAME = "com.bridge.py"
QML_IMPORT_MAJOR_VERSION = 1
@araraloren
araraloren / main.rs
Created February 24, 2024 07:38
Detect key press
use std::{
io::stdout,
time::{Duration, Instant},
};
use crossterm::{
cursor::MoveToNextLine,
event::{poll, read, KeyCode, KeyEvent, KeyEventKind, KeyModifiers},
style,
terminal::{disable_raw_mode, enable_raw_mode},
@araraloren
araraloren / playground.rs
Created February 3, 2024 12:58 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![crate_type = "proc-macro"]
use proc_macro2::Ident;
use proc_macro2::Literal;
use quote::quote;
use syn::{parse_macro_input, spanned::Spanned, ItemFn};
///
///```
/// use playground::named;
@araraloren
araraloren / xml.rs
Created December 19, 2023 15:05
Xml parser
use neure::{
err::Error,
prelude::*,
re::{rec_parser, RecursiveCtor},
};
fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
#[derive(Debug, PartialEq, Eq)]