Skip to content

Instantly share code, notes, and snippets.

View josenaves's full-sized avatar

José Naves Moura Neto josenaves

View GitHub Profile
@josenaves
josenaves / main.dart
Created June 2, 2019 19:05
The Complete Flutter Development Bootcamp with Dart - Flutter Layouts Challenge - Section 6 - 34
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 March 26, 2018 21:35
Show how different Image resizeMode works
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 March 20, 2018 16:44
React Native TextInput as TextArea
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 March 15, 2018 19:07
Example on how to create a image background with another layer on top
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 November 29, 2017 16:59
Flatten an array (ES6)
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 November 9, 2017 13:45
Mapbox v6 - Android - Example project
# 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
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,
@josenaves
josenaves / index.android.js
Created February 12, 2017 21:00
Module example
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
@josenaves
josenaves / balanced-parenthesis.js
Created January 10, 2017 18:03
Balanced parenthesis problem
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 September 10, 2014 19:07
Git branch on bash prompt
# 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