Skip to content

Instantly share code, notes, and snippets.

View armando-couto's full-sized avatar
‼️
Focusing

Antonio Armando Couto Bem Filho armando-couto

‼️
Focusing
View GitHub Profile
docker run --name SFTPName \
-v /var/lib/docker/volumes/sftp-name/_data:/home/user/upload \
-p 2222:22 \
-d atmoz/sftp \
user:password:1001
@armando-couto
armando-couto / crontab
Created December 12, 2021 00:08
Como configurar horários no crontab
Field name | Mandatory? | Allowed values | Allowed special characters
---------- | ---------- | -------------- | --------------------------
Seconds | No | 0-59 | * / , -
Minutes | Yes | 0-59 | * / , -
Hours | Yes | 0-23 | * / , -
Day of month | Yes | 1-31 | * / , - ?
Month | Yes | 1-12 or JAN-DEC | * / , -
Day of week | Yes | 0-6 or SUN-SAT | * / , - ?
@armando-couto
armando-couto / gorotibnas.go
Created December 27, 2021 01:06
Goroutines
package main
import (
"fmt"
"sync"
)
func main() {
letter, number := make(chan bool), make(chan bool)
@armando-couto
armando-couto / deadlock.go
Created February 22, 2022 02:23
Criando um Deadlock em GO.
package main
import (
"fmt"
"sync"
"time"
)
type value struct {
mu sync.Mutex
@armando-couto
armando-couto / goroutines.go
Created March 2, 2022 02:41
In the following example, we combine the fact that goroutines are not garbage collec‐ ted with the runtime’s ability to introspect upon itself and measure the amount of memory allocated before and after goroutine creation!
package main
import (
"fmt"
"runtime"
"sync"
)
func main() {
memConsumed := func() uint64 {
@armando-couto
armando-couto / waitgroup.go
Last active March 2, 2022 02:44
WaitGroup is a great way to wait for a set of concurrent operations to complete when you either don’t care about the result of the concurrent operation, or you have other means of collecting their results. If neither of those conditions are true, I suggest you use channels and a select statement instead. WaitGroup is so useful, I’m introducing i…
package main
import (
"fmt"
"sync"
"time"
)
func main() {
var wg sync.WaitGroup
@armando-couto
armando-couto / mutex.go
Created March 2, 2022 02:47
If you’re already familiar with languages that handle concurrency through memory access synchronization, then you’ll probably immediately recognize Mutex. If you don’t count yourself among that group, don’t worry, Mutex is very easy to understand. Mutex stands for “mutual exclusion” and is a way to guard critical sections of your program. If yo…
package main
import (
"fmt"
"sync"
)
func main() {
var count int
var lock sync.Mutex
@armando-couto
armando-couto / rwmutex.go
Created March 2, 2022 02:50
The sync.RWMutex is conceptually the same thing as a Mutex: it guards access to memory; however, RWMutex gives you a little bit more control over the memory. You can request a lock for reading, in which case you will be granted access unless the lock is being held for writing. This means that an arbitrary number of readers can hold a reader lock…
package main
import (
"fmt"
"math"
"os"
"sync"
"text/tabwriter"
"time"
)
╔════════════════════════════╦══════╦════════════════════════════╗
║ Tradicional ║ ║ Ágil ║
╠════════════════════════════╬══════╬════════════════════════════╣
║ times em silos ║ <--> ║ times ponta-a-ponta ║
║ menos autonomia ║ <--> ║ mais autonomia ║
║ maior custo de coordenação ║ <--> ║ menor custo de coordenação ║
║ mais dependência ║ <--> ║ menos dependência ║
║ maior leadtime ║ <--> ║ menor leadtime ║
║ metas individuais ║ <--> ║ metas compartilhadas ║
║ menor velocidade na tomada ║ <--> ║ maior velocidade na tomada ║
@armando-couto
armando-couto / queue.go
Created March 7, 2022 00:12
Let’s expand on this example and show both sides of the equation: a goroutine that is waiting for a signal, and a goroutine that is sending signals. Say we have a queue of fixed length 2, and 10 items we want to push onto the queue. We want to enqueue items as soon as there is room, so we want to be notified as soon as there’s room in the queue
package main
import (
"fmt"
"sync"
"time"
)
func main() {
c := sync.NewCond(&sync.Mutex{})