Skip to content

Instantly share code, notes, and snippets.

View sponomarev's full-sized avatar
🔴
Offline

Sergey Ponomarev sponomarev

🔴
Offline
View GitHub Profile
-include private.mk
foo :
echo "foo from Makefile"
DELETE users
DELETE users_1_dedicated
# Create users index template
PUT _template/users
{
"index_patterns": ["users*"],
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
GTr#7NyYLYvhqzgdoyLzrTrf
@sponomarev
sponomarev / README.md
Created October 29, 2018 15:23 — forked from joyrexus/README.md
Functional config in go

Quick demo of how to initialize your data structure with optional configuration parameters ... with sane defaults if left unspecified.

This functional config technique ...

  • lets you write APIs that can evolve without pain
  • provides meaningful configuration parameters
  • makes it easy to set default settings
  • makes it possible to set complex conditional values
@sponomarev
sponomarev / context.go
Created October 17, 2018 20:10
Context with Signal
package cmd
import (
"context"
"os"
"os/signal"
"syscall"
)
// ContextWithSignal creates a context canceled when SIGINT or SIGTERM are notified
@sponomarev
sponomarev / main.go
Created September 24, 2018 03:10
Golang context to cancel HTTP request and response
package main
import (
"context"
"fmt"
"io"
"log"
"net/http"
"time"
)
#!/usr/bin/env ruby
require 'time'
start = Time.now
ARGF.read.each_line do |line|
now = Time.now
prev ||= now
$stdout.puts "#{now.iso8601} #{ now - start }s #{ now - prev }s #{line}"
@sponomarev
sponomarev / alias_matchers.md
Created July 10, 2018 13:38 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
1password
adobe-acrobat-reader
atom
blockblock
coconutbattery
cyberduck
daisydisk
dashlane
deluge
docker
@sponomarev
sponomarev / lock_monitor.sql
Created November 24, 2017 16:20
PG Lock monitor
CREATE VIEW lock_monitor AS
(SELECT COALESCE(blockingl.relation::regclass::text,blockingl.locktype) AS locked_item, now() - blockeda.query_start AS waiting_duration, blockeda.pid AS blocked_pid, blockeda.query AS blocked_query, blockedl.mode AS blocked_mode, blockinga.pid AS blocking_pid, blockinga.query AS blocking_query, blockingl.mode AS blocking_mode
FROM pg_catalog.pg_locks blockedl
JOIN pg_stat_activity blockeda ON blockedl.pid = blockeda.pid
JOIN pg_catalog.pg_locks blockingl ON( ((blockingl.transactionid=blockedl.transactionid)
OR (blockingl.relation=blockedl.relation
AND blockingl.locktype=blockedl.locktype) )
AND blockedl.pid != blockingl.pid)
JOIN pg_stat_activity blockinga ON blockingl.pid = blockinga.pid
AND blockinga.datid = blockeda.datid