Skip to content

Instantly share code, notes, and snippets.

View AlexBrasileiro's full-sized avatar

Alex Brasileiro AlexBrasileiro

  • Marlim.co
  • Sao Paulo, Brazil
View GitHub Profile
@AlexBrasileiro
AlexBrasileiro / number-pad-zero.js
Created March 30, 2020 15:30 — forked from endel/number-pad-zero.js
Simplest way for leading zero padding in JavaScript
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
}
(1).pad(3) // => "001"
(10).pad(3) // => "010"
(100).pad(3) // => "100"
@AlexBrasileiro
AlexBrasileiro / index.js
Created March 11, 2019 02:46
Check if is Homepage with JavaScript
((window.location.pathname.indexOf("/") + 1) % ( window.location.pathname.lastIndexOf("/") + 1 ) === 0) // true
@AlexBrasileiro
AlexBrasileiro / index.md
Last active December 12, 2018 05:04
Animate Image Hover Transition

figure > img {transition: all .2s ease-in-out;}

figure:hover &gt; img {transform: scale(1.1)}

@AlexBrasileiro
AlexBrasileiro / index.html
Created December 11, 2018 04:50
Responsive images with Flexbox
<figure>
<img />
</figure>
@AlexBrasileiro
AlexBrasileiro / README.MD
Last active July 2, 2019 18:09
React Native TIPS && BUGS

Run multiples projects with metro

react-native run-ios --port 8082 facebook/react-native#10715 (comment)

path.hub.getScope is not a function

  1. On ./node_modules/metro -> delete the folder node_modules
  2. On package.json (on metro folder) -> change "@babel/core": "7.0.0-beta.56" for "@babel/core": "7.0.0"
  3. npm install (on metro folder)
@AlexBrasileiro
AlexBrasileiro / index.js
Created October 14, 2018 20:35
React Native | ScrollTo
import React, { Component, Fragment } from 'react';
import { StyleSheet, Text, View, ScrollView, TouchableOpacity, Dimensions } from 'react-native';
const Menu = (props) => {
let itens = ['blue', 'yellow', 'green', 'orange', 'pink'];
const { menu } = styles;
return (
<View style={menu}>
{
itens.map(item =>
@AlexBrasileiro
AlexBrasileiro / index.js
Last active September 24, 2020 21:46
ShareYourFeedback
// inspiration: https://dribbble.com/shots/4370657-Share-Your-Feedback
import React, { Component, Fragment } from "react";
import { Animated, StyleSheet, Text, View, TouchableOpacity, Dimensions, Platform, Easing, TextInput, KeyboardAvoidingView, Image } from "react-native";
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
const { width: windowWidth } = Dimensions.get('window');
const Icon = (props) => <FontAwesome5 {...props} />
@AlexBrasileiro
AlexBrasileiro / androidBackButton.js
Last active September 25, 2018 11:28
React Native | Android Backbutton HOC
import React, { Component } from 'react';
import { BackHandler } from 'react-native';
const AndroidBackButton = (WrappedComponent) => {
return class extends Component {
constructor(props) {
super(props)
}