Skip to content

Instantly share code, notes, and snippets.

View padurean's full-sized avatar

Valentin Padurean (Ogg) padurean

View GitHub Profile
@padurean
padurean / README.md
Created March 8, 2023 11:42 — forked from nitaku/README.md
Markdown sidenotes

Test sidenote1 blah.

Footnotes

  1. Bah.

@padurean
padurean / stringToReaderCloser.go
Created September 27, 2022 11:34 — forked from crgimenes/stringToReaderCloser.go
string to io.ReadCloser
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
)
@padurean
padurean / status.go
Created January 15, 2022 13:54
Golang enum pattern with TextMashalJSON
package task
import (
"fmt"
"strings"
)
// Status ...
type Status int
@padurean
padurean / wait_timeout.go
Created January 5, 2022 16:17 — forked from r4um/wait_timeout.go
Golang - WaitGroup Timeout
package main
import (
"fmt"
"sync"
"time"
)
func main() {
wg := sync.WaitGroup{}
@padurean
padurean / enum.go
Created December 16, 2021 21:55 — forked from lummie/enum.go
Golang Enum pattern that can be serialized to json
package enum_example
import (
"bytes"
"encoding/json"
)
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred
type TaskState int
@padurean
padurean / main.go
Created January 29, 2021 12:06 — forked from dopey/main.go
How to generate secure random strings in golang with crypto/rand.
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
// Adapted from https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/
package websocket
import (
"fmt"
"io"
"strings"
"time"
logger "github.com/rs/zerolog/log"
"golang.org/x/net/websocket"
# Git log oneline since a certain date with author names:
git log --after="2020-09-22T00:00:00-00:00" --pretty=format:"%h%x09%ad%x09%an%x09%s" --date=short
@padurean
padurean / GetLocalIP.go
Last active July 23, 2020 19:26
Two ways to get the current local IP in Go #Golang
package main
import (
"errors"
"fmt"
"net"
)
func main() {
localIP, err := getLocalIPFromNetInterfaces()
@padurean
padurean / README-Template.md
Created June 21, 2020 11:08 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites