Skip to content

Instantly share code, notes, and snippets.

View klauskpm's full-sized avatar
:shipit:
Making weird things useful

Klaus Kazlauskas klauskpm

:shipit:
Making weird things useful
  • Brasil
View GitHub Profile
@klauskpm
klauskpm / simple-hook.js
Last active August 2, 2022 14:34
An example of how to create a hook, share a context and loop on state changes.
let contextCounter = 0;
let sharedContext = [];
let innitializedContext = [];
let wasContextUpdated = false;
function createContext(lifecycle) {
sharedContext = [];
innitializedContext = []
const loop = () => {
contextCounter = 0;
(function () {
var Contrast = {
storage: 'contrastState',
cssClass: 'contrast',
currentState: null,
check: checkContrast,
getState: getContrastState,
setState: setContrastState,
toogle: toogleContrast,
updateView: updateViewContrast
@klauskpm
klauskpm / strategies-injector-inject-environment.ts
Last active January 6, 2019 21:53
Environment injection strategy
import { InjectionToken } from '@angular/core';
export const ENVIRONMENT = new InjectionToken<any>('Environment injection token');
import { globalEnvironment } from '../../../../environments/environment.prod';
export const environment = {
production: false,
title: 'Main production',
...globalEnvironment
};
export const globalEnvironment = {
production: true,
title: 'Global production'
};
@klauskpm
klauskpm / without-barrel.js
Last active April 28, 2018 14:16
example of bad exports
import FooComponent from 'your-module/components/foo';
import BarComponent from 'your-module/components/bar';
import FooBarComponent from 'your-module/components/foo-bar';
@klauskpm
klauskpm / with-barrel.js
Last active April 28, 2018 14:15
Example of a good export
import { FooComponent, BarComponent, FooBarComponent } from 'your-module';
@klauskpm
klauskpm / index.js
Created April 28, 2018 14:11
Example of a barrel export
export * from './src/components/foo';
export * from './src/components/bar';
export * from './src/components/foo-bar';
/**
* Created by klauskpm
*/
(function () {
'use strict';
app
.factory('contrastService', ContrastService);
ContrastService.$inject = ['storageService'];
@klauskpm
klauskpm / notificacao.css
Created December 9, 2015 18:53
Cria notificações simples para enviar ao seu usuário. Dependências: jQuery
.notificacao {
width: 100%;
min-height: 20px;
position: fixed;
top: -1000px;
left: 0;
z-index: 250;
min-width: 250px;
}