Skip to content

Instantly share code, notes, and snippets.

@MikeyBurkman
MikeyBurkman / mocker.ts
Last active April 30, 2020 16:36
Typescript Mocking
import util from 'util';
/**
* Behaves like Partial<T>, except nested properties also become optional.
* @example
* ```ts
* type Foo = DeepPartial<{x: { y: number, z: number }>;
* const foo: Foo = {x: { y: 42 } }; // Note that z is now not required
* ```
*/
@reicolina
reicolina / angular-two-dots.md
Last active May 10, 2017 21:53
AngularJS and why you need one or more “dots”

In Angular, it is recommended to add objects to a scope instead of primitive values (always having one or more “dots” when accessing your models)

The reason is: prototypical inheritance. As you know, Javascript is different from classical OOP; inheritance is done in a prototypical matter. Angular follows this pattern in a way that scopes inherit prototypically from their parent scopes.

When implemented incorrectly, two-way data binding breaks if you have two or more nested elements that use separate controllers that point to the same model. Here is why:

Imagine you have two nested elements:

@kellabyte
kellabyte / CQS_and_CQRS.cs
Created March 3, 2012 03:19
CQS_and_CQRS
// CQS (Command-Query Separation)
// Bertrand Meyer devised the CQS principle
// It states that every method should either be a command that performs an action, or a
// query that returns data to the caller, but not both. In other words, asking a question
// should not change the answer. More formally, methods should return a value only if they
// are referentially transparent and hence possess no side effects.
//
// Example:
public class CustomerService