Skip to content

Instantly share code, notes, and snippets.

View mateja176's full-sized avatar
🏋️
Success lies beyond what people say you can't accomplish.

Mateja Petrovic mateja176

🏋️
Success lies beyond what people say you can't accomplish.
View GitHub Profile
  • HTML
    • HTML page
    • tags
    • semantic HTML
    • style tag
    • script tag
      • blocking: async+defer
    • form tag
      • input tag and variants
  • CSS
type RequiredKeys<O extends unknown> = {
// eslint-disable-next-line @typescript-eslint/ban-types
[Key in keyof O]: {} extends Pick<O, Key> ? never : Key;
}[keyof O];
type DeepPick<O extends unknown, Keys extends unknown[]> = Keys extends [
keyof O,
...infer Rest
]
? Keys[0] extends RequiredKeys<O>
const groupByProp = <P extends string, O extends { [Key in P]: string }>(
objects: O[],
prop: P,
) => {
return objects.reduce((groups, object) => {
const key = object[prop];
return { ...groups, [key]: (groups[key] ?? []).concat(object) };
}, {} as Record<O[P], O[]>);
};
type A = { a: 1; b: 2 };
type ObjectToArray<O> = {
[Key in keyof O]: [Key, O[Key]];
}[keyof O][];
type B = ObjectToArray<A>;
const entries = <O>(o: O): ObjectToArray<O> => {
const a: ObjectToArray<O> = [];
for (const key in o) {
const element = o[key];
choco install -y `
autohotkey `
brave `
copyq `
cpu-z `
crystaldiskinfo `
crystaldiskmark `
geforce-experience `
git `
gpu-z `
function christmasTree(n: number) {
let padding = n - 1;
for (let index = 1; index < n; index++) {
const oddNumber = index * 2 - 1;
console.log(' '.repeat(padding), '*'.repeat(oddNumber));
padding -= 1;
}
}