Skip to content

Instantly share code, notes, and snippets.

View sp90's full-sized avatar
🦜
Focusing

Simon sp90

🦜
Focusing
View GitHub Profile
@sp90
sp90 / build-angular-bun.log
Created September 23, 2024 09:13
Failed building angular log using bun 1.1.30-debug+2f8c20ef8
This file has been truncated, but you can view the full file.
[SYS] read(3[/MY_USER/Documents/dev/bun/build/debug/bun-debug], 4096) = 4096 (0.069ms)
[SYS] close(3[/MY_USER/Documents/dev/bun/build/debug/bun-debug])
[SYS] openat(-2, /MY_USER/Documents/dev/sparkle-ui/start) = -1
[SYS] openat(8[/MY_USER/Documents/dev/sparkle-ui], package.json) = 9
[fs] openat(8[/MY_USER/Documents/dev/sparkle-ui], /MY_USER/Documents/dev/sparkle-ui/package.json) = 9[/MY_USER/Documents/dev/sparkle-ui/package.json]
[SYS] close(9[/MY_USER/Documents/dev/sparkle-ui/package.json])
[alloc] new(PackageJSON) = src.resolver.package_json.PackageJSON@138f04080
[SYS] close(3[/])
[SYS] close(4[/Users])
[SYS] close(5[/MY_USER])
import { readFileSync, readdirSync, writeFileSync } from 'fs';
import { JSDOM } from 'jsdom';
import { parse } from 'marked';
import { join, resolve } from 'path';
import { Post } from './posts.const';
import hljs from 'highlight.js/lib/core';
// @ts-ignore
import css from 'highlight.js/lib/languages/css';
@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 / _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 / 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) => {