Skip to content

Instantly share code, notes, and snippets.

View miladvafaeifard's full-sized avatar
🤟
always looking simple solutions

Milad Vafaeifard miladvafaeifard

🤟
always looking simple solutions
View GitHub Profile
@miladvafaeifard
miladvafaeifard / index.html
Created September 25, 2017 12:10
JS Bin flatmap function with reduce functional programming // source http://jsbin.com/kujupip
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="flatmap function with reduce functional programming">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@miladvafaeifard
miladvafaeifard / index.html
Created September 27, 2017 18:22
RxJS 5 Operators // source http://jsbin.com/qakevaj
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>RxJS 5 Operators</title>
<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.3/dist/global/Rx.umd.js"></script>
</head>
<body>
<input type="text" id="example" />
@miladvafaeifard
miladvafaeifard / solid.js
Created February 18, 2018 20:17 — forked from crizstian/solid.js
Code examples of SOLID principles for JavaScript
/*
Code examples from the article: S.O.L.I.D The first 5 priciples of Object Oriented Design with JavaScript
https://medium.com/@cramirez92/s-o-l-i-d-the-first-5-priciples-of-object-oriented-design-with-javascript-790f6ac9b9fa#.7uj4n7rsa
*/
const shapeInterface = (state) => ({
type: 'shapeInterface',
area: () => state.area(state)
})
const counter = (state = 0, action) => {
switch(action.type){
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
}
@miladvafaeifard
miladvafaeifard / crocks.js
Last active May 7, 2018 21:44
Recover from a Nothing with the "alt" method (Crocks, Ramda libraries)
const crocks = require('crocks');
const { and, compose, isEmpty, isString, Maybe, not, prop, safe } = crocks;
const { join, split, toLower } = require('ramda');
const isNonEmptyString = and(not(isEmpty), isString);
const createUrlSlug = compose(join('-'), split(' '), toLower);
const createUrl = slug => `localhost:3000/${slug}`;
@miladvafaeifard
miladvafaeifard / index.html
Created July 3, 2018 18:25
Passing Data (ReactJs)
<div id="root"></div>
@miladvafaeifard
miladvafaeifard / liskov-substitution-principal.ts
Created October 23, 2018 18:34
Liskov Substitution Principal
abstract class Vehicle {
protected speed: number;
protected cubicCapacity: any;
constructor(speed: number, cubicCapacity: number){
this.speed = speed;
this.cubicCapacity = cubicCapacity;
}
public getSpeed(): number {
return this.speed;
}
let random = function*() {
while(true) {
console.log("make random")
yield Math.random();
}
}
let filter = function*(items, predicate) {
for(let item of items){
@miladvafaeifard
miladvafaeifard / api.ts
Last active November 18, 2018 21:04
Ramda.js is a great library to aid in creating functional code as it has some great built-in methods.
const data = [
{ from: 'Holman Serrano', priority: 'normal', subject: 'Payment due' },
{ from: 'Holman Serrano', priority: 'high', subject: 'Payment due' },
{ from: 'Barbra Rasmussen', priority: 'low', subject: 'Payment due' },
{ from: 'Anastasia Cherry', priority: 'high', subject: 'Payment due' },
{ from: 'Holman Serrano', priority: 'high', subject: 'Weekend BBQ' },
{ from: 'Baird Montoya', priority: 'low', subject: 'Weekend BBQ' },
{ from: 'Flores Aguilar', priority: 'low', subject: 'Payment due' }
];
@miladvafaeifard
miladvafaeifard / BEM.scss
Created November 23, 2018 11:38
The Block, Element, Modifier methodology (commonly referred to as BEM) is a popular naming convention for classes in HTML and CSS. Developed by the team at Yandex, its goal is to help developers better understand the relationship between the HTML and CSS in a given project.
@mixin e($elements...) {
$selector: ();
@each $element in $elements {
$selector: append($selector, unquote("&__" + $element), comma);
}
#{$selector} {
@content;
}