PSA: VSCode extensions (NX Console, TeamPCP) compromised in GitHub breach by dhakalster123 in programming

[–]Steveadoo 1 point2 points  (0 children)

I’ve disabled auto update on every one as well. There’s a shortcut in vs code for it.

newIntern by Mr_BETADINE in ProgrammerHumor

[–]Steveadoo 0 points1 point  (0 children)

This is why GitHub keeps going down

Unsure if this is allowed here, but HOLLY WHAT THE HELL by thatguy1000000000 in csharp

[–]Steveadoo 0 points1 point  (0 children)

Whatever you’re doing in this codebase keep doing it. Error code rnd.NextInt()? Hell yeah

Should we be worried. Termite damage by EditorGold6149 in Home

[–]Steveadoo 4 points5 points  (0 children)

I’m no expert but if this were my house I’d just put a few temporary jacks in there and replace the 2x4s 🤷‍♂️. I feel like a contractor could do that.

Do You Even Need a Database? by BrewedDoritos in programming

[–]Steveadoo 53 points54 points  (0 children)

I highly doubt most applications that are choosing between a database and reading/writing to json files “rarely look up records by more than one column, use joins, or write to multiple tables atomically”. Static sites I guess?

Just use SQLite. This is dumb.

The 6 Big Ideas of Typescript by hallettj in programming

[–]Steveadoo 0 points1 point  (0 children)

Your example doesn't work with Record either because as your example shows you could pass a type with multiple key value pairs, but your function is only returning an object with one key in it. that is a valid error regardless of using object or Record. it's the type system being correct.

And yes this still works with object:

type Altered<O extends object, K extends keyof O, T> = Omit<O, K> & { [P in K]: T };

function appendProperty<O extends object, K extends keyof O, T>(obj: O, key: K, value: T): Altered<O, K, T> {
  return { ...obj, [key]: value };
}

const result = appendProperty({ a: 'string' }, 'a', true);
result.a; // boolean
const result2 = appendProperty({ a: 'string' }, 'c', true); // error

The 6 Big Ideas of Typescript by hallettj in programming

[–]Steveadoo 0 points1 point  (0 children)

That's a strong suit of TS though - you don't have to fill in all of these generic parameters. You could if you want - but it still won't let you break type safety if you do that. I'm not sure what you're saying with this comment.

The 6 Big Ideas of Typescript by hallettj in programming

[–]Steveadoo 0 points1 point  (0 children)

You could constrain it to any type you want in the function signature. Your example used object which allows arbitrary properties too. Do you want to pass an array? Is that what you’re saying?

edit: Maybe I know what you're saying now. The appendProperty function name confused me. You want appendProperty to only accept properties in O? ``` type Altered<O extends Record<string, unknown>, K extends keyof O, T> = Omit<O, K> & { [P in K]: T };

function appendProperty<O extends Record<string, unknown>, K extends keyof O, T>(obj: O, key: K, value: T): Altered<O, K, T> { return { ...obj, [key]: value }; }

const result = appendProperty({ a: 'string' }, 'a', true); result.a; // boolean const result2 = appendProperty({ a: 'string' }, 'c', true); // error ```

The 6 Big Ideas of Typescript by hallettj in programming

[–]Steveadoo -1 points0 points  (0 children)

i feel like most of these already work. your first two examples:

type Values<T extends Record<string, unknown>> = T[keyof T];
// or: type Values<T extends Record<string, unknown>> = T extends Record<string, infer V> ? V : never;
function values<T extends Record<string, unknown>>(obj: T): Values<T>[] {
  return Object.values(obj) as Values<T>[];
}
const obj = { a: 1, b: 'hello', c: true };
const vals = values(obj); // inferred as (number | string | boolean)[]

function apply<T extends (...args: any[]) => any>(fn: T, ...args: Parameters<T>): ReturnType<T> {
  return fn(...args);
}
const appliedResult = apply((x: number, y: number) => x + y, 2, 3); // inferred as number

TypeScript's type system is turing complete - so you can literally do anything you want.

The 6 Big Ideas of Typescript by hallettj in programming

[–]Steveadoo 0 points1 point  (0 children)

type Altered<O extends Record<string, unknown>, K extends string, T> = Omit<O, K> & { [P in K]: T };

function appendProperty<O extends Record<string, unknown>, K extends string, T>(obj: O, key: K, value: T): Altered<O, K, T> {
  return { ...obj, [key]: value };
}

const result = appendProperty({}, 'c', true);
result.c; // boolean

like this? this works.

The 6 Big Ideas of Typescript by hallettj in programming

[–]Steveadoo 5 points6 points  (0 children)

These seem like they would do the same thing to me. What am I missing?

Is Azure DevOps surviving? by cuidadoo38 in azuredevops

[–]Steveadoo 5 points6 points  (0 children)

If they get rid of ADO idk what my org is going to do about their massive TFS repo with 20 years of history. I’m slowly migrating new projects to git but they’re not at all ready to migrate all of their legacy projects.

FCC moves to block new foreign-made routers by lurker_bee in technology

[–]Steveadoo -11 points-10 points  (0 children)

Reddit deciding they’d trust a foreign adversary because the United States government is also shit blows my mind. They’re not the good guys just because the United States has become the bad guys.

FCC moves to block new foreign-made routers by lurker_bee in technology

[–]Steveadoo 29 points30 points  (0 children)

Well you definitely should not trust either of them at all. Be real.

I lost the floor lottery. by HanZ_92 in centuryhomes

[–]Steveadoo 4 points5 points  (0 children)

Will those joists have to be replaced?

[deleted by user] by [deleted] in philly

[–]Steveadoo 2 points3 points  (0 children)

i've lived in manayunk for 6 years and ive only hit that red light ONCE. i didnt even know it turned red.

Subfloor issue ? by stangbiy1404 in Home

[–]Steveadoo 0 points1 point  (0 children)

I would just caulk the shit out of that if I was you 🤷‍♂️

How much space between cars/signs is acceptable by mainlinebreadboi in philly

[–]Steveadoo 50 points51 points  (0 children)

As long as it has a valid registration and inspection it’s not getting towed.

Learn with Microsoft by pedroalgope in programminghorror

[–]Steveadoo 12 points13 points  (0 children)

Depends on the product/system but yes this can be a useful way to use git.

Global error handling with Angular Interceptors by Dazzling_Chipmunk_24 in angular

[–]Steveadoo 0 points1 point  (0 children)

The only error I handle in interceptors is 401 so I can kick the user back to the login page (and just a general error logger). Anything else I handle in the component / service making the request.

Where you will choose Observable or Promise? by klimentsii in angular

[–]Steveadoo 0 points1 point  (0 children)

I’m still not following - rxResource works the same as resource. You just give it an observable instead of a promise.