Skip to content

Instantly share code, notes, and snippets.

View sp90's full-sized avatar
🦜
Focusing

Simon sp90

🦜
Focusing
View GitHub Profile
@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
@sp90
sp90 / _breakpoint.scss
Created May 20, 2021 11:45
Breakpoint mixin
/**
* $bp-mega: 2500px;
* $bp-mega: 1900px;
* $bp-kilo: 1360px;
* $bp-centi: 1024px;
* $bp-milli: 768px;
* $bp-nano: 480px;
*/
$breakpoint-map: (
import { of, BehaviorSubject } from 'rxjs';
import { fromFetch } from 'rxjs/fetch';
import { switchMap, catchError } from 'rxjs/operators';
interface CustomMethodInterface {
name: string;
endpoint: string;
method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
}
@sp90
sp90 / client.html
Created July 19, 2019 09:43
Simple karma testing client.html styling
<!DOCTYPE html>
<!--
The entry point for client. This file is loaded just once when the client is captured.
It contains socket.io and all the communication logic.
-->
<html>
<head>
<!-- %X_UA_COMPATIBLE% -->
<title>Karma</title>
<link href="favicon.ico" rel="icon" type="image/x-icon" />
@sp90
sp90 / chainable-methods.js
Last active July 9, 2019 14:11
A simple way of chaining methods
class klass {
constructor() {}
sum(...args) {
this.value = args.reduce((sum, current) => sum + current, 0);
return this;
}
add(value) {
@sp90
sp90 / Array-operations.js
Created March 20, 2019 08:18
Small subset of javascript operations on an array
let myArr = [0, 2, 5]
let arr2 = [1, 6, 7]
// Attach a value to the end of an array
myArr.push(6)
console.log(myArr) // [0, 2, 5, 6]
// Attach a value to the beginning of an array
myArr.unshift(3)
console.log(myArr) // [3, 0, 2, 5, 6]