Skip to content

Instantly share code, notes, and snippets.

View adilsoncarvalho's full-sized avatar

Adilson Carvalho adilsoncarvalho

View GitHub Profile
@adilsoncarvalho
adilsoncarvalho / funcionario.java
Created July 5, 2020 23:12
Exemplo de herança para o Ney
public class Dependente {
public int getIdade() { return 123356777889; }
}
public abstract class Funcionario {
public boolean addDependente(Dependente dependente) {
if (dependentes.count() == 5) return false;
if (!dependenteValido(dependente)) return false;
dependentes.add(dependente);
}
@adilsoncarvalho
adilsoncarvalho / Dockerfile
Last active February 1, 2020 02:24
Docker support for rails-api app
# docker run --rm -v "$(pwd):/api" -ti -w /api ruby:2.7-alpine sh
FROM ruby:2.7-alpine
EXPOSE 3000
RUN apk --no-cache add alpine-sdk postgresql-dev tzdata
RUN mkdir /api
WORKDIR /api
@adilsoncarvalho
adilsoncarvalho / README.md
Created February 18, 2019 17:00
My Visual Studio Code (VSCode) Extensions

My Visual Studio Code Extensions

How I extracted it from my VSCode

code --list-extensions | xargs -L 1 echo code --install-extension

The actual list

@adilsoncarvalho
adilsoncarvalho / gsutil-upload.sh
Created October 19, 2018 12:28 — forked from mraible/gsutil-upload.sh
Upload optimized assets to Google Cloud Storage
# Rsync to remove old files
gsutil -m rsync -x '.git*' -c -d -r dist gs://bucket/
# Upload and gzip HTML, CSS and JavaScript
gsutil -m cp -z "html,css,js" -r dist/** gs://bucket/
# Set expires headers (6 months) on JS and CSS assets
gsutil -m setmeta -h "Cache-Control: public, max-age=15552000" gs://bucket/assets/**
# Make sure there's no expiration headers on HTML files
@adilsoncarvalho
adilsoncarvalho / docker-compose.yml
Created September 13, 2018 16:58
Example of a docker-compose.yml mounting cloud_sql_proxy as a service
version: '3'
services:
app:
build: .
# your own configurations for that app
depends_on:
- cloud-sql-proxy
environment:
# You must set an URL to access your database. On sequelize (nodejs) it follows this
@adilsoncarvalho
adilsoncarvalho / logger.js
Created September 6, 2018 15:19
Winston -> GCP Logger
const Logging = require('@google-cloud/logging');
// Your Google Cloud Platform project ID
const projectId = 'wiseup-102030';
// Creates a client
const logging = new Logging({
projectId: projectId,
});
@adilsoncarvalho
adilsoncarvalho / variables.json
Created August 28, 2018 18:09
Google Cloud Functions default environment variables
{
"X_GOOGLE_CODE_LOCATION": "/user_code",
"WORKER_PORT": "8091",
"X_GOOGLE_SUPERVISOR_INTERNAL_PORT": "8081",
"X_GOOGLE_WORKER_PORT": "8091",
"FUNCTION_IDENTITY": "teretete@appspot.gserviceaccount.com",
"X_GOOGLE_LOAD_ON_START": "false",
"GCLOUD_PROJECT": "project-id",
"X_GOOGLE_FUNCTION_REGION": "us-central1",
"FUNCTION_NAME": "function-name",
@adilsoncarvalho
adilsoncarvalho / create-xlsx.js
Created May 27, 2018 12:17
Creating a xlsx file using the package xlsx
// More at: https://github.com/SheetJS/js-xlsx/blob/master/demos/server/express.js
import XLSX from 'xlsx';
// create a new workbook
const workbook = XLSX.utils.book_new();
// create a new worksheet
const worksheet = XSLX.utils.json_to_sheet([{ a: 1, b: false }]);
@adilsoncarvalho
adilsoncarvalho / LICENSE
Last active March 20, 2018 01:30
Goes back to master while pulling from origin and removing the local branches deleted on origin
MIT License
Copyright (c) 2018 Adilson Luiz Carvalho
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@adilsoncarvalho
adilsoncarvalho / install.sh
Created February 26, 2018 13:58
All the Node lint packages for Visual Studio Code
#!/bin/bash
npm install -g \
eslint \
eslint-config-airbnb eslint-config-airbnb-base \
eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react \
babel-eslint