Skip to content

Instantly share code, notes, and snippets.

View intojs's full-sized avatar

Daniel Dughila intojs

View GitHub Profile
@intojs
intojs / dom-pointer.html
Last active August 18, 2016 14:37
Navigate through a table like dom structure and highlight each element
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
@intojs
intojs / testing-cheetsheet.js
Last active December 4, 2016 21:12
Testing Cheetsheet
/**
* Sinon.
*/
const CATS = ['Sassy', 'Tom'];
function sayMeow(cats) {}
describe('when sayMeow is called', () => {
beforeEach(() => {
@intojs
intojs / Repo.ts
Last active May 21, 2017 13:00
redux-like-state-management-in-angular
export interface Repo {
name: string;
descriptio: string;
}
@intojs
intojs / 0_reuse_code.js
Created May 21, 2017 13:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@intojs
intojs / Repos.ts
Last active May 21, 2017 13:44
redux-like-state-management-in-angular
import { Repo } from './Repo';
export interface Repos {
isLoading: boolean;
repos: Repo[];
hasError: boolean;
}
@intojs
intojs / optimistic-state-management.html
Last active November 22, 2017 22:09
Optimistic state management
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Optimistic State Management</title>
</head>
<body>
<p>Number of items: <span id="number-of-items"></span></p>
<p>Total Cost: <span id="total-cost"></span></p>
@intojs
intojs / Product.ts
Created December 5, 2017 21:59
Mocking in Typescript - Product.ts
import { Price } from './Price';
export interface Product {
name: string;
description: string;
longDescription: string;
imageOne: string;
imageTwo: string;
imageThree: string;
price: Price;
@intojs
intojs / Price.ts
Created December 5, 2017 22:01
Mocking in Typescript - Price.ts
export interface Price {
value: number;
currency: string;
vat: number;
stringRepresentation: string;
}
@intojs
intojs / product-utils.ts
Created December 5, 2017 22:06
Mocking in TypeScript
import { Product } from './Product';
import { Price } from './Price';
export const filterProductsByName =
(name: string) =>
(products: Product[]) =>
products.filter((product: Product) => product.name.includes(name));
export const addPriceToProduct =
(price: Price) =>
@intojs
intojs / product-utils.spec
Created December 5, 2017 22:16
Mocking in Typescript - product-utils.spec
import { Product } from './Product';
import { Price } from './Price';
import { filterProductsByName, addPriceToProduct } from './product-utils';
describe('product-utils', () => {
test('filterProductsByName', () => {
const name = 'Puffy';
const puffy: Product = {
name: 'Puffy',