Skip to content

Instantly share code, notes, and snippets.

View johhansantana's full-sized avatar

Johhan Santana johhansantana

View GitHub Profile
@johhansantana
johhansantana / gist:943b568949d2d70e756d40ca8ce1d73d
Created December 5, 2023 14:59
build expo without eas cli
# To generate all the Android and IOS files
npx expo prebuild
# Make sure to connect your device or to run your Emulator
npx react-native run-android --mode="release"
# If you want to sign the APK and publish to Google Play Store.
npx react-native build-android --mode=release
# to build local apk
@johhansantana
johhansantana / config.json
Created December 4, 2023 16:53
add alias to webstorm using jsconfig.json for example, react-native-web
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"react-native": ["node_modules/react-native-web"]
}
}
}
@johhansantana
johhansantana / pushnotification.js
Last active March 4, 2019 21:02
push notification with working headsup display on android
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 December 7, 2017 18:45
disable uglify in nextjs webpack config
config.plugins = config.plugins.filter(plugin => {
return plugin.constructor.name !== 'UglifyJsPlugin';
})
@johhansantana
johhansantana / input.jsx
Created October 17, 2017 18:30
react-select multiple select input with redux-form example
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 August 18, 2017 18:45
Get initial values from redux store with redux form with bootstrap
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 July 18, 2017 20:39
render select field with redux form
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' : ''}`}
@johhansantana
johhansantana / renderField.jsx
Created July 18, 2017 19:48
field for redux-form
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 April 20, 2017 21:33
Run multiple async/await functions simultaneously
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 March 26, 2017 19:32
Custom webpack in next.js
module.exports = {
webpack: (config, { dev }) => {
// Perform customizations to config
config.node = {
fs: 'empty'
};
return config
}
}