Skip to content

Instantly share code, notes, and snippets.

View logrusorgru's full-sized avatar

Konstantin Ivanov logrusorgru

View GitHub Profile
@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 / mysql.sql
Last active January 16, 2024 07:01
SQL: uniqueness, automatic created_at, updated_at refresh + soft delete. SQLite, PostgreSQL, MySQL
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
-- mysql --
-- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
-- mysql <http://sqlfiddle.com/#!9/91afb5/2>
-- note: sqlfiddle is very stupid
@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 / 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 / notf.md
Last active October 3, 2023 01:56
golang functional options problems
@logrusorgru
logrusorgru / Makefile
Last active January 25, 2023 18:13
GNU Assembler: пишем разделяемые библиотеки
all: clean build run
build:
gcc -nostdlib -Wall -shared -fPIC hello_exit.S -Wl,-soname,libhelloexit.so.1 -o libhelloexit.so.1.0
ln -sv libhelloexit.so.1.0 libhelloexit.so.1
ln -sv libhelloexit.so.1.0 libhelloexit.so
gcc -nostdlib -Wall -L. -I. hello.c -lhelloexit -Wl,-rpath,. -o hello
@echo Done
run:
@logrusorgru
logrusorgru / gist:9867976
Last active December 16, 2022 02:54
Rails - How to check for online users? Redis.

Rails - How to check for online users? Redis.

Init Redis

   # config/initializers/redis.rb
    
   $redis_onlines = Redis.new
   # it's the simplest way, but i'd recommend:
   # $redis_onlines = Redis.new path: "/tmp/redis.sock", db: 15, driver: :hiredis
@logrusorgru
logrusorgru / Intro.md
Last active July 29, 2021 22:49
To string, or not to sting, that is the question...
@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
@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)
}