pr06lefs

@[email protected]

This profile is from a federated server and may be incomplete. Browse more on the original instance.

pr06lefs,

Pretty much my whole genre is obscure - appalachian “old time” fiddle music.

The best way to experience this genre - sitting the middle of a jam, preferably with an instrument. Here’s boys them buzzards are flying from that perspective.

Some more examples I like:

Here’s Dan Gellert being funky on fretless banjo. Tune is black eyed susie.

Here’s his daughter Rayna Gellert & co on red steer

Here’s Jon Bekoff on rabbit in the pea patch.

Here’s some cool dual fiddles on grub springs

pr06lefs,

UPDATE!

I sort of solved this part of it, or at least got it to compile. I’ve got a reddit post of this too! Someone there hinted that I should use another struct ‘above’ ZkNoteStream. I’m doing that in the code listing below.

ZnsMaker has an init() fn, then you call make_stream() and it returns a ZkNoteStream. The intent is ZnsMaker should be managed so it lasts as long as the ZkNoteStream needs to last. All this bit compiles, great! But when I go to use it in my actix handler, I get a borrowing problem there instead. So I may have just kicked the can down the road.

This part compiles. Wrong types still, should produce Bytes instead of ZkListNotes.


<span style="color:#323232;">pub struct ZkNoteStream<'a, T> {
</span><span style="color:#323232;">  rec_iter: Box<dyn Iterator<Item = T> + 'a>,
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">impl<'a> Stream for ZkNoteStream<'a, Result<ZkListNote, rusqlite::Error>> {
</span><span style="color:#323232;">  type Item = Result<ZkListNote, rusqlite::Error>;
</span><span style="color:#323232;">
</span><span style="color:#323232;">  fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
</span><span style="color:#323232;">    Poll::Ready(self.rec_iter.next())
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">pub struct ZnsMaker<'a> {
</span><span style="color:#323232;">  pstmt: rusqlite::Statement<'a>,
</span><span style="color:#323232;">  sysid: i64,
</span><span style="color:#323232;">  args: Vec<String>,
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">impl<'a> ZnsMaker<'a> {
</span><span style="color:#323232;">  pub fn init(
</span><span style="color:#323232;">    conn: &'a Connection,
</span><span style="color:#323232;">    user: i64,
</span><span style="color:#323232;">    search: &ZkNoteSearch,
</span><span style="color:#323232;">  ) -> Result<Self, Box<dyn Error>> {
</span><span style="color:#323232;">    let (sql, args) = build_sql(&conn, user, search.clone())?;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    let sysid = user_id(&conn, "system")?;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    Ok(ZnsMaker {
</span><span style="color:#323232;">      args: args,
</span><span style="color:#323232;">      sysid: sysid,
</span><span style="color:#323232;">      pstmt: conn.prepare(sql.as_str())?,
</span><span style="color:#323232;">    })
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">
</span><span style="color:#323232;">  pub fn make_stream(
</span><span style="color:#323232;">    &'a mut self,
</span><span style="color:#323232;">    conn: &'a Connection,  // have to pass the connection in here instead of storing in ZnsMaker, for Reasons.
</span><span style="color:#323232;">  ) -> Result<ZkNoteStream<'a, Result<ZkListNote, rusqlite::Error>>, rusqlite::Error> {
</span><span style="color:#323232;">    let sysid = self.sysid;
</span><span style="color:#323232;">    let rec_iter =
</span><span style="color:#323232;">      self
</span><span style="color:#323232;">        .pstmt
</span><span style="color:#323232;">        .query_map(rusqlite::params_from_iter(self.args.iter()), move |row| {
</span><span style="color:#323232;">          let id = row.get(0)?;
</span><span style="color:#323232;">          let sysids = get_sysids(&conn, sysid, id)?;
</span><span style="color:#323232;">          Ok(ZkListNote {
</span><span style="color:#323232;">            id: id,
</span><span style="color:#323232;">            title: row.get(1)?,
</span><span style="color:#323232;">            is_file: {
</span><span style="color:#323232;">              let wat: Option<i64> = row.get(2)?;
</span><span style="color:#323232;">              wat.is_some()
</span><span style="color:#323232;">            },
</span><span style="color:#323232;">            user: row.get(3)?,
</span><span style="color:#323232;">            createdate: row.get(4)?,
</span><span style="color:#323232;">            changeddate: row.get(5)?,
</span><span style="color:#323232;">            sysids: sysids,
</span><span style="color:#323232;">          })
</span><span style="color:#323232;">        })?;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    Ok(ZkNoteStream::<'a, Result<ZkListNote, rusqlite::Error>> {
</span><span style="color:#323232;">      rec_iter: Box::new(rec_iter),
</span><span style="color:#323232;">    })
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">}
</span>

