Skip to content

Instantly share code, notes, and snippets.

@gumayunov
gumayunov / queue-monitoring.clj
Last active October 15, 2015 15:48
queue-monitoring.clj
(defn- queue-stuck?
[events]
(comment "простейшая проверка, что очередь не стала меньше"))
(defn- make-alert-event
[events]
(merge (first events) { :state "major" :description (str "Смотрите как все плохо " events)}))
(defn- when-stuck
[children]
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
class NewMsisdnInUseError < Error;
def initialize(msg, models:)
super msg
@models = models
end
def inspect
Object.instance_method(:inspect).bind(self).call
end
end
@gumayunov
gumayunov / tmux.conf
Last active December 23, 2015 08:49
set -g default-command "exec /bin/zsh -l"
set -g bell-action none
set -g history-limit 10000
set -g base-index 1
set -g default-terminal "screen-256color"
#setw -u automatic-rename
module ReverseField
def field=(value)
value = value.reverse
super
end
end
class C
include ReverseField
class Name < AcriveRecord::Base
# includes & extensions
include Module
# constants
CONST = 1
# attributes
attr_accessor :attribute
@gumayunov
gumayunov / template.rb
Created December 7, 2012 09:29
Rails template
gem 'pg'
gem 'jquery-rails'
gem "haml-rails"
gem 'simple_form'
gem "rabl", git: "git://github.com/nesquena/rabl.git"
gem "unicorn"
gem 'state_machine'
gem 'haml-rails'
gem_group :development do
@gumayunov
gumayunov / gist:3992138
Created November 1, 2012 06:15 — forked from alinpopa/gist:1281448
elasticsearch analyzer example - Test Queries
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",
Configus.build Rails.env do
env :production do
services do
stripe "StripeService"
stripe_gateway "StripeGateway"
end
end
class ::Chef::Provider::HttpRequest < Chef::Provider
def load_current_resource
Chef::Log.debug("load_current_resource: #{@new_resource.inspect}")
@rest = Chef::REST.new(@new_resource.url, nil, nil, :disable_gzip => true)
end
end