Skip to content

Instantly share code, notes, and snippets.

View logrusorgru's full-sized avatar

Konstantin Ivanov logrusorgru

View GitHub Profile
@logrusorgru
logrusorgru / Intro.md
Last active July 29, 2021 22:49
To string, or not to sting, that is the question...
@logrusorgru
logrusorgru / load.go
Last active November 18, 2023 10:50
Golang load HTML templates
//
// 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.
//
@logrusorgru
logrusorgru / is_initialized.go
Created October 25, 2017 17:31
is initialized
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 October 3, 2017 19:22
skyobject Refs API preview
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 October 3, 2023 01:56
golang functional options problems
@logrusorgru
logrusorgru / handle.go
Last active August 13, 2017 22:17
CXO update Root
// 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 February 18, 2017 16:18
gnet example app
package main
import (
"flag"
"fmt"
"log"
"strings"
"time"
"github.com/peterh/liner"
@logrusorgru
logrusorgru / imgrsz.go
Created November 3, 2016 18:50
Golang resize png images using different interpolations
package main
import (
"image"
"image/png"
"log"
"os"
"time"
"golang.org/x/image/draw"
@logrusorgru
logrusorgru / S.sublime-syntax
Created August 21, 2016 20:46
gnu assembler custom highlighting for sublime text 3
%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 September 19, 2018 12:50
go-mangos pools research
package pool
import (
"sync"
"testing"
"time"
)
// perform:
// go test -bench syncPool