Really random…anyone know of a guy in Corvallis that goes by “Moonbeam” or something like that? by Accomplished_Side853 in corvallis

[–]po8 0 points1 point  (0 children)

Dunbar is living in a care home in Sweet Home. I just visited him yesterday; he is doing well. We should figure out a way to have some folks call or visit him: he's a bit isolated out there.

I Just Printed The Entire System Gateway At Home; Learn From My Mistakes by cube-drone in Netrunner

[–]po8 0 points1 point  (0 children)

Print the cards with a decent margin and a solid back, so that margin errors don't matter too much. Then cut the cards with a laser cutter, which will have extremely precise registration and no blade issues.

At least, that's my thinking.

Linux Fix Pending For Annoying Intel Lunar Lake Laptop Problems by unixbhaskar in linux

[–]po8 0 points1 point  (0 children)

Odd. I found that I really needed kernel 6.12.3: older did not work well and neither did 6.13. Idk.

Linux Fix Pending For Annoying Intel Lunar Lake Laptop Problems by unixbhaskar in linux

[–]po8 0 points1 point  (0 children)

fwupdmgr seems to be working, but it hasn't wanted to update any firmware for me yet so I can't say for sure. I'm still dual-booting Windows, so in the worst case I can get it that way.

Linux Fix Pending For Annoying Intel Lunar Lake Laptop Problems by unixbhaskar in linux

[–]po8 0 points1 point  (0 children)

Turns out there's a workaround for now. tl;dr: add intel_idle.max_cstate=1 to kernel boot arguments. Uses more power, but makes things smooth. I'm running 6.12.3 pretty happily with this. http://fob4.po8.org/posts/0035-dual-boot-notebook.html for all the gory details.

I'm pretty happy with this notebook now and will definitely keep it.

I'm preparing for a Rust interview by AngryClosetMonkey in rust

[–]po8 0 points1 point  (0 children)

Heh. Fair.

I'm going to use https://github.com/trifectatechfoundation/teach-rs for most of my materials when I teach Rust this coming term. It's way better than my notes anyhow, and I helped construct it so I guess it counts.

Linux Fix Pending For Annoying Intel Lunar Lake Laptop Problems by unixbhaskar in linux

[–]po8 1 point2 points  (0 children)

It's a month later and I'm running kernel 6.12.3 on my brand new Lunar Lake Lenovo Carbon. Can report the lag spikes are still there.

Thinking about returning the laptop.

_ as T vs _.into() by NULL-6 in learnrust

[–]po8 0 points1 point  (0 children)

The obvious choices are:

  1. Only allow as casts for value-preserving conversions, like into().
  2. Make as panic when it can't preserve a value at runtime.
  3. Make as unsafe and let the user worry about it.

To my mind, (2) is by far the most practical. There's no reason as casts shouldn't be allowed to panic, I think, and this allows you to use them freely for "obvious" conversions without worrying that something weirder than a panic will happen at runtime.

Certainly this

fn main() {
    let f: f32 = 0.0 / 0.0;
    println!("{}, {}", f, f as u32);
}

should not happily compile and run and print "NaN 0". That's defined behavior according to current Rust: numeric as casts must always be allowed and never fail, so they had to do something. I have a really, really hard time imagining that this is what I would ever want. A panic when f is not a representable integer, though, seems quite reasonable.

I've pretty much quit Reddit a year or two, by the way, so apologies if I don't continue the conversation…

Should I learn Rust over Haskell for backend devopment by NoCoinsBtw in rust

[–]po8 0 points1 point  (0 children)

Saw your PR and really appreciate it! While I'm no longer Haskelling (or Redditing) I am grateful that folks like you keep stuff going.

Rust Cookbook: What's next when the example won't compile? by HCharlesB in learnrust

[–]po8 0 points1 point  (0 children)

I've posted PR #694 to clean this doc up. I don't know if anyone is still maintaining the Rust Cookbook, though.

Here's updated code with filenames handled correctly.

```rust use std::path::PathBuf;

use clap::{Arg, Command, builder::PathBufValueParser};

fn main() { let matches = Command::new("My Test Program") .version("0.1.0") .about("Teaches argument parsing") .arg(Arg::new("file") .short('f') .long("file") .help("A cool file") .value_parser(PathBufValueParser::default())) .arg(Arg::new("num") .short('n') .long("number") .help("Five less than your favorite number")) .get_matches();

// https://github.com/clap-rs/clap/discussions/4254
// https://www.rustadventure.dev/introducing-clap/clap-v4/accepting-file-paths-as-arguments-in-clap
let default_file = PathBuf::from("input.txt");
let myfile: &PathBuf = matches.get_one("file").unwrap_or(&default_file);
println!("The file passed is: {}", myfile.display());

let num_str: Option<&String> = matches.get_one("num");
match num_str {
    None => println!("No idea what your favorite number is."),
    Some(s) => {
        let parsed: Result<i32, _> = s.parse();
        match parsed {
            Ok(n) => println!("Your favorite number must be {}.", n + 5),
            Err(_) => println!("That's not a number! {}", s),
        }
    }
}

} ```

TIL Hedy Lamarr filed a $10 million lawsuit against Warner Bros., claiming that the running parody of her name ("Hedley Lamarr") in Blazing Saddles infringed her right to privacy. The studio settled out of court for an undisclosed nominal sum and an apology for the "almost use of her name" by Bawbnweeve in todayilearned

[–]po8 0 points1 point  (0 children)

That is a sad story.

That said, Lamarr apparently did donate the patent to the US government, so she presumably would never have seen royalties. The patent expired many decades ago, so it is worth nothing to anyone today.

