Skip to content

Instantly share code, notes, and snippets.

View andreleoni's full-sized avatar
🎮
playing software development

André Luiz Leoni andreleoni

🎮
playing software development
View GitHub Profile
@andreleoni
andreleoni / main.go
Created August 11, 2020 01:51
context studies
package main
import (
"context"
"fmt"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(
@andreleoni
andreleoni / array.rb
Created January 15, 2021 22:48
flatten implementation for ruby
input = [[1, 2], 3, 4, 5, [6, 7, [8, [10, 11],9]]]
expected = input.dup.flatten
class Array
def flatten2!
self.replace(flatten2)
end
def flatten2(array = self, result = [])
array.each { |a| a.is_a?(Array) ? flatten2(a, result) : result << a }
# dd if=/dev/zero of=/swapfile bs=1M count=12k
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.23138 s, 872 MB/s
# losetup --find --show /swapfile
/dev/loop0
# mkswap /dev/loop0
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
@andreleoni
andreleoni / Dockerfile
Created March 31, 2024 22:03
Golang docker-compose.yml with mongodb and multiple microservices
FROM golang:1.22.1
WORKDIR /go/src/app
COPY . .
RUN go mod download