Skip to content

Instantly share code, notes, and snippets.

View rzkhosroshahi's full-sized avatar
🪖

Reza Khosroshahi rzkhosroshahi

🪖
View GitHub Profile
class DynamicRender extends Component {
constructor() {
super();
this.state = {
foolks: [],
};
}
componentWillMount() {
components.map((cmp) => {
import(/* webpackMode: "eager" */ `containers/${cmp}/index`)
const coroutine = require('./coroutine');
var arr = [1,2,3,4,5,6,7,8,9,10];
function reader(target, i) {
target.next(i);
};
const arrConsumer = coroutine(function* (target) {
try {
const StringFarsiMonthes = (str) => {
switch (str) {
case "۱":
return 'فروردین';
case "۲":
return 'اردیبهشت';
case "۳":
return 'خرداد';
case "۴":
return 'تیر';
function normalizeDependOn(key, id) {
var depend = id || "id";
return key.reduce(function(data,oldData) {
data[oldData[depend]] = oldData;
return data;
},{});
}
var data = {
@rzkhosroshahi
rzkhosroshahi / index.js
Created November 10, 2017 15:39
Functional string spliter
const curry = require('lodash/curry');
const spliter = curry((separateTo,sign,string) => {
string = string.split('');
return string.reduce((comb,current,i) =>
((i+1) % separateTo === 0 && (i + 1) !== string.length)
? comb + current + sign
: comb + current
)});
@rzkhosroshahi
rzkhosroshahi / scale.scss
Last active July 25, 2017 18:18
This snippet computing golden ratio field for SASS/SCSS
@function scaleMath($n) {
@if $n == 0 {@return 1;}
@if $n == 1 {@return 1.618;}
@if $n == -1 {@return 0.618;}
@if $n > 0{
@return scaleMath($n - 1) + scaleMath($n - 2);
}
@if $n < 0 {
@return scaleMath($n + 2) - scaleMath($n + 1);
@rzkhosroshahi
rzkhosroshahi / scale.js
Created July 21, 2017 23:02
This snippet computing the golden ratio field.
function scale(n){
if(n === 0) return 1;
if(n === 1) return 1.618;
if(n === -1) return 0.618;
if(n > 0){
return scale(n-1) + scale(n-2);
}
if(n < 0){
return scale(n+2) - scale(n+1);