Skip to content

Instantly share code, notes, and snippets.

View eneajaho's full-sized avatar
🏠
Working from home

Enea Jahollari eneajaho

🏠
Working from home
View GitHub Profile
@eneajaho
eneajaho / gist:52b16ca77648c31e856a6bde881e212e
Created March 29, 2024 22:06
Open ports 80 and 443 (http and https) ubuntu server
sudo iptables-legacy -I INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
sudo iptables-legacy -I INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
sudo iptables-legacy-save | sudo tee /etc/iptables/rules.v4
more info here
https://dev.to/armiedema/opening-up-port-80-and-443-for-oracle-cloud-servers-j35
https://stackoverflow.com/a/66148257/7220620
@eneajaho
eneajaho / what-forces-layout.md
Created October 25, 2023 08:01 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@eneajaho
eneajaho / mnlink.directive.ts
Created October 11, 2023 19:13
Router Link with external + internal links
@eneajaho
eneajaho / angular-snippets.json
Created September 25, 2023 17:26
angular-snippets.json
{
"Angular Standalone Single File Component": {
"prefix": "asfc",
"scope": "typescript",
"description": "Angular Standalone Single File Component",
"body": [
"import { Component, ChangeDetectionStrategy } from '@angular/core';",
"",
"@Component({",
"\tselector: 'app-${1:selector-name}',",
@eneajaho
eneajaho / computed-from.ts
Last active September 12, 2023 18:23
Chau's implementation of computedFrom
import { isSignal, Signal, untracked } from '@angular/core';
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
import { combineLatest, distinctUntilChanged, from, isObservable, ObservableInput, of, OperatorFunction, take } from 'rxjs';
export type ObservableSignalInput<T> = ObservableInput<T> | Signal<T>;
/**
* So that we can have `fn([Observable<A>, Signal<B>]): Observable<[A, B]>`
*/
type ObservableSignalInputTuple<T> = {
@eneajaho
eneajaho / computedFrom.ts
Last active August 21, 2023 11:01
Initial computedFrom impl
import { isSignal, signal, Signal } from '@angular/core';
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
import { combineLatest, distinctUntilChanged, from, interval, isObservable, Observable, ObservableInput, of, OperatorFunction } from 'rxjs';
export type ObservableSignalInput<T> = ObservableInput<T> | Signal<T>;
/**
* So that we can have `fn([Observable<A>, Signal<B>]): Observable<[A, B]>`
*/
@eneajaho
eneajaho / computed$.ts
Last active August 21, 2023 11:01
Initial computed$ implementation
import { Signal, isSignal } from "@angular/core";
import { toSignal, toObservable } from "@angular/core/rxjs-interop";
import { from, isObservable, Observable, ObservableInput, OperatorFunction } from "rxjs";
export function computed$<TValue, TReturn = TValue>(
signal: Signal<TValue>,
operator: OperatorFunction<TValue, TReturn>
): Signal<TReturn>;
export function computed$<TValue, TReturn = TValue>(
promise: Promise<TValue>,
@eneajaho
eneajaho / inject-destroy.ts
Created August 11, 2023 13:45
Inject Destroy
import { DestroyRef, inject } from '@angular/core';
import { ReplaySubject } from 'rxjs';
/**
* Injects the `DestroyRef` service and returns a `ReplaySubject` that emits
* when the component is destroyed.
*
* @throws {Error} If no `DestroyRef` is found.
* @returns {ReplaySubject<void>} A `ReplaySubject` that emits when the component is destroyed.
*
@eneajaho
eneajaho / settings.json
Last active December 14, 2023 20:21
My VSCode settings
{
"editor.fontWeight": 400,
"editor.fontSize": 16,
"editor.lineHeight": 2,
"editor.quickSuggestionsDelay": 0,
"editor.inlineSuggest.enabled": true,
"editor.bracketPairColorization.independentColorPoolPerBracketType": true,
"editor.foldingImportsByDefault": true,
@eneajaho
eneajaho / regenereate-cache.module.ts
Last active November 8, 2022 16:17
Vendure Admin Regenerate cache button
```ts
import { NgModule } from '@angular/core';
import { SharedModule, addActionBarItem } from '@vendure/admin-ui/core';
import { take } from 'rxjs/operators';
@NgModule({
imports: [ SharedModule ],
providers: [
addActionBarItem({
id: 'isr-regenerate-cache',