Skip to content

Instantly share code, notes, and snippets.

Avatar

Konstantin Ivanov logrusorgru

View GitHub Profile
@logrusorgru
logrusorgru / Intro.md
Last active Jul 29, 2021
To string, or not to sting, that is the question...
View Intro.md
@logrusorgru
logrusorgru / load.go
Last active May 11, 2020
Golang load HTML templates
View load.go
//
// Copyright (c) 2018 Konstanin Ivanov <kostyarin.ivanov@gmail.com>.
// All rights reserved. This program is free software. It comes without
// any warranty, to the extent permitted by applicable law. You can
// redistribute it and/or modify it under the terms of the Do What
// The Fuck You Want To Public License, Version 2, as published by
// Sam Hocevar. See below for more details.
//
View is_initialized.go
type MessengerFactory struct {
factory.MessengerFactory
isInitialized bool
}
func (m *MessengerFactory) IsInitialized() bool { return m.isInitialized }
func (m *MessengerFactory) Connect(address string) (conn *Connection, err error) {
return m.ConnectWithConfig(address, nil)
}
@logrusorgru
logrusorgru / refs.go
Last active Oct 3, 2017
skyobject Refs API preview
View refs.go
Len(pack Pack) (ln int, err error)
// presence check
HasHash(pack Pack, hash cipher.SHA256) (ok bool, err error)
// short hand for HasHash + pack.Get(hash) + encoder.DeserializeRaw
ValueByHash(pack Pack, hash cipher.SHA256, obj interface{}) (err error)
// the IndexByHash is useful only if the Refs contains only unique
// elements
@logrusorgru
logrusorgru / notf.md
Last active Oct 17, 2021
golang functional options problems
View notf.md
@logrusorgru
logrusorgru / handle.go
Last active Aug 13, 2017
CXO update Root
View handle.go
// in this example the Event is an event, that requires updates in our Root
func startHandlingSomePack(events <-chan Event, pack *skyobject.Pack,
n *node.Node, wg *sync.WaitGroup) {
go handleSomePack(n, pack, events, n.Quiting(), wg)
}
func handleSomePack(n *node.Node, pack *cxo.Pack, events <-chan Event,
quit <-chan struct{}, wg *sync.WaitGroup) {
@logrusorgru
logrusorgru / gnetex.go
Last active Feb 18, 2017
gnet example app
View gnetex.go
package main
import (
"flag"
"fmt"
"log"
"strings"
"time"
"github.com/peterh/liner"
@logrusorgru
logrusorgru / imgrsz.go
Created Nov 3, 2016
Golang resize png images using different interpolations
View imgrsz.go
package main
import (
"image"
"image/png"
"log"
"os"
"time"
"golang.org/x/image/draw"
@logrusorgru
logrusorgru / S.sublime-syntax
Created Aug 21, 2016
gnu assembler custom highlighting for sublime text 3
View S.sublime-syntax
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
- S
scope: source.S
contexts:
main:
# comment multiline
@logrusorgru
logrusorgru / bench_test.go
Last active Sep 19, 2018
go-mangos pools research
View bench_test.go
package pool
import (
"sync"
"testing"
"time"
)
// perform:
// go test -bench syncPool