Ok and here’s the handler function where I receive a query and make the ZnsMaker. But if I create a ZkNoteStream with it, I get a borrowing error. Maybe it would be ok if I immediately consumed it in an HttpResponse::Ok().streaming(znsstream). Got to fix the types first though.


<span style="color:#323232;">pub async fn zk_interface_loggedin_streaming(
</span><span style="color:#323232;">  config: &Config,
</span><span style="color:#323232;">  uid: i64,
</span><span style="color:#323232;">  msg: &UserMessage,
</span><span style="color:#323232;">) -> Result<HttpResponse, Box<dyn Error>> {
</span><span style="color:#323232;">  match msg.what.as_str() {
</span><span style="color:#323232;">    "searchzknotesstream" => {
</span><span style="color:#323232;">      let msgdata = Option::ok_or(msg.data.as_ref(), "malformed json data")?;
</span><span style="color:#323232;">      let search: ZkNoteSearch = serde_json::from_value(msgdata.clone())?;
</span><span style="color:#323232;">      let conn = sqldata::connection_open(config.orgauth_config.db.as_path())?;
</span><span style="color:#323232;">      let mut znsm = ZnsMaker::init(&conn, uid, &search)?;
</span><span style="color:#323232;">      {
</span><span style="color:#323232;">        // borrowed value of znsm doesn't live long enough!  wat do?
</span><span style="color:#323232;">        let znsstream = &znsm.make_stream(&conn)?;
</span><span style="color:#323232;">      }
</span><span style="color:#323232;">      Err("wat".into())
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">    wat => Err(format!("invalid 'what' code:'{}'", wat).into()),
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">}
</span>
pr06lefs,

So close! The problem is that query_map doesn’t consume pstmt, it only references it.


<span style="color:#323232;">Error[E0515]: cannot return value referencing local variable `pstmt`
</span><span style="color:#323232;">   --> server-lib/src/search.rs:191:5
</span><span style="color:#323232;">    |
</span><span style="color:#323232;">162 |         let rec_iter = pstmt.query_map(rusqlite::params_from_iter(args.iter()), move |row| {
</span><span style="color:#323232;">    |                        ----- `pstmt` is borrowed here
</span><span style="color:#323232;">...
</span><span style="color:#323232;">191 | /     Ok(ZkNoteStream {
</span><span style="color:#323232;">192 | |       rec_iter: Box::new(bytes_iter),
</span><span style="color:#323232;">193 | |     })
</span><span style="color:#323232;">    | |______^ returns a value referencing data owned by the current function
</span>

(bytes_iter is rec_iter run through some map()s)

pr06lefs,

Yep, gave that a try (I think!). Here’s that version.


<span style="color:#323232;">pub struct ZkNoteStream<'a> {
</span><span style="color:#323232;">  rec_iter: Box<dyn Iterator<Item = Bytes> + 'a>,
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">impl<'a> ZkNoteStream<'a> {
</span><span style="color:#323232;">  pub fn init(conn: Connection, user: i64, search: &ZkNoteSearch) -> Result<Self, Box<dyn Error>> {
</span><span style="color:#323232;">    let (sql, args) = build_sql(&conn, user, search.clone())?;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    let sysid = user_id(&conn, "system")?;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    let bytes_iter = {
</span><span style="color:#323232;">      let mut pstmt = conn.prepare(sql.as_str())?;
</span><span style="color:#323232;">      let rec_iter = pstmt.query_map(rusqlite::params_from_iter(args.iter()), move |row| {
</span><span style="color:#323232;">        let id = row.get(0)?;
</span><span style="color:#323232;">        Ok(ZkListNote {
</span><span style="color:#323232;">          id: id,
</span><span style="color:#323232;">          title: row.get(1)?,
</span><span style="color:#323232;">          is_file: {
</span><span style="color:#323232;">            let wat: Option<i64> = row.get(2)?;
</span><span style="color:#323232;">            wat.is_some()
</span><span style="color:#323232;">          },
</span><span style="color:#323232;">          user: row.get(3)?,
</span><span style="color:#323232;">          createdate: row.get(4)?,
</span><span style="color:#323232;">          changeddate: row.get(5)?,
</span><span style="color:#323232;">          sysids: Vec::new(),
</span><span style="color:#323232;">        })
</span><span style="color:#323232;">      })?;
</span><span style="color:#323232;">
</span><span style="color:#323232;">      let val_iter = rec_iter
</span><span style="color:#323232;">        .filter_map(|x| x.ok())
</span><span style="color:#323232;">        .map(|x| serde_json::to_value(x).map_err(|e| e.into()));
</span><span style="color:#323232;">
</span><span style="color:#323232;">      val_iter
</span><span style="color:#323232;">        .filter_map(|x: Result<serde_json::Value, orgauth::error::Error>| x.ok())
</span><span style="color:#323232;">        .map(|x| Bytes::from(x.to_string()))
</span><span style="color:#323232;">    };
</span><span style="color:#323232;">
</span><span style="color:#323232;">    Ok(ZkNoteStream {
</span><span style="color:#323232;">      rec_iter: Box::new(bytes_iter),
</span><span style="color:#323232;">    })
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">impl<'a> Stream for ZkNoteStream<'a> {
</span><span style="color:#323232;">  type Item = Bytes;
</span><span style="color:#323232;">
</span><span style="color:#323232;">  fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
</span><span style="color:#323232;">    Poll::Ready(self.rec_iter.next())
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">}
</span>

This gets two errors, one for the conn and one for the pstmt:


<span style="color:#323232;">error[E0515]: cannot return value referencing local variable `pstmt`
</span><span style="color:#323232;">   --> server-lib/src/search.rs:181:5
</span><span style="color:#323232;">    |
</span><span style="color:#323232;">153 |         let rec_iter = pstmt.query_map(rusqlite::params_from_iter(args.iter()), move |row| {
</span><span style="color:#323232;">    |                        ----- `pstmt` is borrowed here
</span><span style="color:#323232;">...
</span><span style="color:#323232;">181 | /     Ok(ZkNoteStream {
</span><span style="color:#323232;">182 | |       rec_iter: Box::new(bytes_iter),
</span><span style="color:#323232;">183 | |     })
</span><span style="color:#323232;">    | |______^ returns a value referencing data owned by the current function
</span><span style="color:#323232;">
</span><span style="color:#323232;">error[E0515]: cannot return value referencing function parameter `conn`
</span><span style="color:#323232;">   --> server-lib/src/search.rs:181:5
</span><span style="color:#323232;">    |
</span><span style="color:#323232;">152 |         let mut pstmt = conn.prepare(sql.as_str())?;
</span><span style="color:#323232;">    |                         ---- `conn` is borrowed here
</span><span style="color:#323232;">...
</span><span style="color:#323232;">181 | /     Ok(ZkNoteStream {
</span><span style="color:#323232;">182 | |       rec_iter: Box::new(bytes_iter),
</span><span style="color:#323232;">183 | |     })
</span><span style="color:#323232;">    | |______^ returns a value referencing data owned by the current function
</span>
pr06lefs,

The problem is that the return from the actix handler has to be HttpResult::Ok().stream(my_znsstream). Anything else in the function will get dropped before the HttpResult. So either the pstmt is somehow embedded in my_znsstream, or it doesn’t compile… : (

pr06lefs, (edited )

I’m not quite ready to give up, but its not looking good. One of the rusqlite maintainers issued this haiku-like missive:


<span style="color:#323232;">yeah you just have to collect
</span><span style="color:#323232;">you can't return that as an iterator
</span><span style="color:#323232;">it needs to borrow from the statement
</span>

Got to wondering how Vec does this interator-with-internal-state thing, and its with unsafe.

update from the maintainer on discord:


<span style="color:#323232;">fundamentally you're asking for a self-referential type. e.g. one field borrows from another field of the same struct. cant  be done without  unsafe
</span><span style="color:#323232;">very easy to have soundness holes even if you use unsafe
</span>
pr06lefs,

I’ve been looking into it a bit - not pinning per se but self referential. There’s a library called ouroboros that looks helpful. There’s even an example on github where someone uses rusqlite and ouroboros together.

So it seems like this should work:


<span style="color:#323232;">#[self_referencing]
</span><span style="color:#323232;">pub struct ZkNoteStream {
</span><span style="color:#323232;">  conn: Connection,
</span><span style="color:#323232;">  #[borrows(conn)]
</span><span style="color:#323232;">  pstmt: rusqlite::Statement<'this>,
</span><span style="color:#323232;">  #[borrows(mut pstmt)]
</span><span style="color:#323232;">  #[covariant]
</span><span style="color:#323232;">  rec_iter: rusqlite::Rows<'this>,
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">impl ZkNoteStream {
</span><span style="color:#323232;">  pub fn init(conn: Connection, user: i64, search: &ZkNoteSearch) -> Result<Self, Box<dyn Error>> {
</span><span style="color:#323232;">    let (sql, args) = build_sql(&conn, user, search.clone())?;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    Ok(
</span><span style="color:#323232;">      ZkNoteStreamTryBuilder {
</span><span style="color:#323232;">        conn: conn,
</span><span style="color:#323232;">        pstmt_builder: |conn: &Connection| conn.prepare(sql.as_str()),
</span><span style="color:#323232;">        rec_iter_builder: |pstmt: &mut rusqlite::Statement<'_>| {
</span><span style="color:#323232;">          pstmt.query(rusqlite::params_from_iter(args.iter()))
</span><span style="color:#323232;">        },
</span><span style="color:#323232;">      }
</span><span style="color:#323232;">      .try_build()?,
</span><span style="color:#323232;">    )
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">}
</span>

Unfortunately I get this:


<span style="color:#323232;">error[E0597]: `pstmt` does not live long enough
</span><span style="color:#323232;">   --> server-lib/src/search.rs:880:1
</span><span style="color:#323232;">    |
</span><span style="color:#323232;">880 | #[self_referencing]
</span><span style="color:#323232;">    | ^^^^^^^^^^^^^^^^^^-
</span><span style="color:#323232;">    | |                 |
</span><span style="color:#323232;">    | |                 `pstmt` dropped here while still borrowed
</span><span style="color:#323232;">    | |                 borrow might be used here, when `pstmt` is dropped and runs the `Drop` code for type `Statement`
</span><span style="color:#323232;">    | borrowed value does not live long enough
</span><span style="color:#323232;">    |
</span><span style="color:#323232;">    = note: this error originates in the attribute macro `self_referencing` (in Nightly builds, run with -Z macro-backtrace for more info)
</span>

So close! But no cigar so far. No idea why its complaining.

pr06lefs,

Got this solved over on the rust-lang discourse. The solution was to use the async_stream crate. Ends up being a small amount of code too.

pr06lefs,

nixos + xmonad + xfce-no-desktop here. Its not for noobs perhaps but so stable and confidence inspiring.

Query about your linux daily drivers?

So i have my main system, i have been running NixOS on for over a year. It has been a pleasure to daily drive. And ive recently been playing with gentoo and funtoo. And althought alot of information, which is somewhat overwhelming but is slowly growing on me and making me appreatate linux as a whole. So i was wondring what other...

pr06lefs,

Pretty happy with my Dell precision 5520 with nixos. Except that the oem batteries swell up, but a lower capacity 3rd party battery is fine. I’m going to be looking at the snapdragon x elite laptops when they come out next year

pr06lefs,

Lately I’ve been more conscious of my decisions to watch trash on you tube. You watch a few traffic cam videos and pretty soon that’s half your feed. So I’m finding myself thinking twice before clicking.

Shorts I mostly avoid because I feel that feature is toxic clickbait.

Americans of Lemmy, what is your approach to next year's election?

2020 was… truly unique. It was so hard to stay away from doom scrolling, and I (and many others) were pretty disillusioned by the sad fact that so much of our country legitimately supported the Orange Man. I didn’t get a wink of sleep the night of the election because I genuinely considered it to be a make or break decision...

pr06lefs,

Fucking democrat all the way. Primaries I’ll vote for the less corporate candidates. The republican party is fascists and traitors.

pr06lefs,

I’d just peel it off and maybe rub it with my finger to get rid of leftover adhesive.

8 dead in crash after police chased a suspected human smuggler, Texas officials say (apnews.com)

The crash happened around 6:30 a.m. when the driver of a 2009 Honda Civic tried to outrun deputies from the Zavala County Sheriff’s Office and attempted to pass a semi truck, the state Department of Public Safety said. The Civic collided with a 2015 Chevrolet Equinox, which caught fire....

pr06lefs,

Or else what? Extra vacation?

pr06lefs,

Sounds like he shouldn’t have been near the robot while it was active. Normally robots in factories will operate inside a cage or in a limited access area. They want the robots moving as fast as possible for productivity, and you don’t want to be near that.

pr06lefs,

The Qualcomm x elite benchmarks as faster than the M3 for multicore. Not too surprising as I think it’s 12 cores vs 10. For single core its something like 2700 vs 3200.

Laptops running x elite are supposed to be available mid 2024.

Thermal Spray Coating Oil Gas Market is Projected to reach USD 574 Billion by 2032

The global thermal spray coating market in the oil and gas sector had a total value of USD 292 billion in 2022. It is anticipated to grow to USD 574 billion by 2032, with a robust compound annual growth rate (CAGR) of 7.8% throughout the forecast period. A primary driver of this revenue surge is the increasing demand for safe,...

pr06lefs,

Reads like ai generated junk

pr06lefs,

I dunno about the qualilty but I do yt-dlp -x and it downloads and extracts just the audio portion.

pr06lefs,

I use nextcloud, thunderbird, and on android caldav-sync and simple calendar pro.

Its all fine for personal use, but nextcloud with a team is not great. Want to have an event and invite the whole team? Add then one by one. Want to see how many people are coming to the event? I guess ask them?

pr06lefs,

IPC standing for Inter Process Communication in this instance.

pr06lefs,

I find it annoying when an article contains ATANE.

The Best PeerTube Frontends are Mastodon and Lemmy

The fascinating thing about PeerTube right now is that the frontend experience actually seems to be best on other services. This is primarily because discoverability between instances is fairly poor due to both federation mechanics and due to the nature of bootstrapping social. Because Lemmy and Mastodon feature their own human...

pr06lefs,

I’m using a lemmy app on my phone. When I click the above links I get a ‘format error’. If I put the addresses into search I just get this post and a few similar posts, not any peertube content.

pr06lefs,

My particular one is Liftoff. Issue filed!

The Paperweight Dilemma: Original Pinephone might lose future kernel updates if devs can't pay down tech debt (blog.mobian.org)

I think I’m reading this blogpost correctly: Mobian devs working on maintaining Linux kernel support for Pinephone painted themselves into a corner with tech debt, and may not be able to continue porting new kernel updates. Pinephone Pro runs a different chipset with wider community support, so it’s not affected....

pr06lefs,

The pinephone is cool but so underpowered. Hoping to get some use out of of it as a audio looper controller. Looks like I can anticipate a sharp drop in support in the next year or two.

pr06lefs,

Wow turns out loan forgiveness is a great idea after all! For corrupt republican shitbags.

pr06lefs,

unfortunately my control over how youtube works is quite limited

pr06lefs,

I like their directory page. Presumably that shows current live streams from different instances. Having one place to go to see all streams seems key, casual viewers will not visit lots of different instances looking for streams.

pr06lefs,

People get scared because they think they are in danger. The delivery driver didn’t know where things were going to stop in this encounter, and I don’t blame him one bit for putting a stop to it before he got beaten or stabbed.

But if the delivery driver wasn’t scared it wouldn’t have been a fun prank for mr 6 foot 5 and his dimwit subscribers. He relies on intimidation to get away with his shenanigans, if he wasn’t so physically threatening he would have had his ass beat before now, and deservedly so. Fuck that guy.

pr06lefs,

People have a legitimate right to defend themselves. For instance waking up to an unannounced armed intruder in your house justifies the use of force. In this case an unhinged large crazy person was actually harassing someone in a threatening way. They weren’t going about their business with a hoodie on, or delivering a pizza. The court agreed with the defendant that it was a self defense situation and so do I.

Did we kill Linux's killer feature?

A few years ago we were able to upgrade everything (OS and Apps) using a single command. I remember this was something we boasted about when talking to Windows and Mac fans. It was such an amazing feature. Something that users of proprietary systems hadn’t even heard about. We had this on desktops before things like Apple’s...

pr06lefs,

Nixos got this and then some

pr06lefs,

Wake me up when Catholics aren’t forced-birth advocates that will vote in any fascist that aligns with their single issue.

pr06lefs, (edited )

So why not disable images, including thumbnails? Wouldn’t that solve it? Imgur was created because reddit didn’t host images.

Is anyone using NixOS as their daily driver?

I’m currently running Arch and it’s great, but I’m noticing I’m not staying on the ball in regards to updates. I’ve been reading a bit about Nix and NixOS and thinking of trying it as my daily driver. I’ve got a Lenovo x1 xtreme laptop, I don’t do much gaming (except OSRS), use firefox, jetbrains stuff, bitwarden,...

pr06lefs,

Regular nixos user here. Also failed on pinebook nixos, then bricked it trying to install something else. Ah well, seemed like it would be a cool machine.

pr06lefs,

Its been a while since I did it. I needed towboot but you couldn’t install that with the default distro, then I tried installing another distro and now it doesn’t even show an LED when I plug it in. Is it flash, is it something else? Dunno. Just hasn’t been enough of a priority for me to spend more time on it.

pr06lefs,

A feature in my book! 😄

pr06lefs,

Not really digging the dragging windows with the mouse bit. Hopefully will be workable with keyboard only.

pr06lefs,

hate searches. “What about this ungodly Barbie movie my pastor told me to hate”

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • KamenRider
  • TheResearchGuardian
  • KbinCafe
  • Socialism
  • oklahoma
  • SuperSentai
  • feritale
  • All magazines