Skip to content

Instantly share code, notes, and snippets.

View viiftw's full-sized avatar
❄️
Try not to be lulled into a false sense of security!

Dat Doan viiftw

❄️
Try not to be lulled into a false sense of security!
  • Hanoi, Vietnam
View GitHub Profile
@viiftw
viiftw / docker-compose-backup.sh
Created January 20, 2021 04:04 — forked from pirate/docker-compose-backup.sh
Backup a docker-compose project, including all images, named and unnamed volumes, container filesystems, config, logs, and databases.
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
@viiftw
viiftw / links.go
Created November 26, 2020 05:07
Working with file links
@viiftw
viiftw / golang-tls.md
Created November 18, 2020 03:28 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@viiftw
viiftw / livecaption.go
Last active November 5, 2020 04:04 — forked from rakyll/livecaption.go
Code for bidirectional gRPC streaming client in https://rakyll.org/grpc-streaming/
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Command caption reads an audio file and outputs the transcript for it.
package main
import (
"fmt"
"io"
@viiftw
viiftw / main.go
Created November 2, 2020 04:02 — forked from kostanovych/main.go
Golang long polling example with request cancellation
package main
import (
"context"
"fmt"
"net/http"
"time"
)
func longOperation(ctx context.Context, ch chan<- string) {
@viiftw
viiftw / delete-from-v2-docker-registry.md
Created September 28, 2020 04:03 — forked from jaytaylor/delete-from-v2-docker-registry.md
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@viiftw
viiftw / getXML.go
Created September 18, 2020 08:51 — forked from james2doyle/getXML.go
Use HTTP to GET and parse XML in golang
// tweaked from: https://stackoverflow.com/a/42718113/1170664
func getXML(url string) ([]byte, error) {
resp, err := http.Get(url)
if err != nil {
return []byte{}, fmt.Errorf("GET error: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return []byte{}, fmt.Errorf("Status error: %v", resp.StatusCode)