Skip to content

Instantly share code, notes, and snippets.

View vorant94's full-sized avatar
🧑‍💻
Looking for an inspiration

Mordechai Dror vorant94

🧑‍💻
Looking for an inspiration
View GitHub Profile
interface Walkable {
walk(): void;
}
interface Flyable {
fly(): void;
}
class Dog implements Walkable {
walk() {
abstract class Animal {
abstract move(): void;
}
class Mammal extends Animal {
move() {
// Move in 2d space
}
}
@vorant94
vorant94 / app.component.ts
Created September 12, 2023 07:18
an example of how to load scripts in angular without polluting index.html
...
@Component({
...
})
export class AppComponent implements OnInit{
constructor(private readonly http: HttpClient) {
}
ngOnInit() {
export function* chunks<T>(values: T[], size = 1): Generator<T[]> {
for (let index = 0; index < values.length; index += size) {
yield values.slice(index, index + size);
}
}
@vorant94
vorant94 / Dockerfile
Last active September 7, 2023 11:11
passing secrets from gh action to docker builder
...
COPY package*.json ./
RUN --mount=type=secret,id=npmrc,target=/usr/local/app/.npmrc \
npm ci
...
import { filter, map, Observable, OperatorFunction } from 'rxjs';
export function nonNullable<T>(): OperatorFunction<T, NonNullable<T>> {
return function (source$: Observable<T>): Observable<NonNullable<T>> {
return source$.pipe(
filter(value => value != null),
map(value => value!)
);
};
}
export class Batches<T> implements Iterable<T[]> {
constructor(private values: T[], private size: number) {
}
[Symbol.iterator](): Iterator<T[]> {
return new BatchesIterator(this.values, this.size);
}
}
class BatchesIterator<T> implements Iterator<T[]> {