Skip to content

Instantly share code, notes, and snippets.

[{"direction":"Long","timestamp":"01/19/2023 09:40:00 AM"},{"direction":"Short","timestamp":"01/19/2023 09:48:00 AM"},{"direction":"Long","timestamp":"01/19/2023 10:08:00 AM"},{"direction":"Short","timestamp":"01/19/2023 10:12:00 AM"},{"direction":"Long","timestamp":"01/19/2023 11:08:00 AM"},{"direction":"Short","timestamp":"01/19/2023 11:28:00 AM"},{"direction":"Long","timestamp":"01/19/2023 12:00:00 PM"},{"direction":"Short","timestamp":"01/19/2023 12:24:00 PM"},{"direction":"Long","timestamp":"01/19/2023 12:59:00 PM"},{"direction":"Short","timestamp":"01/19/2023 01:51:00 PM"},{"direction":"Long","timestamp":"01/19/2023 02:15:00 PM"},{"direction":"Short","timestamp":"01/19/2023 02:54:00 PM"},{"direction":"Long","timestamp":"01/18/2023 09:40:00 AM"},{"direction":"Short","timestamp":"01/18/2023 10:18:00 AM"},{"direction":"Long","timestamp":"01/18/2023 01:26:00 PM"},{"direction":"Short","timestamp":"01/18/2023 02:02:00 PM"},{"direction":"Long","timestamp":"01/18/2023 02:28:00 PM"},{"direction":"Short","timesta
@brandonros
brandonros / main.tf
Last active January 13, 2023 01:57
Docker Desktop + Kubernetes + Terraform + Helm Charts for Elasticsearch/Kibana
provider "kubernetes" {
config_path = "~/.kube/config"
config_context = "docker-desktop"
}
provider "helm" {
kubernetes {
config_path = "~/.kube/config"
config_context = "docker-desktop"
}
@brandonros
brandonros / macpine.sh
Last active November 28, 2022 02:59
QEMU + Macpine = Debian container on Apple M1 arm64/aarch64
#!/bin/bash
# install qemu
brew update --auto-update
brew install qemu
# install macpine
wget https://github.com/beringresearch/macpine/releases/download/v.06/alpine_darwin_arm64
mv alpine_darwin_arm64 alpine
chmod +x alpine
sudo mv alpine /usr/local/bin/
# use alpine to launch debian VM
@brandonros
brandonros / retries-and-timeouts.rs
Created November 25, 2022 18:54
Rust async retries + timeout callbacks
use log::warn;
use std::future::Future;
pub async fn timeout_wrapper<Fut, T>(timeout_ms: u64, cb: &impl Fn() -> Fut) -> Result<T, String>
where
Fut: Future<Output = Result<T, String>>,
{
let request_future = cb();
let timeout_future = tokio::time::timeout(tokio::time::Duration::from_millis(timeout_ms), request_future).await;
if timeout_future.is_err() {

docker-compose.yaml

version: "3.7"

volumes:
  postgres:

services:
  rust-service: # in the same network by default in docker-compose?
@brandonros
brandonros / aws-ec2.tf
Last active September 24, 2022 18:29
AWS EC2 Terraform example
/*
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_DEFAULT_REGION="eu-central-1"
export TF_VAR_public_key=$(ssh-keygen -y -f ../assets/ssh-private-key.pem)
*/
terraform {
required_providers {
aws = {
typedef enum {
BC_ISLT,
BC_ISGE,
BC_ISLE,
BC_ISGT,
BC_ISEQV,
BC_ISNEV,
BC_ISEQS,
BC_ISNES,
BC_ISEQN,
@brandonros
brandonros / json-brotli-adapter.mjs
Created August 29, 2022 20:10
JSONBrotliAdapter for lowdb
import zlib from 'zlib'
import fs from 'fs'
class JSONBrotliAdapter {
constructor(filename) {
this.filename = filename
}
async read() {
let compressedData = null
[
{
"timestamp": "07/26/2021 10:40:00 AM",
"direction": "short",
"expectedExit": "07/26/2021 11:30:00 AM",
"expectedOpenPrice": 439.59666666666664,
"expectedExitPrice": 440.4116333333333,
"expectedProfitLoss": -407.48333333334585
},
{
#![no_main]
#![no_std]
use panic_probe as _;
use core::{cell::RefCell, ops::Deref};
use cortex_m::interrupt::{Mutex, free};
use cortex_m_rt::entry;
use stm32f4xx_hal::{
gpio::{Alternate, PA8, PC6},
pac::{interrupt, Interrupt, Peripherals, TIM1, TIM8},