Skip to content

Instantly share code, notes, and snippets.

@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> = {
@oscarmarina
oscarmarina / getScrollableParent.js
Last active May 7, 2024 19:49
Returns the scroll parent of an element along a specified axis and the scroll size and client size.
/**
* Returns the scroll parent of an element along a specified axis and the scroll size and client size.
*
* @param {HTMLElement} el - The element to find the scroll parent of.
* @param {String} [axis='y'] - The axis to find the scroll parent for.
* @returns {Object} An object with the following properties:
* @property {HTMLElement} scrollParent - The scroll parent element.
* @property {Number} scrollParentSize - The size of the scroll parent along the specified axis.
* @property {Number} clientParentSize - The size of the scroll parent's client area along the specified axis.
*/
@MarkTechson
MarkTechson / use-syntax-angular-v12-example.scss
Last active July 5, 2021 21:07
Example of the USE Syntax
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Here's an example of the before and after.
// BEFORE
@mpalpha
mpalpha / ideamaker-end.gcode
Last active January 2, 2025 22:07
klipper 3d printer firmware printer.cfg for creativity elf corexy, mks robin nano v1.2, tmc2209 x5 uart over 2 wifi pins, orbiter extruder, phaetus dragonfly BMS hotend, bltouch, dual z align, no z endstops.
M221 T0 S100 ;reset flow
M104 S0 ;turn off hotend
M140 S0 ;turn off bed
M107 ;turn off fan
G91 ;set relative positioning
G1 E-1 F300 ;retract extruder slightly
G1 Z+150 E-5 X-20 Y-20 F9000.00 ;move z down, retract warm, move nozzle away
G28 X Y ;home x, y
M84 ;disable steppers
G90 ;reset absolute
@HELWATANY
HELWATANY / Webstorm64.vmoptions
Last active August 5, 2026 18:16
[Updated 2025] JetBrains Custom VM Options Configuration Optimized For High Performance... Works with all JetBrains IDEs... JDK 8.x+ Recommended....
# Make sure to modify "-Xms", "Xmx", "CICompilerCount", and "ParallelGCThreads" according to your PC hardware configuration...
# -------------------------------------------
# Memory Settings (High-Memory Workstation)
# -------------------------------------------
# Set the initial heap size (this reduces resizing overhead)
-Xms2048m
# Set the maximum heap size (adjust depending on your system; 2048m or 4096m is good for modern machines)
@Goobles
Goobles / combine-latest-properties.ts
Created April 14, 2020 17:30
combineLatestProperties
import { Observable, ObservableInput, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
export type ObservableReturnType<T> = T extends Observable<infer R> ? R : any;
export type ObjectWithObservableReturnTypes<T> = {
[P in keyof T]: ObservableReturnType<T[P]>
};
export function combineLatestProperties<TObj extends { [key: string]: ObservableInput<any> }>(observableObject: TObj): Observable<ObjectWithObservableReturnTypes<TObj>> {
@ServerlessBot
ServerlessBot / IAMCredentials.json
Last active January 11, 2026 11:53
Minimum credential set for Serverless Framework
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",
@twxia
twxia / getScrollableParent.js
Created January 5, 2018 03:41
Get Scrollable Parent
function getScrollParent(node) {
const isElement = node instanceof HTMLElement;
const overflowY = isElement && window.getComputedStyle(node).overflowY;
const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';
if (!node) {
return null;
} else if (isScrollable && node.scrollHeight >= node.clientHeight) {
return node;
}
@aginev
aginev / add-locale-ubuntu.md
Last active March 30, 2020 18:17
Add new locale at Ubuntu 16.04

First install the language pack

sudo apt-get install language-pack-bg

Add new locale

sudo locale-gen bg_BG
sudo locale-gen bg_BG.UTF-8
<?php
// Usage:
// $master=new WebSocket("localhost",12345);
// $master->callback = function($self, $user, $msg){
// $self->send($user->socket,$msg);
// };
require "CommandsAppBase.class.php";
require "WsRequest.class.php";