Skip to content

Instantly share code, notes, and snippets.

View tonivj5's full-sized avatar
👨‍🎓
Studying...

Toni Villena tonivj5

👨‍🎓
Studying...
View GitHub Profile
@trungvose
trungvose / nx-structure-angular-nestjs.md
Last active May 5, 2025 05:13
Nx workspace structure for NestJS and Angular

Nx

https://nx.dev/

Nx is a suite of powerful, extensible dev tools to help you architect, test, and build at any scale — integrating seamlessly with modern technologies and libraries while providing a robust CLI, caching, dependency management, and more.

It has first-class support for many frontend and backend technologies, so its documentation comes in multiple flavours.

Principles

@sindresorhus
sindresorhus / esm-package.md
Last active June 4, 2025 00:56
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@sastan
sastan / tailwind-to-css.js
Last active October 3, 2023 16:10
Extract CSS Object from Tailwind classes
import { create } from 'https://cdn.skypack.dev/twind'
const { tw: TW } = create({ preflight: false })
const tw = (...tokens) => {
let styles
TW(({ css }) => {
styles = css(...tokens)
styles._ = undefined
return ''
// Playground link: https://www.typescriptlang.org/play?#code/PTAEHEEsGcBdQG4FMBO1IHsB2AuUALWWAB2hxAHMZYA6K2fAVwCMaBjDAW2ACUelkaVMABMAZgCMbMQDYAHAFZFAQwAmCkWwAMSACwB2VXJHN98hQu1IFAWABQ92AE9iSUAFEAHkjYAeAMJcnMpYqtAANKAAyrDKsG4AvKAA3qBwymwA1ngA2gC6kQA2GGzKhWQpAL6glQB8oAn2oKCBnMGh0KBInvEdoDmQWABmqC1BIaqRNNODIyig-HB5TaAA-B7efouwkV4+re2qvjFxSJEHE7W1K3gn8QDc9o4ubgDygiiQqki+r8wAVpEAHLKThnUAANTKjCQ9SSILBXR6SD6cE+WAoaxSKxyAGlQINQAAKTJIJwYIagP7-ACUoAAPqAEUg8nh8d1emEmaC3OsoYUYaA8NS8aAAGTE0nkynUmnLOzVPBYASoR4OOzOVwQJCwfkw34A4E8uHcxEclFcqUUqkArEi5l5IWgZWCNXPLUAFUYxEKPyBSM5nSwjE4zFQkR4AYtnRCTnyDX6eRNPByAHJfRiGKnHea+v71pG8F6fX7IjlY1Npjwk267IN4ighhk3ECkBQgSGwyhfABBZidXNc4Oh1D1VLKihxSDIPB9zqVd0ttu+D0mj1RvNtjsj7uzUZz+rrOdO9eDoOd0brVvti-d1dOl2qp4al6gOcrtcbrnX7dd3x7+Y53vI9+3XIsv3PHcsTA50VRQWtNTcHtiB9JwokgCgsBXSIAAUMAHZE+mYDAMF9EITTwgjA1AWAUEFdYYOvD8ENfcAdXQzCPwTU9CO-Ldb18Ycu0PUAm3KNw8FomEWK1ABZRhCg4rCe0iAAhE0chU0BVJzXjOhyKTwUMx1GRyMToHBcyWSxQynSsmS3CiENf1QXsIOdW81PcoTRwTHJphoYtfV7WpK0C71gvUvI0wzCgs0dCUfPg59EOiFggp+Ht3NjfIvLPUAcq
@ryandabler
ryandabler / Arithmetic.ts
Last active December 19, 2023 17:09
Complete example of an arithmetic system built inside TypeScript's type system for this article: https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
// Utility types
type Length<T extends any[]> = T extends { length: infer L } ? L : never;
type BuildTuple<L extends number, T extends any[] = []> =
T extends { length: L }
? T
: BuildTuple<L, [...T, any]>;
type MultiAdd<N extends number, A extends number, I extends number> =
I extends 0
const fs = require('fs');
const yargs = require('yargs');
const { Argv } = yargs;
const { promisify } = require('util');
const { resolve } = require('path');
const exists = promisify(fs.exists);
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
@jesussegado
jesussegado / nx-generate-deps.ts
Last active July 15, 2020 09:56 — forked from westmark/nx-generate-deps.ts
package.json generator for @nrwl:node apps
import * as fs from 'fs';
import { resolve } from 'path';
import { promisify } from 'util';
import { argv as params } from 'yargs';
const exists = promisify(fs.exists);
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
const root = resolve(process.cwd());
import {Directive, ElementRef, Input} from '@angular/core';
import {Observable, Subscription, of} from 'rxjs';
import {share} from 'rxjs/operators';
/**
* Adds the css class `active-animate` to the element, if given expression is truthy, but after a setTimeout without triggering change detection
* This allows to animate an element entering the view, as you can't have an animation on an element that was just added to the DOM
*
* Example:
*
@madkoding
madkoding / pair-dual-boot-bluetooth.md
Last active May 24, 2025 17:11
Pairing bluetooth devices in dual boot with Linux Ubuntu and Windows 10/11

Pairing Bluetooth Devices in Dual Boot with Linux Ubuntu and Windows 10/11

Introduction

This guide provides updated instructions for pairing Bluetooth devices (such as keyboards or mice) in a dual-boot environment with Linux Ubuntu and Windows 10/11, incorporating community feedback and suggestions.

Instructions

1. Pair in Linux First

  • Pair your Bluetooth device in Linux. This is crucial to ensure the LinkKey remains consistent.
  • Note: Do not re-pair the device in Linux after completing the pairing in Windows.
@stupidawesome
stupidawesome / button.ts
Last active February 24, 2020 15:22
How to use ng-effects to create UI "traits"
import { ElementRef, Injectable, Renderer2 } from "@angular/core"
import { Context, Effect, State } from "ng-effects"
import { merge, Subject } from "rxjs"
import { disable, EventMap, fromEvents, toggle } from "../utils"
enum ButtonEvents {
"click",
"pointerenter",
"pointerleave",
"pointerdown",