Skip to content

Instantly share code, notes, and snippets.

Johhan Santana johhansantana

View GitHub Profile
@johhansantana
johhansantana / pushnotification.js
Last active Mar 4, 2019
push notification with working headsup display on android
View pushnotification.js
const admin = require("firebase-admin");
const serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "your database url (optional)"
});
module.exports = (req, res) => {
const payload = {
@johhansantana
johhansantana / nextjs.config.js
Created Dec 7, 2017
disable uglify in nextjs webpack config
View nextjs.config.js
config.plugins = config.plugins.filter(plugin => {
return plugin.constructor.name !== 'UglifyJsPlugin';
})
@johhansantana
johhansantana / input.jsx
Created Oct 17, 2017
react-select multiple select input with redux-form example
View input.jsx
const renderSelect = field => (
<Select
id={field.id}
name={field.input.name}
multi={true}
joinValues={true}
value={field.input.value}
options={field.options}
onChange={(val) => field.input.onChange(val)}
/>
@johhansantana
johhansantana / redux-form-basic.jsx
Last active Aug 18, 2017
Get initial values from redux store with redux form with bootstrap
View redux-form-basic.jsx
import React from 'react'
import { connect } from 'react-redux'
import { Field, reduxForm } from 'redux-form'
const required = value => (value ? undefined : 'Requerido')
let ConcursoForm = props => {
const { handleSubmit, submitting, invalid } = props
return (
<form onSubmit={ handleSubmit }>
<Field
@johhansantana
johhansantana / renderSelect.jsx
Last active Jul 18, 2017
render select field with redux form
View renderSelect.jsx
const renderSelect = (field) => (
<div className="form-group">
<label htmlFor={field.input.name}>{field.label}</label>
<select
id={field.id}
name={field.input.name}
defaultValue=""
onChange={(event) => field.input.onChange(event.target.value)}
onBlur={(event) => field.input.onBlur(event.target.value)}
className={`form-control ${field.meta.touched && field.meta.error ? 'error' : ''}`}
View renderField.jsx
const renderField = (field) => (
<div className="form-group">
<label htmlFor={field.input.name}>{field.label}</label>
<input
{...field.input}
id={field.input.name}
name={field.input.name}
className={`form-control ${field.meta.touched && field.meta.error ? 'error' : ''}`}
type={field.type}
/>
@johhansantana
johhansantana / simultaneously-async-await.js
Created Apr 20, 2017
Run multiple async/await functions simultaneously
View simultaneously-async-await.js
async () => {
try {
const [locations, categories] = await Promise.all([
getLocations(),
getCategories()
])
this.setState({locations, categories, loading: false});
} catch (err) {
alert("Error: " + err.code + " " + err.message);
this.setState({loading: false});
@johhansantana
johhansantana / next.config.js
Created Mar 26, 2017
Custom webpack in next.js
View next.config.js
module.exports = {
webpack: (config, { dev }) => {
// Perform customizations to config
config.node = {
fs: 'empty'
};
return config
}
}
@johhansantana
johhansantana / index.html
Created Mar 16, 2017
Angular animate using angular-animate
View index.html
<div class="animate" ng-hide="loading">
...
</div>
@johhansantana
johhansantana / flexbox.css
Created Mar 6, 2017
Easy flexbox predefined css
View flexbox.css
/**
Flex css start
*/
.containerFlexRow {
display: flex;
flex-direction: row;
}
.wrapFlex {
flex-wrap: wrap;
You can’t perform that action at this time.