Skip to content

Instantly share code, notes, and snippets.

View victorwpbastos's full-sized avatar
🏠
Working from home

Victor Bastos victorwpbastos

🏠
Working from home
View GitHub Profile
@victorwpbastos
victorwpbastos / setup.md
Last active August 4, 2021 19:40
Setup React Native environment for Ubuntu

Install OpenJDK-14

sudo apt install openjdk-14-jdk

Install Android Studio

sudo snap install android-studio --classic
import React from 'react';
export function setState(newState) {
this.state = { ...this.state, ...newState };
this.listeners.forEach((listener) => {
listener(this.state);
});
}
export function useCustom() {
@victorwpbastos
victorwpbastos / enableswap.sh
Created October 28, 2020 22:52
Script para habilitar swap em servidores Ubuntu
echo 'Enabling swap...'
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
@victorwpbastos
victorwpbastos / index.js
Created May 29, 2020 16:22
Reduce image size with Sharp
const sharp = require('sharp');
const fs = require('fs');
const input = sharp('./image.jpg');
input
.flatten(
{
r: 255,
g: 255,
@victorwpbastos
victorwpbastos / flatlist.js
Created May 22, 2020 16:47
Better performance paginated FlatList
import React, { useState, useEffect } from 'react';
import { Text, FlatList, View, TextInput, TouchableOpacity } from 'react-native';
let arr: any[] = [];
for (let i = 1; i <= 100; i++) {
arr.push({ id: i, text: `mensagem bacana #${i}` });
}
arr.reverse();
@victorwpbastos
victorwpbastos / javascript.json
Created October 9, 2019 16:02
VS Code snippets
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": ["console.log($1);"],
"description": "Log output to console"
@victorwpbastos
victorwpbastos / settings.json
Created October 4, 2019 16:35
VS Code settings
{
"editor.detectIndentation": false,
"editor.fontFamily": "Fira Code",
"editor.fontWeight": "300",
"editor.fontLigatures": false,
"editor.fontSize": 15,
"editor.formatOnPaste": false,
"editor.formatOnSave": false,
"editor.insertSpaces": false,
"editor.lineHeight": 24,
@victorwpbastos
victorwpbastos / .hyper.js
Created October 1, 2019 17:34
Hyper config
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Fira Code, Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
@victorwpbastos
victorwpbastos / platforms.js
Last active July 30, 2019 21:17
canvas platforms
/** @type {HTMLCanvasElement} */
const canvas = document.querySelector('#screen');
const ctx = canvas.getContext('2d');
canvas.width = 400;
canvas.height = 400;
let box = {
width: 25,
height: 25,
@victorwpbastos
victorwpbastos / documentViewer.vue
Created June 13, 2019 15:30
Vue document viewer component
<template>
<div>
<v-layout row align-center @click="show = true" style="cursor:pointer;">
<v-flex shrink class="mr-3">
<v-icon>insert_drive_file</v-icon>
</v-flex>
<v-flex>
<div>
<strong>{{ document.tipoAnexo.descricao }}</strong>
</div>