Skip to content

Instantly share code, notes, and snippets.

View r3code's full-sized avatar

Dmitriy S. Sinyavskiy r3code

View GitHub Profile
@r3code
r3code / .gitconfig
Last active June 22, 2020 09:34
Gitconfig to set Mela as default diff and mergetool for git
diff]
tool = meld
[difftool]
prompt = false
[difftool "meld"]
trustExitCode = true
cmd = open -W -a Meld --args \"$LOCAL\" \"$PWD/$REMOTE\"
[merge]
tool = meld
[mergetool]
@r3code
r3code / postgresql_drop_all_tables.sql
Created June 26, 2020 15:59
PostgreSQL query to drop all tables at once at specified shema (helps with dirty state in go-migrate)
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
@r3code
r3code / check_string_has_duplicate_symbols.go
Last active July 7, 2020 13:14
Go: check if string has duplicate symbols
func hasDuplicateSymbols(s string) bool {
seen := make(map[rune]struct{}, len(s))
for _, r := range s {
if _, ok := seen[r]; ok {
return true
}
seen[r] = struct{}{}
}
return false
}
@r3code
r3code / git-absorb-usage.md
Last active July 8, 2020 09:41
Объединение комитов созданных для исправлений после code review
@r3code
r3code / add-go-to-path.sh
Created July 14, 2020 09:02
How to add golang tools to path?
export PATH=$PATH:$(go env GOPATH)/bin
@r3code
r3code / golang-cspell-vscode-settings.js
Last active March 26, 2025 08:47
Visual Studio Code - Code Spell Checker config for GoLang
{
// Add to VS Code settings.js file
"cSpell.languageSettings": [
// GoLang settings
{
"languageId": "go",
// Turn off compound words, because it is only checking strings.
"allowCompoundWords": false,
// Only check comments and strings
"includeRegExpList": [
@r3code
r3code / db.go
Created November 4, 2020 17:40 — forked from adamfdl/db.go
package sql
import (
"database/sql"
)
var (
ErrNoRows = sql.ErrNoRows
)
@r3code
r3code / resume.json
Last active December 4, 2022 18:48
Dmitriy S. Sinyavskiy Resume / CV (created with https://gitconnected.com/r3code/resume)
{
"basics": {
"name": "Dmitriy S. Sinyavskiy",
"label": "Go Developer | Site Reliability Engineer",
"image": "https://avatars0.githubusercontent.com/u/1355056?v=4",
"url": "https://habr.com/ru/users/r3code/",
"summary": "I'm a software developer with more than 17 years of experience. I try to do my best and encourage teammates to do the same. \n\nI prefer to create documented, well organized and tested code. Other developer should have an ability to start working with the code without any need to ask me about it.\n\nMy open-source code here at GitHub: https://github.com/r3code\n\nOther hobbies:\n* teach kids computer science and programming\n* ship-modeling from plastic\n* snowboarding\n\nI like to work with people. I can understand what stakeholder really need and translate the data to the developers language. Before tell, I listen then propose. For me, it is very important to do the work! I use Kanban board to manage task flow and EventStorming methodology to und
@r3code
r3code / structured-logging.md
Last active March 24, 2021 12:15
Structured logging best practices

Structured logging best practices (from NLog fo java)

  • The message logged should be the same every time. It should be a constant string, not a string formatted to contain data values such as ids or quantities. Then it is easy to search for.
  • The message logged should be distinct i.e. not the same as the message produced by an unrelated log statement. Then searching for it does not match unrelated things as well.
  • The message should be a reasonable length i.e. longer than a word, but shorter than an essay.
  • The data should be simple values. Use field values of types e.g. string, int, decimal, DateTimeOffset, or enum types. StructuredLogging.Json does not log hierarchical data, just a flat list of key-value pairs. The values are serialised to string with some simple rules: Nulls are serialised as empty strings. DateTime values (and DateTime?, DateTimeOffset and DateTimeOffset?) are serialised to string in ISO8601 date and time format. Everything else is just serialised with .ToStr
@r3code
r3code / golang-code-introspection.md
Created March 27, 2021 09:33
Интроспекция Go кода