Skip to content

Instantly share code, notes, and snippets.

View adilsoncarvalho's full-sized avatar

Adilson Carvalho adilsoncarvalho

View GitHub Profile
@adilsoncarvalho
adilsoncarvalho / README.md
Last active February 15, 2025 13:19
Script to add to cron to push a repo to GitHub

repo-update.zsh

What does it do?

  1. Takes a directory as an argument.
  2. Checks if it's a Git repository.
  3. Checks for uncommitted changes.
  4. Generates a commit message with 🌱, the current timestamp, and "morning/afternoon/night update."
  5. Commits and pushes the changes.
@adilsoncarvalho
adilsoncarvalho / client.go
Created October 13, 2024 01:09
Go net/http/CookieJar
package main
import (
"log/slog"
"net/http"
"net/http/cookiejar"
"os"
)
func main() {
@adilsoncarvalho
adilsoncarvalho / main.go
Created October 12, 2024 10:50
Multiple implementations to the same interface in Go
// This code tests how one can create multiple implementations and play with
// them in Go, being an example on how the interface and struct dynamic works.
//
// This code was tested in Go 1.23
//
// # How to run it:
//
// go run main.go
//
// # Output:
@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": "[email protected]",
"X_GOOGLE_LOAD_ON_START": "false",
"GCLOUD_PROJECT": "project-id",
"X_GOOGLE_FUNCTION_REGION": "us-central1",
"FUNCTION_NAME": "function-name",