Skip to content

Instantly share code, notes, and snippets.

@mohlendo
mohlendo / i18n.component.ts
Last active December 11, 2019 01:35
Angular i18n translations outside a template - JIT only
import { Component } from '@angular/core'
@Component({
selector: 'i18n',
moduleId: module.id,
template: `<span i18n="@@foobar">Hello {{placeholder}}!</span>`
})
export class I18NComponent {
placeholder: any
}
@Psvensso
Psvensso / localStorage.ts
Last active September 10, 2020 14:52
React LocalStorage HOC that syncs component state to LocalStorage with whitelist
import * as React from 'react';
export function getLocalStorageItem<T>(key: string, ifNull: T) {
try {
var item = localStorage.getItem(key);
return item === null ? ifNull : JSON.parse(item);
} catch (e) {
localStorage.removeItem(key);
return ifNull;
}
}
@ahmeti
ahmeti / only-number.directive.md
Last active September 18, 2024 02:44
Angular 5 - Only Number Input, Only Number Decimal
@peterbsmyth
peterbsmyth / recipe.example.md
Last active May 21, 2020 13:39
Making chained API Calls using @ngrx/Effects

Making chained API Calls using @ngrx/Effects

Purpose

This recipe is useful for cooking up chained API calls as a result of a single action.

Description

In the below example, a single action called POST_REPO is dispatched and it's intention is to create a new repostiory on GitHub then update the README with new data after it is created.
For this to happen there are 4 API calls necessary to the GitHub API:

  1. POST a new repostiry
  2. GET the master branch of the new repository
  3. GET the files on the master branch
@ThomasBurleson
ThomasBurleson / tickets.facade.md
Last active February 22, 2024 07:41
Using ngrx with Effects + Facades

NgRx State Management with TicketFacade

Facades are a programming pattern in which a simpler public interface is provided to mask a composition of internal, more-complex, component usages.

When writing a lot of NgRx code - as many enterprises do - developers quickly accumulate large collections of actions and selectors classes. These classes are used to dispatch and query [respectively] the NgRx Store.

Using a Facade - to wrap and blackbox NgRx - simplifies accessing and modifying your NgRx state by masking internal all interactions with the Store, actions, reducers, selectors, and effects.

For more introduction, see Better State Management with Ngrx Facades

@ygrenzinger
ygrenzinger / CleanArchitecture.md
Last active April 8, 2025 17:22
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.

@loilo
loilo / bem.md
Last active March 7, 2024 09:14
Sass mixins for BEM

ATTENTION!

I keep this Gist for archival reasons, however I strongly recommend against using it. As I discovered after several weeks in production usage, these BEM mixins cause unexpected, unfixable and hard-to-debug selectors in some cases (especially when nested in some ways).

Sass mixins for BEM

This is a utility with three simple Sass mixins for writing BEM as DRY as possible, heavily inspired by Hugo Giraudel's article on CSS Tricks.

It exposes three Sass mixins: block, element and modifier.

@KDCinfo
KDCinfo / README.md
Last active September 10, 2020 15:43
LocalStorage Functions with Testing Mock-up - `Typed` with TypeScript

LocalStorage Functions

... Typed with TypeScript
... With Testing Mock-up

In the Wild

GitHub - Done (for now) - Filename used: ./src/utilities/functions.ts

@jwilson8767
jwilson8767 / es6-element-ready.js
Last active February 24, 2025 08:50
Wait for an element to exist. ES6, Promise, MutationObserver
// MIT Licensed
// Author: jwilson8767
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/