Spyke

Posts

askelectronics·Ask Electronicsbywulf

Unlock Small Doors on a Grid

So I have an idea of a habit builder (also I think it would be fun to build)

Essentially, one piece tracks the habit, and one piece unlocks doors (small, in a grid) based on habit trend. Inside each door would be a "prize".

My question is about the small doors.

  • Is there an example of small unlocking like this I can use to expand to multiple doors?

  • The idea is there might be more doors than pins on the microcontroller. Is there a board I could put inbetween, or a special technique since they are on a grid, to accomplish this?

View original on lemmy.world
linux·Linuxbywulf

ssh reverse tunnel

Is it possible to use a reverse ssh tunnel to force all network connection on the remote host through the local host.

Essentially:

local -> ssh -> remote remote web request -> ssh tunnel -> local -> internet

I want the remote to make connections through the locals VPN without having to authenticate on the remote as well

Hopefully this makes sense

View original on lemmy.world
programming·Programmingbywulf

Return Generic Type in Rust

Background: I have a large serde_json value that I want to be read-only (the authoritative source is an encrypted SQLite DB and should only be updated when that gets updated)

The issue, I would like a single get function that returns a generic type

use serde_json;

pub struct Configuration {
    config: serde_json::Value,
}

impl Configuration {
    async fn get(&self, key: &str) -> Result {
        let tmp_value: = &self.config["test"];

        // This would be repeated for String, bool, etc
        if tmp_value.is_i64() {
            match tmp_value.as_i64 {
                Some(x) => Ok(x),
                Err(e) => Err(()),
            }
        } else {
            Err(())
        }
    }
}

However I get: "mismatched types expected type parameter T found type i64"

Is it even possible to return multiple types from a single function?

EDIT: SOLUTION

Here is the solution I came up with:

pub struct Configuration {}

impl Configuration {
    fn get std::str::FromStr>() -> Result {
        Ok(T::from_str("1234");
    }
}

fn main() {
    let my_conf_val = Configuration::get();
}
View original on lemmy.world
headphones·Headphonesbywulf

Purchase Advice

Looking to get new headphones since the battery is now shot in my Corsair

I'm looking for:

  • Mostly listening to music, some online meetings, some single player games (I am not an audio file)
  • Bluetooth that can save multiple devices
  • Over ear
  • Noise cancelling (preferably adjustable, but not necessary)
  • Microphone (preferred but not necessary)
  • Under 300 (preferably under 200)

Whenever I search online the lists are always "here is the best for 500 - 1000, or really affordable, but with no features"

Thank you in advanced!

View original on lemmy.world
personalfinance·Personal Financebywulf

Calculating Interest on a "Virtual" Savings Account

So for our kids, who are still quite young, instead of opening an entire other savings account for them, we decided to do "virtual" savings accounts.

Essentially, we have a spreadsheet with what money they have gotten from birthdays and other events, then we just deposit it in our savings. They can withdraw whenever they want.

In this spreadsheet, I've been trying to keep track of interest (in a basic way), to show how saving can also help them "earn" money. However, I don't think I'm doing it correctly.

See Google sheet: dates are not correct and interest rates are not accurate. I just wanted to show that we are attempting to give the "correct" interest rate for the given date. (I know interest rates fluctuate all the time, just trying to not make it not too difficult to maintain)

https://docs.google.com/spreadsheets/d/1rwwIFVOGYt-lIx8Dtuv_6PGz28jSNQbH7LcZG2qKlfg/edit?usp=sharing

Thank you for taking a look, I've been trying to get this right for a while.

View original on lemmy.world

You reached the end