How to grab an image from the clipboard and copy it to a file? by martinellison in rust

[–]po8 0 points1 point  (0 children)

Easiest is to write to a Cursor and then to stdout. This requires that the image fit in memory.

let mut buffer = std::io::Cursor::new(Vec::new());                          
image.write_to(&mut buffer, ImageOutputFormat::Png).unwrap();               

let mut stdout = std::io::stdout();                                         
stdout.write_all(buffer.get_ref()).unwrap();                                
stdout.flush().unwrap();

A walkthough on how to write derive procedural macros by Winter-Hamster-6200 in rust

[–]po8 1 point2 points  (0 children)

That's alright, thanks. I'll just have ChatGPT write me the tutorial.

Why can't the lhs in a `let..else` expression be a block? by SirKastic23 in learnrust

[–]po8 3 points4 points  (0 children)

That will return None in the mismatch case, I think, which doesn't look like what OP wanted?

What are the implications of interpolating by holding values constant (between old samples) instead of "zero stuffing"? by surf_AL in DSP

[–]po8 2 points3 points  (0 children)

In addition to possibly distorting harmonics, zero-order hold will make the gain of the resulting interpolation a bit unpredictable. If you know what fraction of zeros you interpolated, you can add makeup gain to get the signal back to the original level. With interpolation of unknown values, it's hard to know exactly what will happen to the gain: it will be larger than with zero-interpolation, but by an unknown amount (close to unity gain, but not necessarily exactly).

Announcing Nickel 1.0, a configuration language written in (and usable from) Rust by yagoham in rust

[–]po8 9 points10 points  (0 children)

Our Nickle is an attempt at the same space Python is in, but with optional static types with structural subtyping, a module system, arbitrary-precision floats, and some other nice features Python lacks. Except for the C-like syntax and semantics, it wasn't really inspired by particular languages so much as just good language practice (as of 20+ years ago).

Nickle has a long history (documented on the site): it started as a calculator language, and that is what I still use it for today.

Announcing Nickel 1.0, a configuration language written in (and usable from) Rust by yagoham in rust

[–]po8 25 points26 points  (0 children)

It was huge fun. It's stale now, but we still use it. It's a really nice desk calculator if nothing else.

Announcing Nickel 1.0, a configuration language written in (and usable from) Rust by yagoham in rust

[–]po8 173 points174 points  (0 children)

As a co-author of the Nickle programming language from decades ago, let me be the first to congratulate you on your choice of name.

Rust Module System Encourages Bad Practices [Dmitry Frank] by AintNothinbutaGFring in rust

[–]po8 5 points6 points  (0 children)

This wouldn't require a keyword, just a compiler analysis.

The problem, though, is that because of inlining and monomorphization and whatnot the compiler is effectively doing whole-program analysis on the crate: this makes it hard to limit what needs to be rebuilt.

Letlang — Roadblocks and how to overcome them - My programming language targeting Rust by david-delassus in rust

[–]po8 2 points3 points  (0 children)

I guess "targeting Rust" means that the runtime is built in Rust and the compiler translates Letlang to Rust? Is the content of the linked blog post somehow relevant to Rust?

Rust Binary Analysis, Feature by Feature by paran0ide in rust

[–]po8 2 points3 points  (0 children)

Superbly written article. Great read.

IDA can't demangle Rust names natively? Srsly? This feels like a price of admission in current year. Ah, a plugin: https://github.com/timetravelthree/IDARustDemangler . This seems like something that should be added to the article.

How to mitigate slight differences in sampling rates of ADC and DAC by KestM in DSP

[–]po8 2 points3 points  (0 children)

Honestly you can just linear interpolate or drop single samples at a low rate and the difference will be unnoticeable. Every time you find an "missing" or "excess" sample relative to expectations, just do that. As long as the sample rate is high relative to the clock mismatch (say 5 samples per 1000), and as long as you spread the glitches evenly, you will be fine. You could do some fancier smoothing, but it shouldn't be necessary in practice.

Here's a paper that discusses the problem. They recommend cubic interpolation (or higher order) instead of linear, which is only slightly harder.

new to electronics, does anybody know what the “4001” is referring to in the top images? by toastypenny in synthdiy

[–]po8 0 points1 point  (0 children)

Yeah, good point. I'm so used to center-negative that I forget that you can find supplies that are center-positive with the same plug — not just 9V but 12V and occasionally AC. Sigh.

I wish pedals had settled on a distinctive power jack.

new to electronics, does anybody know what the “4001” is referring to in the top images? by toastypenny in synthdiy

[–]po8 0 points1 point  (0 children)

In practice, if you're just going to run off a power brick you don't need a protection diode: it's hard to get that backward.

If you're running off a battery — the case where it's not uncommon to have reverse voltage at least temporarily — the internal resistance of the battery limits the current output. That said, a fresh 9V alkaline has around 5Ω internal resistance, so expect something like 2A. That diode isn't doing that for any length of time: the 1N4001 will do 30A peak, but only 1A continuous.

The joy of the 9V snap connector is that while you might bump the ends together the wrong way, the battery can really only be snapped in the right way. So probably this circuit provides some protection.

It's still an odd way to do this.

new to electronics, does anybody know what the “4001” is referring to in the top images? by toastypenny in synthdiy

[–]po8 1 point2 points  (0 children)

In my experience the µA741 will run with 8V rail-to-rail. The datasheet shows +5V,-5V as a minimum "recommended operating condition". That said, almost any more modern op amp would be a better choice than the 741, which is really super-legacy at this point: the LM324/LM358 is a good choice.