Skip to content

Instantly share code, notes, and snippets.

View herbertpimentel's full-sized avatar
🙃

Herbert Pimentel herbertpimentel

🙃
  • Kapuca Sofware
  • Brazil
View GitHub Profile
/**
* @description Flats an array with any nested level deep. e.g. [[1,2,[3]],4] -> [1,2,3,4]
*/
export const flatArray = (arr) => {
return (arr || []).reduce((previous, current) =>
// call it recursivelly, adds support to nested arrays any level deep
previous.concat(Array.isArray(current) ? flatArray(current) : current)
, []);
}
@herbertpimentel
herbertpimentel / Redux-Form-Semantic-UI-React
Created February 28, 2018 02:31 — forked from mairh/Redux-Form-Semantic-UI-React
Semantic-UI-React form validation using redux-form example
// semantic-ui-form.js
import React from 'react';
import PropTypes from 'prop-types';
import { Form, Input } from 'semantic-ui-react';
export default function semanticFormField ({ input, type, label, placeholder, meta: { touched, error, warning }, as: As = Input, ...props }) {
function handleChange (e, { value }) {
return input.onChange(value);
}
@herbertpimentel
herbertpimentel / .htaccess
Created April 11, 2016 11:14 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
(function (ko, handlers, unwrap, extend) {
"use strict";
extend(handlers, {
href: {
update: function (element, valueAccessor) {
handlers.attr.update(element, function () {
return { href: valueAccessor() };
});
}
},