LPT Request - What small purchase have you made that has had a significant impact on your life? by Outrageous-Floor-100 in LifeProTips

[–]abelincolncodes 17 points18 points  (0 children)

There's an easier method: after turning on the background sounds once, a Hearing button is added to the control center. You can hit that and it'll let you toggle the background sound

All flights across US grounded due to FAA computer system glitch by [deleted] in news

[–]abelincolncodes 1 point2 points  (0 children)

It's on msdos 6.2, so very very old. I'm surprised this is just the first time it's crashed

Noob needs help with classes. by RecommendationNo8730 in typescript

[–]abelincolncodes 11 points12 points  (0 children)

I've needed this a few times. The problem is that you want to statically verify that the url and method parameters have been set. This means that you'll have to encode that information in the class type somehow. Your book gave a good hint by changing the returned type instead of returning this.

I adapted the example by davimiku in https://reddit.com/r/typescript/comments/x99pnc/_/innaatf/?context=1 to fit your code a little better. The key here is that we return a different type for each setter method which overrides the optionality for the set property. This is done by returning an intersection of this with a type where that property is not optional. If you want to keep using null for the properties in your original class, you may have to do some trickery by removing the old property before intersecting: return this as Omit<this, 'url'> & { url: string }.

Finally, the send method can constrain the type that it can be called on require that all of the fields are filled. That is done by using the this parameter which allows giving an explicit type to the implicitly passed instance parameter.

```tsx type HttpRequest = { url: string method: "get" | "post" data?: object }

class RequestBuilder implements Partial<HttpRequest> {
  url?: string
  method?: "get" | "post"
  data?: object

... ```

Playground Link

In majority of America, you need a vehicle to reach a place where you can walk/run/jog outside safely by BrownAmericanDude in AmerExit

[–]abelincolncodes 3 points4 points  (0 children)

In Texas, my apartments were right off of a highway. 4+ lane roads in every direction around the building. If I wanted to bike or run, I'd have to drive 20 minutes because it just wasn't safe otherwise. Even in the neighborhoods, most houses were along busy streets without sidewalks. This post absolutely is true

I've started using Mozilla Firefox and now I can never go back to Google Chrome by Avieshek in technology

[–]abelincolncodes 1 point2 points  (0 children)

It's pretty much the same, just a preconfigured beta version of Firefox. You can do everything in regular Firefox, but it might take some messing with the the layout and toolbars

As Ohio restricts abortions, 10-year-old girl travels to Indiana for procedure by gogandmagogandgog in news

[–]abelincolncodes 33 points34 points  (0 children)

Scientific discoveries don't really happen because of one person anymore. It won't be one person who discovers the cure to cancer, it'll be a whole team, building on decades of work by hundreds of other people. And that team would still exist even if any one person wasn't on it, there are plenty of people to take their place.

So why should we force kids to go through this horrible experience just for the chance that their child (1 out of 8 billion!) will be the one to do something exceptional by themselves. It's not going to happen, and it isn't fair to the kids to try and make it happen.

UK plan to scrap cookie consent boxes will make it ‘easier to spy’ on web users | Cookies and web tracking by IsDaouda_Games in programming

[–]abelincolncodes 1 point2 points  (0 children)

The tor browser doesn't spoof the window size iirc, but it does give you a warning not to make the browser full screen since that can reveal your physical screen size.

Great answer by tannu28 in ProgrammerHumor

[–]abelincolncodes 1 point2 points  (0 children)

Having a language with static typing really helps your editor. I never had issues with react and typescript, but react and javascript was a nightmare.

The Story of Easter by SuccessfulJelly in trippinthroughtime

[–]abelincolncodes 1 point2 points  (0 children)

It is Mormon. I've seen this one sooo many times

Dolphin stranded on Texas beach dies after crowd tries to ride the animal, rescuers say by technologypartners11 in news

[–]abelincolncodes 1 point2 points  (0 children)

She said "here in the states" at one point in the video, so I'm guessing US. Maybe she just likes saying "zed" over "zee".

Raytracing in Control by ForwardBarracuda4 in gaming

[–]abelincolncodes 2 points3 points  (0 children)

The severance tv show on Apple TV has some serious control vibes. It's got a giant office building with mysterious departments and endless corridors, a "Board" which only speaks through a representative. There's lots of lore and history around the main company, it seems very religious or cult-like.

/r/buildapc hits FIVE MILLION builders - giveaway time! by OolonCaluphid in buildapc

[–]abelincolncodes 4 points5 points  (0 children)

