Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Making weird things useful

Klaus Kazlauskas klauskpm

:shipit:
Making weird things useful
  • Brasil
View GitHub Profile
View strategies-injector-inject-environment.ts
import { InjectionToken } from '@angular/core';
export const ENVIRONMENT = new InjectionToken<any>('Environment injection token');
View environments-main-environment.prod.ts
import { globalEnvironment } from '../../../../environments/environment.prod';
export const environment = {
production: false,
title: 'Main production',
...globalEnvironment
};
View environments-environment.prod.ts
export const globalEnvironment = {
production: true,
title: 'Global production'
};
@klauskpm
klauskpm / books.json
Last active Jul 22, 2018
Mapt test for object-oriented javascript
View books.json
[
{
"id" : 101,
"title" : "Some book title"
},
{
"id" : 102,
"title" : "Another book title"
},
{
@klauskpm
klauskpm / index.js
Created Apr 28, 2018
Example of a barrel export
View index.js
export * from './src/components/foo';
export * from './src/components/bar';
export * from './src/components/foo-bar';
@klauskpm
klauskpm / with-barrel.js
Last active Apr 28, 2018
Example of a good export
View with-barrel.js
import { FooComponent, BarComponent, FooBarComponent } from 'your-module';
@klauskpm
klauskpm / without-barrel.js
Last active Apr 28, 2018
example of bad exports
View without-barrel.js
import FooComponent from 'your-module/components/foo';
import BarComponent from 'your-module/components/bar';
import FooBarComponent from 'your-module/components/foo-bar';
View contrast.class.js
(function () {
var Contrast = {
storage: 'contrastState',
cssClass: 'contrast',
currentState: null,
check: checkContrast,
getState: getContrastState,
setState: setContrastState,
toogle: toogleContrast,
updateView: updateViewContrast
View contrast.service.js
/**
* Created by klauskpm
*/
(function () {
'use strict';
app
.factory('contrastService', ContrastService);
ContrastService.$inject = ['storageService'];
View score-keeper.js
var LOG_TAG = "ScoreKeeper";
var ScoreKeeper = {
/**
* @param {Team[]}
*/
teams: [],
init: function initF(teamAName, teamBName) {
console.log("%c INIT", "color: #FF0000; font-weight: bolder;", LOG_TAG);