Skip to content

Instantly share code, notes, and snippets.

@alexandrricov
alexandrricov / react-ecosystem.md
Created March 16, 2018 09:13
React ecosystem workaround
@alexandrricov
alexandrricov / package.json
Created April 21, 2017 06:37
add postcss-custom-properties to create-react-app without "eject"
"scripts": {
"postbuild": "postcss --replace build/**/*.css"
}
import isClient from 'helpers/isClientSideRender';
function isObject(val) {
return Object.prototype.toString.call(val) === '[object Object]';
}
function fn(dest, obj, rootPath, myColl) {
return Object.keys(obj).reduce(
(acc, key) => {
const val = obj[key];
/**
*
* @param {Object} obj - base object
* @param {string} prop - property path
* @returns {*}
*/
function getProperty(obj, prop) {
return prop.split('.')
.reduce((m, i) => m && typeof m === 'object' ? m[i] : null, obj);
}
var flatten = arr =>
arr.reduce((p, c) =>
p.concat(Array.isArray(c) ? flatten(c) : c),
[]);
/*
* Exemplo:
* var users = [
* {name: 'Victor Queiroz'},
* {name: 'João Bosco'},
* {nickname: {myNickname: 'Ruan Jordão'}}
* ];
*
* Aplicando o filtro:
* {{ users | pluck:'name | nickname.myNickname' | join:', ' }}
@alexandrricov
alexandrricov / index.html
Created September 19, 2014 14:33
seconds (number) to "hh : mm : ss" (string)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Lol</title>
<style>
.ng-invalid {
border-color: red;
}
</style>