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 / lstm_binary_prediction
Created May 3, 2024 05:02
lstm binary prediction
from random import randint
from numpy import array
from numpy import argmax
from pandas import concat
from pandas import DataFrame
from keras.models import Sequential
from keras.layers import LSTM
from keras.layers import Dense
# generate a sequence of random numbers in [0, 99]
@sangelxyz
sangelxyz / gist:97752321878bf71ac0cf0cfa065c1464
Created May 1, 2024 13:38
javascript sinewave animation on canvas
document.addEventListener('DOMContentLoaded', function() {
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
// Set canvas dimensions
canvas.width = 800;
canvas.height = 400;
let wave = {
y: canvas.height / 2,
<!doctype html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
<!-- Disable zooming: -->
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no"
/>
@sangelxyz
sangelxyz / gist:29a2395cf609aa469219a162f9379e90
Last active April 25, 2024 12:14
rust-optimised-sccache-mold-cranelift
[unstable]
codegen-backend = true
[build]
rustc-wrapper = '/home/sangel/.cargo/bin/sccache'
rustflags = ["-Z", "threads=16"]
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]
// Server-Sent Events (SSE) with tokio broadcast channel - with cors
// Note: seems to be cors error still while connecting.
use async_stream::stream;
use axum:: {
extract::State, response::{sse::{Event, KeepAlive, Sse}, IntoResponse}, routing::get, Json, Router
};
use std::{
convert::Infallible, sync::Arc, time::Duration
};
// Server-Sent Events (SSE) with tokio broadcast channel
// Update: removed arc/mutex.
use async_stream::stream;
use axum:: {
extract::State, response::{sse::{Event, KeepAlive, Sse}, IntoResponse}, routing::get, Json, Router
};
use std::{
convert::Infallible, sync::Arc, time::Duration
};
open Donald
open System.Data.Common
open System.Data.SQLite
open System.Threading.Tasks
open Giraffe
open Giraffe.ViewEngine
open FsToolkit.ErrorHandling
open Microsoft.AspNetCore.Builder
[<RequireQualifiedAccess>]
@sangelxyz
sangelxyz / gist:f73b1f7581318979275322dc13094e19
Last active April 25, 2024 16:19
Insomnia and Postman Alternatives
Updated list / April 25 - 2024
ATAC - https://github.com/Julien-cpsn/ATAC
Rest.nvim - https://github.com/rest-nvim/rest.nvim
Slumber - (uses tui client) https://slumber.lucaspickering.me/
Restfox https://restfox.dev/
fn main() {
let json_str = std::fs::read_to_string("../posts.json").unwrap();
let posts: Vec<Post> = from_str(&json_str).unwrap();
let start = Instant::now();
let mut post_tags_map: FxHashMap<&str, Vec<u16>> = FxHashMap::default();
for (post_idx, post) in posts.iter().enumerate() {
for tag in post.tags.iter() {