Skip to content

Instantly share code, notes, and snippets.

View evzpav's full-sized avatar

Evandro Pavei evzpav

View GitHub Profile
@evzpav
evzpav / aws.service.ts
Created May 17, 2023 16:40
NestJS AWS s3 upload
import { Injectable } from '@nestjs/common';
import { configService } from '../enviroment.config';
import * as AWS from 'aws-sdk';
import { S3 } from 'aws-sdk';
@Injectable()
export class AwsService {
s3: AWS.S3;
constructor() {
@evzpav
evzpav / Dockerfile_Nest
Last active March 24, 2023 03:30
Dockerfile Nest project
# ---- Base Node ----
FROM node:19-alpine3.16 AS base
ENV NODE_ENV=development
RUN mkdir /app && chown -R node:node /app
WORKDIR /app
USER node
RUN npm set progress=false && npm config set depth 0
# ---- Dependencies ----
FROM base AS dependencies
@evzpav
evzpav / github_workflows_dokku.yml
Last active March 24, 2023 01:38
.github/workflows/dokku.yml
name: 'deploy'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
@evzpav
evzpav / NewSingleHostReverseProxy+gorillamux
Last active March 23, 2023 18:32
golang NewSingleHostReverseProxy + gorilla mux
package main
import (
"net/http"
"net/http/httputil"
"net/url"
"github.com/gorilla/mux"
)
@evzpav
evzpav / main_test.go
Created July 14, 2022 14:05
Combination Algorithm in Golang - Combinations from n arrays picking one element from each array
//source: https://www.geeksforgeeks.org/combinations-from-n-arrays-picking-one-element-from-each-array/
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
@evzpav
evzpav / round_robin.go
Created January 13, 2022 18:35
Golang Round Robin - Algorithm
package main
import (
"fmt"
"sync"
"sync/atomic"
)
func main() {
concurrentCalls := 20
@evzpav
evzpav / golang_base62_encoding.go
Created January 12, 2022 02:39
Golang base62 encoding/decoding
package main
import (
"bytes"
"fmt"
"strings"
)
const chars string = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
@evzpav
evzpav / delete_stale_branches.sh
Created October 13, 2020 10:46
Delete stale local branches
#!/bin/bash
# Delete all local branches that are no "master" neither "develop"
git branch -D `git branch | grep -vE 'master|develop'`
package main
import (
"archive/zip"
"fmt"
"io/ioutil"
"os"
)
func main() {
@evzpav
evzpav / measure_time.go
Created July 6, 2020 02:55
Measure function time to execute in Go
package main
import (
"fmt"
"time"
)
func measureTime(funcName string) func() {
start := time.Now()