Skip to content

Instantly share code, notes, and snippets.

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

Hoisel hoisel

🏠
Working from home
  • https://cloud.name-coach.com/
  • Vitória-ES
  • 00:18 (UTC -03:00)
  • X @danielhoisel
View GitHub Profile
import { assertInInjectionContext, DestroyRef, inject, Injector, isDevMode, isSignal, type Signal } from '@angular/core';
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
import { isObservable, Observable, of, retry, type RetryConfig, Subject, Subscription } from 'rxjs';
export type CreateEffectOptions = {
injector?: Injector,
/**
* @param retryOnError
* Set to 'false' to disable retrying on error.
* Otherwise, generated effect will use `retry()`.
@mishushakov
mishushakov / client.tsx
Last active June 6, 2025 23:20
A React hook for calling Next.js Server Actions from client components
'use client'
import { test } from './server'
import { useServerAction } from './hook'
export default function Home() {
const { data, loading, error, execute: testAction } = useServerAction(test)
if (loading) return <div>Loading...</div>
if (error) return <div>Error: {error.message}</div>
@sindresorhus
sindresorhus / esm-package.md
Last active July 2, 2025 19:35
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.
@bcinarli
bcinarli / Brew
Created January 3, 2020 20:04
Brew
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Chrome
brew cask install google-chrome
# Install hyper
brew cask install hyper
hyper install hyperline
hyper install an-old-hype
@rivenvirus
rivenvirus / pipes.module.ts
Last active November 22, 2020 13:32
Thumbor Pipe for Angular 7
import { NgModule } from '@angular/core';
import { ThumborPipe } from './thumbor.pipe';
@NgModule({
imports: [
// dep modules
],
declarations: [
ThumborPipe
],
const log = (tag: string) => tap(
next => console.log(`%c[${tag}: Next]`, 'color: #4CAF50;', next),
error => console.log(`%c${tag}: Error]`, 'color: #F44336;', error),
() => console.log(`%c[${tag}: Complete]`, 'color: #2196F3;')
);
@jakub-g
jakub-g / async-defer-module.md
Last active June 17, 2025 08:47
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@mohanpedala
mohanpedala / bash_strict_mode.md
Last active July 2, 2025 15:35
set -e, -u, -o, -x pipefail explanation
@johnmcase
johnmcase / updateNpm.bat
Last active October 6, 2022 16:28
Update npm on windows
rem see https://github.com/coreybutler/nvm-windows/issues/300
@echo off
SETLOCAL EnableDelayedExpansion
if [%1] == [] (
echo Pass in the version you would like to install, or "latest" to install the latest npm version.
) else (
set wanted_version=%1

Angular Interview Questions

Some basic questions going from easy to difficult. A more exhaustive list of more questions from the community can be found here.

Easy

  • Whats the difference between components and directives? [ANSWER]: Components are widgets while directives more like decorators for elements and/or components.
  • How do you get a reference to a child component? [ANSWER]: ViewChild/ViewChildren or ContentChild/ContentChildren
  • What is the difference between ViewChild and ContentChild?
  • Whats the difference between NgModules and ES2015 Modules?
  • How do you lazy load components and why is lazy loading important?
  • Explain Observables and why they are useful.