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 / migrate-material-buttons.js
Created March 25, 2025 21:19
A migration to migrate all material buttons to use the input for the appearance instead of the selector
const fs = require('fs').promises;
const path = require('path');
const { EOL } = require('os'); // End Of Line character
// --- Configuration ---
const PROJECT_ROOT = process.argv[2] || '.'; // Get project root from arg or use current dir
const EXCLUDE_DIRS = ['node_modules', '.angular', 'dist', 'e2e', 'coverage']; // Directories to skip
const HTML_SUFFIX = '.html';
const APPLY_CHANGES = process.argv.includes('--apply'); // Check for --apply flag
// --- End Configuration ---
@eneajaho
eneajaho / analyze-components.js
Created March 25, 2025 20:45
Check components on project if they are OnPush
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const ts = require('typescript'); // Requires 'npm install typescript'
// --- Configuration ---
const DEFAULT_PROJECT_PATH = '.'; // Default to current directory
const EXCLUDED_DIRS = ['node_modules', 'dist', '.angular', '.vscode', '.git']; // Directories to skip
const COMPONENT_FILE_SUFFIX = '.component.ts';
@eneajaho
eneajaho / install.sh
Created July 23, 2024 18:11 — forked from dinhquochan/install.sh
Install PHP 8.2, Composer, MySQL 8 for Laravel Development on Ubuntu 22.04
## PHP
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2-cli php8.2-dev php8.2-pgsql php8.2-sqlite3 php8.2-gd php8.2-imagick \
php8.2-curl php8.2-imap php8.2-mysql php8.2-mbstring php8.2-xml php8.2-zip \
php8.2-bcmath php8.2-soap php8.2-intl php8.2-readline php8.2-ldap php8.2-msgpack \
php8.2-igbinary php8.2-redis php8.2-memcache php8.2-pcov php8.2-xdebug
@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 May 12, 2024 07:25
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>,