Skip to content

Instantly share code, notes, and snippets.

View SebastianHGonzalez's full-sized avatar

Sebastian Gonzalez SebastianHGonzalez

View GitHub Profile
@SebastianHGonzalez
SebastianHGonzalez / addAspect.js
Created January 21, 2019 12:30
addAspect example
addAspect(aspect) {
this.aspects = [...this.aspects, aspect];
}
@SebastianHGonzalez
SebastianHGonzalez / beforeAndAfterPointCut.js
Last active January 21, 2019 12:35
point cut's before and after methods
before(context, joinPointName, ...args) {
this.aspects.reduce(
(_, aspect) => aspect.before(context, joinPointName, ...args)
);
}
after(context, joinPointName, result, ...args) {
return this.aspects.reduce(
(prevResult, aspect) => aspect.after(context, joinPointName, prevResult, ...args),
result
@SebastianHGonzalez
SebastianHGonzalez / aroundPointCut.js
Created January 21, 2019 12:39
point cut's around method
around(context, joinPoint, ...args) {
return this.aspects.reduce(
function aroundReducer(next, aspect) {
return function joinPointify(...newArgs) {
const newContext = this;
aspect.around(newContext, next, ...newArgs)
}
},
joinPoint
).apply(context, args);
@SebastianHGonzalez
SebastianHGonzalez / injectPointCut.js
Created January 21, 2019 13:14
pointCut's inject correction
inject(definition) {
definition.decoreateTargets(joinPoint => this.decorate(joinPoint));
}
@SebastianHGonzalez
SebastianHGonzalez / pointCutDefinition.js
Last active January 21, 2019 13:24
first pointcutdefinition implementation
class PointCutDefinition {
/**
TODO
**/
decorateTargets(decorator) {
this.decorateMethods(decorator);
}
decorateMethods(decorator) {
this.targetClasses
@SebastianHGonzalez
SebastianHGonzalez / aopExample.js
Last active January 21, 2019 13:54
AOP example code
class PointCut {
aspects = [];
constructor(definition) {
this.inject(definition);
}
addAspect(aspect) {
this.aspects = [...this.aspects, aspect];
@SebastianHGonzalez
SebastianHGonzalez / sassTransitionExample.scss
Created January 23, 2019 13:25
sass transitrions example
$pending-color: hsl(192, 69%, 50%);
$done-color: hsl(128, 69%, 50%);
@mixin transition($x...){
-webkit-transition: $x;
-moz-transition: $x;
-ms-transition: $x;
-o-transition: $x;
transition: $x;
}
/**
* Copyright 2019 Sebastian Gonzalez
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
@SebastianHGonzalez
SebastianHGonzalez / ReactUserPlaylist.js
Last active May 1, 2019 17:27
React User Playlist - Example of fetching and displaying an user's playlist using react hooks
/**
* React Example
* User Playlist
*
* Example of fetching and displaying an user's playlist using react hooks
*
*/
/**
* Copyright 2019 Sebastian Gonzalez
@SebastianHGonzalez
SebastianHGonzalez / Wizard.jsx
Last active May 8, 2019 17:36
React Router Wizard
/**
* Copyright 2019 Sebastian Gonzalez
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE