Skip to content

Instantly share code, notes, and snippets.

View tsyber1an's full-sized avatar
🎯
Focusing

Tsyren O. tsyber1an

🎯
Focusing
View GitHub Profile
@tsyber1an
tsyber1an / main.go
Created August 9, 2022 14:35
Go 1.18 Generics usage example
package main
import "fmt"
func handler[arg int64 | float32](input arg) {
fmt.Println(input)
}
type Number in qzzzterface {
int8 | int16 | int32 | int64 | float32 | float64
@tsyber1an
tsyber1an / index.html
Created April 2, 2012 07:42
Slider example implementation in SVG
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<style type="text/css">
svg {
background: #333;
}
@tsyber1an
tsyber1an / git.sh
Created November 15, 2021 06:18
git commands
git config --global rebase.autosquash true
git rebase -Xtheirs branch-b
@tsyber1an
tsyber1an / caller_example.go
Created November 11, 2021 09:26
runtime.Caller example
package main
import (
"fmt"
"runtime"
)
func foo() {
_, file, no, ok := runtime.Caller(1)
if ok {
@tsyber1an
tsyber1an / logger.go
Created November 10, 2021 08:22
explicit sarama kafka logger
sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags)
@tsyber1an
tsyber1an / golang-tls.md
Created October 31, 2021 15:14 — 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)
@tsyber1an
tsyber1an / main.go
Created October 26, 2021 13:02 — forked from kpurdon/main.go
golang graceful server shutdown example
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@tsyber1an
tsyber1an / data.json
Created April 10, 2012 09:07
simple force-directed graph using d3
{
"nodes": [
{
"name": "Myriel",
"group": 1
},
{
"name": "Napoleon",
"group": 1
},