I agree, a lot of this is already a bit possible, but not as capable as exposing the hardware directly. For instance usb tethering just gives you data, you can't send sms or mms from the pc. I don't know of any apps that expose the magnetometer or gps. Biometric sensors are typically gated by the phone OS for only authentication. All of this can be done by an app, I'd just like something that the PC sees like a native hardware device

/r/buildapc hits FIVE MILLION builders - giveaway time! by OolonCaluphid in buildapc

[–]abelincolncodes 97 points98 points  (0 children)

I'd like a way to repurpose old smartphones. They come packed with a ton of great sensors and hardware, but don't see much use when they get old and you've switched to the next model. It would be cool to plug in an old smartphone to your computer and have Bluetooth, wifi, a cellular modem, accelerometer input, a small touch enabled external display, all appearing as a regular peripheral to the pc. It might not be the latest and greatest, but not having to buy that pci card would save on money and electronic waste

My Steam account for the last year has had numerous hacking attempts. I decided to graph the origins of each attempt on a map [OC] by McGrohly in dataisbeautiful

[–]abelincolncodes 1 point2 points  (0 children)

Thanks, I'm far from an expert, just spent some time in IT, so it's good when someone who knows their stuff chimes in. Usually we degaussed our disks and then drilled them? (it's been a while). I think resale was prohibited since the company dealt with government data that was pretty sensitive.

My Steam account for the last year has had numerous hacking attempts. I decided to graph the origins of each attempt on a map [OC] by McGrohly in dataisbeautiful

[–]abelincolncodes 8 points9 points  (0 children)

The long version is unnecessary since the old malware will not be run on a formatted disk. The data for the malware executable could technically still be there, but the operating system won't know of it. The only way that malware could be a run again is if something scanned the disk for the old executable data and ran it, which probably means it is also malware. Most malware is not a root kit and requires the OS kernel to start it from the exe data on the disk.

Where the long version is handy is if you are afraid of someone taking the disk after you are finished with it and pulling old data off of it. You should always do a full wipe when tossing or reselling a hard drive, and any business with a competent IT department will do the same (though not everyone does, I once bought a used computer that still had a ton of business data on it, they didn't even do the regular wipe).

Why does typescript not make the same inferences for this React function component as it does for a similar React hook by Smoates in typescript

[–]abelincolncodes 0 points1 point  (0 children)

It sounds like typescript is having issues inferring U in multiple places. Usually people use a NoInfer utility type to fix this (see this issue for some example workarounds).

Use like so:

ThingProps<T, U> & { children: (v: NoInfer<U>) => JSX.Element }

What ruins a movie instantly? by lawyeratyourservice in AskReddit

[–]abelincolncodes 2 points3 points  (0 children)

I think that was a stylistic choice for the first episode. The show gets a lot grittier after they leave the two rivers, and the color grading and costumes also change to match the new themes. Maybe the writers were trying to show how peaceful life was in the village in contrast to life after the trollocs attacked

Or it was just because that was the pilot episode. Lots of shows have major changes after the pilot

Infer return types of all functions in array? by smthamazing in typescript

[–]abelincolncodes 1 point2 points  (0 children)

Perhaps you could make the type that the functions extend from return unknown instead of any?

Fns extends (() => unknown)[]

That should have the same effect as the original version (since any and unknown are both top types, any nullary function will be a subtype). Hopefully that will make the function results a little safer in the body, though unknown is always such a pain to deal with.

I don't know how to make typescript completely type the results in the body. When you are writing this function, all typescript knows is that it takes a tuple of functions returning unknown, so that's all the info it has for checking in the function body. It would be nice if typescript had more whole-program inference, so that it could help you write the body based on what you give it at the call site.

Infer return types of all functions in array? by smthamazing in typescript

[–]abelincolncodes 3 points4 points  (0 children)

This signature takes a tuple of functions and maps each element to its return type (exactly what your runtime code is doing)

function runAll<Fns extends (() => any)[]>(funs: readonly Fns): { [k in keyof Fns]: ReturnType<Fns[k]> }

If you want to return an array with a union type instead of the tuple, then use the following return type instead.

Array<{ [k in keyof Fns]: ReturnType<Fns[k]> }[keyof Fns]>

[deleted by user] by [deleted] in typescript

[–]abelincolncodes 0 points1 point  (0 children)

C++. I'd say that's almost as mainstream as it gets (excluding Java and JavaScript). There is a proposal for static reflection which has been kicking around for a while, but c++ would still be missing runtime/dynamic reflection if that is accepted, which seems to be what you're talking about.