Skip to content

Instantly share code, notes, and snippets.

View sp90's full-sized avatar
🦜
Focusing

Simon sp90

🦜
Focusing
View GitHub Profile
@sp90
sp90 / _available-phosphor-icons.json
Last active January 4, 2024 12:35
Generate sub set of the phosphor icon font to transfer less bytes
{
"__FYI__": "THIS FILE IS USED TO GENERATING A SUBFONT ON PHOSPHOR ICONS",
"address-book": "e900",
"airplane": "e901",
"airplane-in-flight": "e902",
"airplane-landing": "e903",
"airplane-takeoff": "e904",
"airplane-tilt": "e905",
"airplay": "e906",
"air-traffic-control": "e907",
@sp90
sp90 / auth.state.ts
Created November 17, 2023 13:16
Auth state example - angular v17
@Injectable({
providedIn: 'root',
})
export class AuthState {
private authService = inject(AuthService);
private router = inject(Router);
private tokenStorage = localStorage.get('token') ?? null;
private activeUserStorage = JSON.parse(localStorage.get('activeUser')) ?? {};
private isLoggedIn = signal<boolean>(this.tokenStorage ? true : false);
@sp90
sp90 / expansion-example.html
Created November 16, 2023 10:05
Angular material expansion panel lazy load on expand using the angular v17 control flow
<mat-accordion>
@for (some of someArr; track some.id) {
<mat-expansion-panel #mep="matExpansionPanel">
<mat-expansion-panel-header>
<mat-panel-title>
{{ some.title }}
</mat-panel-title>
</mat-expansion-panel-header>
@defer (when mep.expanded) {
@sp90
sp90 / app.config.ts
Created September 18, 2023 12:12
Workaround to have withViewTransitions() running on your angular/ssr server
export const baseAppConfig: ApplicationConfig = {
providers: [
provideRouter(routes, withComponentInputBinding())
],
};
export const appConfig: ApplicationConfig = mergeApplicationConfig(baseAppConfig, {
providers: [provideRouter(routes, withComponentInputBinding(), withViewTransitions())]
});
@sp90
sp90 / Dockerfile
Created September 18, 2023 11:24
Temp solution for sharp bun docker
# 2 Stage build install sharp using npm
FROM node:20-bullseye-slim as installSharp
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm i sharp
# Install all deps using bun and copy the
# sharp install from first stage
FROM oven/bun as base
@sp90
sp90 / Dockerfile
Last active July 7, 2023 08:15
Digitalocean app platform dockerfile node 20
FROM node:20 as base
# Create app directory
WORKDIR /app
# Copy lock files
COPY package.json bun.lockb package-lock.json ./
# Install app dependencies
RUN npm ci
@sp90
sp90 / user-icon.component.html
Last active April 11, 2023 21:38
How i would use angular
<pre>{{ user$ | async | json }}</pre>
@sp90
sp90 / custom-validators.ts
Last active March 2, 2023 10:20
Conditional Angular Reactive Form
import { ValidatorFn } from '@angular/forms';
export type BooleanFn = () => boolean;
export function conditionalValidator(
predicate: BooleanFn,
validator: ValidatorFn,
errorNamespace?: string
): ValidatorFn {
return (formControl) => {
@sp90
sp90 / lazy-console.log.json
Last active January 20, 2023 10:13
VScode snippet so when you write log and hit "tab" then you get a console log with multiple cursors
{
"Print to console": {
"prefix": "log",
"body": ["console.log('$1: ', $1);", "$2"],
"description": "Log output to console"
}
}
@sp90
sp90 / angular-cli-node-js-typescript-rxjs-compatiblity-matrix.csv
Created September 4, 2022 19:05 — forked from LayZeeDK/angular-cli-node-js-typescript-rxjs-compatiblity-matrix.csv
Angular CLI, Angular, Node.js, TypeScript, and RxJS version compatibility matrix. Based on changelogs, metadata, and hands-on experience. Major Node.js and RxJS versions above officially supported versions are not listed. Note that minor TypeScript versions also contain breaking changes.
Angular CLI version Angular version Node.js version TypeScript version RxJS version
1.0.0-beta.17 (package name: angular-cli) ~2.0.2 ^6.9.5 ~2.0.10 ^5.0.3
1.0.0-beta.20-1 (package name: angular-cli) ~2.1.2 ^6.9.5 ~2.0.10 ^5.0.3
1.0.0-beta.22-1 (package name: angular-cli) ~2.2.4 ^6.9.5 ~2.0.10 ^5.0.3
1.0.0-beta.30 ~2.3.1 ^6.9.5 ~2.0.10 ^5.0.3
1.0.0-rc.4 ~2.4.10 ^6.9.5 ~2.0.10 ^5.0.3
~1.0.6 >= 4.0.3 <= 4.1.3 ^6.9.5 ~2.2.2 ^5.0.3
~1.1.3 >= 4.0.3 <= 4.1.3 ^6.9.5 ~2.3.4 ^5.0.3
~1.2.7 >= 4.0.3 <= 4.1.3 ^6.9.5 ~2.3.4 ^5.0.3
~1.3.2 >= 4.2.6 <= 4.4.7 ^6.9.5 ~2.4.2 ^5.0.3