Skip to content

Instantly share code, notes, and snippets.

View jayhuang75's full-sized avatar

jayhuang75 jayhuang75

View GitHub Profile
@jayhuang75
jayhuang75 / rust_duckdb_demo_sentiment_analysis.ipynb
Last active August 31, 2023 18:35
rust_duckdb_demo_sentiment_analysis
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jayhuang75
jayhuang75 / duckdb_demo_aml.ipynb
Last active August 1, 2023 15:38
duckdb_demo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jayhuang75
jayhuang75 / mediator_unit_test.rs
Last active December 12, 2022 14:22
mediator_unit_test.rs
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new_aircraft() {
let ac312 = PassengerAircraft::new("ac312_toronto_newyork_1700");
assert_eq!(ac312.id(), "ac312_toronto_newyork_1700");
}
@jayhuang75
jayhuang75 / mediator_coordinator.rs
Created November 27, 2022 04:40
mediator_coordinator.rs
// Coordinator is playing a mediator role which ensure the only place to
pub trait Coordinator {
fn arrival(&mut self, aircraft_id: &str) -> bool;
fn gate_available(&mut self) -> Option<i8>;
fn departure(&mut self, aircraft_id: &str);
}
impl Coordinator for Airport {
fn arrival(&mut self, aircraft_id: &str) -> bool {
/*
@jayhuang75
jayhuang75 / mediator_aircraft.rs
Created November 27, 2022 04:28
mediator_aircraft.rs
pub struct PassengerAircraft {
id: String,
}
impl PassengerAircraft {
pub fn new(id: impl Into<String>) -> Self {
Self {
id: id.into(),
}
}
@jayhuang75
jayhuang75 / mediator_airport.rs
Last active November 27, 2022 14:49
mediator_airport
pub struct Airport {
name: String,
aircrafts: HashMap<String, Box<dyn Aircraft>>,
aircraft_on_gate: HashMap<i8, String>,
aircraft_queue: VecDeque<String>,
gates: HashMap<i8, bool>,
}
impl Airport {
@jayhuang75
jayhuang75 / rust_serverless_trading_view_github_action.yml
Created September 21, 2022 02:33
rust_serverless_trading_view_github_action
name: Rust
on:
push:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
BUILD_HOME: /home/runner/work/bot/bot
@jayhuang75
jayhuang75 / rust_serverless_trading_view_build.sh
Last active September 21, 2022 02:30
rust_serverless_trading_view_build
# build
cargo build --release --target=x86_64-unknown-linux-musl
# move to the bootstrap name
cp target/x86_64-unknown-linux-musl/release/rstvb bootstrap
# zip as lambda.zip
zip lambda.zip bootstrap
@jayhuang75
jayhuang75 / rust_serverless_trading_view_cargo.toml
Created September 21, 2022 01:24
rust_serverless_trading_view_cargo
[[bin]]
name = "bootstrap"
path = "src/bootstrap.rs"
[[bin]]
name = "main"
path = "src/main.rs"
@jayhuang75
jayhuang75 / rust_serverless_trading_view_bootstrap.rs
Created September 20, 2022 12:09
rust_serverless_trading_view_bootstrap
#[tokio::main]
async fn main() -> Result<(), Error> {
dotenv().ok();
// The runtime logging can be enabled here by initializing `tracing` with `tracing-subscriber`
// While `tracing` is used internally, `log` can be used as well if preferred.
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
// disabling time is handy because CloudWatch will add the ingestion time.
.without_time()