Skip to content

Instantly share code, notes, and snippets.

View jsidew's full-sized avatar

Jacopo Salvestrini jsidew

View GitHub Profile
@jsidew
jsidew / kivy_progressbar_example.py
Last active August 2, 2018 16:42
Just a little script to see kivy's ProgressBar working within a Popup window.
import kivy
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.uix.progressbar import ProgressBar
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
// This is a code snippet related to Jacopo Salvestrini's medium.com article
// https://medium.com/@jacoposalvestrini/fluent-middleware-in-golang-7ee7f20427fd
// * * *
// A Fluent evolution (check-out the diffs between commits)
// of the adapter pattern from Mat Ryer's article
// https://medium.com/@matryer/writing-middleware-in-golang-and-how-go-makes-it-so-much-fun-4375c1246e81
package main
import "net/http"
// from (2020-01-14) https://docs.aws.amazon.com/sdk-for-go/api/service/s3/s3manager/#Downloader.DownloadWithIterator
svc := s3manager.NewDownloader(session)
fooFile, err := os.Open("/tmp/foo.file")
if err != nil {
return err
}
barFile, err := os.Open("/tmp/bar.file")
if err != nil {
type buffer struct {
Path string
buf *aws.WriteAtBuffer
}
func (b *buffer) WriteAt(p []byte, off int64) (n int, err error) {
if b.buf == nil {
b.buf = &aws.WriteAtBuffer{}
}
const localBase = "/tmp/"
func download(ctx context.Context, client *s3.S3, bucket string, paths []string) ([]string, error) {
downloadedFiles := []string{}
length := len(paths)
if length < 1 {
return downloadedFiles, fmt.Errorf("no files to download")
}