Skip to content

Instantly share code, notes, and snippets.

View donvito's full-sized avatar
🚀
solo dev building apps with AI. launched aidreamphoto.com

Melvin Vivas @DonvitoCodes donvito

🚀
solo dev building apps with AI. launched aidreamphoto.com
View GitHub Profile
package main
import (
"fmt"
)
func main() {
x := 10
fmt.Println(sum_i(x))
@donvito
donvito / resize.py
Created August 13, 2019 04:28
Python script to resize photos
import os, sys
from PIL import Image
size = 512, 512
resizedFolder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resized")
if not os.path.exists(resizedFolder):
os.makedirs(resizedFolder)
for file in os.listdir("./"):
if file.endswith(".jpg") or file.endswith(".jpeg") or file.endswith(".png") :
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@donvito
donvito / data.json
Last active September 18, 2019 04:27
GraphQL Go
[
{
"id": 1,
"position": "Software Engineer",
"company": "Apple",
"description": "job description",
"skillsRequired": ["Go", "GraphQL"],
"location": "location",
"employmentType": "full-time"
},
@donvito
donvito / main.go
Last active September 26, 2019 12:36
package main
import "fmt"
func main() {
fmt.Println("Hello universe! gist!")
}
@donvito
donvito / Dockerfile
Last active November 2, 2019 05:35
Dockerfile to build a docker image with a main.go gist
FROM golang:1.13.4 AS builder
ARG GIST_RAW_URL
RUN mkdir /app
RUN curl $GIST_RAW_URL --output /app/main.go
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./...
FROM alpine:latest AS production
COPY --from=builder /app .
CMD ["./main"]
@donvito
donvito / main.go
Last active September 26, 2019 12:51
Go code to run a container and retrieve stdout
package main
import (
"context"
"os"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/stdcopy"
@donvito
donvito / main.go
Created October 29, 2019 01:19
Go Interface example - print area of shapes
package main
import (
"fmt"
"reflect"
)
func main() {
r := Rectangle{length:5, width:10}
printArea(&r)
@donvito
donvito / main.go
Created November 21, 2019 11:27
AWS Lambda Go example - retrieve environment variables
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
@donvito
donvito / balance.go
Last active November 26, 2019 14:05
Higher order functions
package main
import (
"fmt"
)
func balanceFormula(paidLate bool) func(float64, float64) float64 {
if(paidLate == true){
fn := func(principal float64, lateFee float64) float64{