Skip to content

Instantly share code, notes, and snippets.

View sangelxyz's full-sized avatar
🎯
Focusing

sAngelxyz sangelxyz

🎯
Focusing
View GitHub Profile
@sangelxyz
sangelxyz / gist:e1ed5294a60b7e7cd1b01adf7fd5b3ac
Created May 29, 2024 01:59
tradingview leptos component
use leptos::*;
#[component]
pub fn TradingView(symbol: String) -> impl IntoView {
// Creates a reactive value to update the button
view! {
<div class="tradingview-container" style="width:100%;">
<div class="tradingview-widget-container" style="height:100%;width:100%">
<div class="tradingview-widget-container__widget" style="height:calc(100% - 32px);width:100%"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js" async inner_html=r#"
@sangelxyz
sangelxyz / rust-let-else.rs
Created August 29, 2024 12:56 — forked from jeremychone/rust-let-else.rs
Rust 1.65 - let-else statements - new language feature!!! For youtube video: https://www.youtube.com/watch?v=U-5_bumwH9w&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q)
//! For youtube video: https://www.youtube.com/watch?v=U-5_bumwH9w&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q
/// Guard pattern with let-else
/// e.g., "my_key: 123"
pub fn key_num_guard_1(item: &str) -> Result<(&str, i32), &'static str> {
let Some((key, val)) = item.split_once(':') else {
return Err("Invalid item");
};
let Ok(val) = val.trim().parse::<i32>() else {
return Err("Invalid item");
@sangelxyz
sangelxyz / gist:7aa34ff7730d5f441918c82936a77347
Last active November 15, 2024 07:04
rust echarts graphic
// Add to echarts struct
// graphic: Vec<Graphic>
// add graphic: vec![],
// to chart > new
// add to implementation
pub fn graphic<I>(mut self, graphic: I) -> Self
where
I: IntoIterator<Item = Graphic>,
{
self.graphic.extend(graphic);
@sangelxyz
sangelxyz / gist:4e556af04ff03fc8d643adec3236a89b
Created December 18, 2024 17:30
Tradingview RSI, RMA in rust
// This is messy, still needs work. it will calculate the correct value with over 100points.
// lower v
///! Converted from the offical examples from.
/// https://www.tradingview.com/pine-script-reference/v6/
#[derive(Debug, Clone)]
struct Series {
closes: Vec<f64>,
period: f64,
https://www.lurklurk.org/effective-rust/
https://google.github.io/comprehensive-rust/
Handling Errors
https://sabrinajewson.org/blog/errors
@sangelxyz
sangelxyz / AI_BOT_PREVENTION.md
Created April 16, 2025 05:05
Anti Bot, AI scraping ideas.