Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Available for freelancing gigs

José Naves Moura Neto josenaves

🏠
Available for freelancing gigs
View GitHub Profile
@josenaves
josenaves / main.dart
Created Jun 2, 2019
The Complete Flutter Development Bootcamp with Dart - Flutter Layouts Challenge - Section 6 - 34
View main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@josenaves
josenaves / image-resizeMode.js
Created Mar 26, 2018
Show how different Image resizeMode works
View image-resizeMode.js
import React, { Component } from 'react';
import { View, StyleSheet, Image } from 'react-native';
import { Constants } from 'expo';
const mallandro = require('./assets/rah.png');
const HEIGHT = 170;
export default class App extends Component {
render() {
@josenaves
josenaves / textArea.js
Last active Mar 20, 2018
React Native TextInput as TextArea
View textArea.js
import React, { Component } from 'react';
import { View, StyleSheet, Picker, TouchableOpacity, Text, TextInput } from 'react-native';
import { withNavigation } from 'react-navigation';
const MAX_LENGTH = 150;
const styles = StyleSheet.create({
header: {
color: '#9EA0A1',
fontSize: 18,
@josenaves
josenaves / AddImageView
Created Mar 15, 2018
Example on how to create a image background with another layer on top
View AddImageView
import React, { Component } from 'react';
import { Text, View, StyleSheet, Image, ImageBackground, Platform } from 'react-native';
const backgroundImage = require('../assets/background.png')
const iconCamera = require('../assets/camera_alt_white_48x48.png')
const styles = StyleSheet.create({
addImage: {
flexDirection: 'column',
justifyContent: 'center',
@josenaves
josenaves / flattenArray.js
Created Nov 29, 2017
Flatten an array (ES6)
View flattenArray.js
const arr = [[1,2,[3]],4];
const flattenArray = list =>
list.reduce(
(a, b) => a.concat(Array.isArray(b) ? flattenArray(b) : b), []
);
console.log(flattenArray(arr));
@josenaves
josenaves / build.gradle_app
Created Nov 9, 2017
Mapbox v6 - Android - Example project
View build.gradle_app
# THIS IS example/android/app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
View App.js
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import Modal from 'react-modal';
import * as uuid from 'uuid/v1';
import {
getCategories,
getPosts,
changeSortOrder,
increasePostScore,
View index.android.js
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
@josenaves
josenaves / balanced-parenthesis.js
Created Jan 10, 2017
Balanced parenthesis problem
View balanced-parenthesis.js
function balancedParentesis(string) {
return !string.split("").reduce(function(previous, char) {
if (previous < 0) return previous;
if (char === "(") return previous + 1;
if (char === ")") return previous - 1;
return previous;
}, 0);
}
balancedParentesis("))(("); // False
@josenaves
josenaves / git-branch-in-terminal
Created Sep 10, 2014
Git branch on bash prompt
View git-branch-in-terminal
# prompt
force_color_prompt=yes
# Add git branch if its present to PS1
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else