jstrong

u/jstrong


r/Amtrak•

boarded the new acela this morning and could not get my linux laptop to connect to wifi. I was connected to the wifi router but DNS wasn't working and I couldn't determine what the IP address of the login page was. It turned out to be 100.64.1.2 (ie go to https://100.64.1.2 in your browser. Port 80 does not respond you need to access port 443 and ignore the SSL warning).

Once I was logged in I was connected to the Internet but my DNS settings did not get fixed automatically, so I had to override with 1.1.1.1 as my DNS server.

Hope this helps someone save an hour of their life.

143

r/rust•

playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5639912d5046e1c6818ce9c8b05fe45f

I am trying to implement a struct that can stores a future (i.e. implements std::future::Future) as a field and also holds some state about the future it wraps. I would like the wrapper type to implement Future and "delegate" the poll call to the member field.

My initial implementation of this did not compile, and after looking at how some libraries do similar things (e.g. Either type in futures-util) it appears they used Pin::get_unchecked_mut + Pin::new_unchecked to get a Pin<

710

r/10s•

Got my racquets back from the stringer today, and ended up breaking the strings on one of them less than 30min into the session. Is that just something that can happen, or a sign that the stringing wasn't done correctly? I mostly replace my strings after about 4 weeks, playing 3-4 times a week, and don't usually even break them over that stint.

515

r/10s•

My friend let me try a Yonex Vcore 97h (330g), and initially it felt great. He lent it to me and yesterday I used it for a 2h hitting session. My normal racquet is a Wislon Blade 98 16x19 v8, which I like quite a bit.

I love how the heavier Yonex feels when I hit the ball, and the pace and spin I can generate with it. But the additional weight is a bit unwieldy and requires quite a bit more energy to use. I think I may have played better with it, but had less fun doing so.

My question is: would I quickly get used to hitting with the heavier racquet? For those who moved to a heavier racquet in the past, what was the transition like? Did you only do so (and would only recommend it) when play

827

r/10s•

lets say that you've hit a shallow floater to your opponent and he's about to tee it up, deciding which side to go to. A lot of times I see players in this situation wait (or try to wait) until their opponent is committed, then "guess" to one side or the other, moving to it aggressively. in that case, if you guess right, you'd be in position to possibly get to it, and if not, well you were already a sitting duck anyway.

my question is, would it be unsportsmanlike ("hindrance") to fake or bluff moving to one side, triggering your opponent to decide to hit it to the other, and then reverse the movement in time to get to the side you deceived him into hitting towards?

if this is not cheating

713

r/PostgreSQL•

small, self-contained example of unique, case-insensitive index on the "name" column of a table:

create extension if not exists "pg_trgm";

create table things_with_unique_names(
    id serial,
    name text not null
);

create unique index unique_names_no_funny_stuff
    on things_with_unique_names(
        show_trgm(                                  -- makes the comparisons case-insensitive
            regexp_replace(name, '[-_\s]', '', 'g') -- remove punctuation - can assume we only need to handle dashes, underscores, and spaces
        )
    ); 

any suggestions on how this could be better? I don't have anything in mind, but found quite a

58

r/rustjerk•
$ curl -i https://shipyard.rs/ping

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 30
Connection: keep-alive
server: shipyard.rs/v0.27.3
cache-control: no-store, max-age=0
x-frame-options: DENY
vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
date: Thu, 01 Sep 2022 04:16:39 GMT
x-rust-evangelism-strike-force: engaged
x-runs-blazingly-fast: ✓
x-prevents-segfaults: ✓
x-guarantees-thread-safety: 💯

{"msg": "pong!","v":"0.27.3"}
1099

r/rust•

Hello, r/rust! I wanted to introduce you to a new project I have been working on for the past few months, Shipyard.rs: a new private crate registry service.

Shipyard.rs offers hosted private crate registries that work like Crates.io, but for proprietary or otherwise non-public crates.

The inspiration for Shipyard.rs is my experience building things in Rust. My day job is at Keyrock, a cryptocurrency market maker, where I work on a trading system built in Rust. I have been developing actively in the language since 2018.

A while back, I set up a private crate registry for personal projects, and the experience turned me into

4736

r/rust•

playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a68fed56bb6698c6a55f5a04b8b93358

I am running into a "conflicting implementations of trait" error for two closely related traits, both of which I want to have blanket Rc<RefCell<T>> impl for.

to explain the context a bit, one trait is for a single Feature, whereas the other, FeaturesGroup is for a set of features. Unfortunately, it is important to have both, and not just rely on, say, Vec<T> where T: Feature as there are often important optimizations from combining multiple features that are not possible as a set of independent objects.

the problem seems to stem from

84

r/rust•

I want a &mut [u8] with an arbitrary alignment for the purposes of writing to disk with O_DIRECT. rather than wrapping fixed-size arrays with a struct that is has a repr(align(..)) attribute and writing my output in chunks I came up with this. I have a lot of experience with safe rust but not as much with unsafe, and was hoping to get an extra pair of eyes on whether anything could go wrong with this code that I'm not expecting. I have nothing particular in mind, my current belief is this code is fine. if use of try_reserve feature is unexpected/confusing, purpose is to return an Err(..) in the event the memory isn't available to be allocated.

https://play.rust-lang.org/?version

2021

r/rust•

I ran into tihs error and don't know how to solve it:

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
   --> src/path/to/my/code.rs:155:50
    |
155 |         let xs: [T; 16] = unsafe { std::mem::transmute(xs) };
    |                                                  ^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: `[MaybeUninit<T>; 16]` (size can vary because of T)
    = note: target type: `[T; 16]` (size can vary because of T)

In this instance, I was converting code that previously created an fixed-size array of a specific type to instead create an array of a parameterized type, which has a trait defin

186

r/rust•

I've been on nightly for years but have so far not dipped my toe into const generics. If you've used it recently I'd love to hear about your experience. The current compiler warning that it's an "incomplete feature" scared me off earlier tonight when I would have otherwise used it. On my current project, it's ok to use nightly/unstable features but I can't afford to be slowed down with too many mysterious bugs or compiler crashes. Also, if there are pitfalls to avoid in structuring types that use the new features, that'd be great to hear, too. Thanks!

10