Skip to content

Instantly share code, notes, and snippets.

View dmexe's full-sized avatar

Dmitry Galinsky dmexe

View GitHub Profile

Publisher

When published an import to audio2 for processing

{
  "message": "Successfully published ImportCreatedOrUpdated(123e4567-e89b-12d3-a456-426614174000) to publisher-v1-json-events[2]/14788",
  "event.kind": "event",
  "event.created": "2016-05-23T08:05:34.853Z",
  "event.code": "publisher:import_created_or_updated",
/// It converts an inner stream into a future, which
/// pick up a first ok result from the stream and stop
/// or if a stream ended without any successful result return
/// a last recorded error from the stream.
///
/// Usage:
/// ```
/// let stream = iter_ok(vec![1,2,3]);
/// let future = stream.next_ok_or_last_err();
/// ```
@dmexe
dmexe / pg_change_db_owner.sh
Created September 8, 2016 16:50 — forked from jirutka/pg_change_db_owner.sh
Some convenient scripts to manage ownerships and privileges in PostgreSQL.
#!/bin/bash
#
# The MIT License
#
# Copyright 2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
require 'thread'
m = Mutex.new
c = ConditionVariable.new
th = Thread.new do
include Vx::Common::Spawn
spawn "command" do |output|
if output =~ /regexp/
m.synchronize { c.signal }
save_customers false
save_events true
total :unique_customers_count, :sum
total :events_count, :sum
total :events_sum, :sum
total :events_bonus_sum, :sum
total :events_discount_sum, :sum
total :events_discount_percentage, :avg, type: "numeric(16,2)"
total :avg_events_sum, :avg, type: "numeric(16,2)"
copy (select dsc.sfid, count(c.id), sum(d.cost) from deal_source_sf_deal_containers dsc inner join deal_source_sf_deals ds on ds.deal_source_sf_deal_container_id = dsc.id inner join deals d on d.deal_source_sf_deal_id = ds.id inner join coupons c on c.deal_id = d.id and c.state = 'money_back' group by dsc.sfid) to '/tmp/returns.csv' with csv;
*** a/libexec/rbenv 2011-12-26 02:32:48.000000000 +0000
--- b/libexec/rbenv 2012-07-21 07:41:23.401917945 +0000
***************
*** 21,27 ****
}
if [ -z "${RBENV_ROOT}" ]; then
! RBENV_ROOT="${HOME}/.rbenv"
else
RBENV_ROOT="${RBENV_ROOT%/}"
@dmexe
dmexe / gist:1508019
Created December 21, 2011 22:32
Git workflow

После установки

Указываем свое имя и почту

git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

Делаем алиасы на команды

class Fashionclub.Views.CommentsView extends Backbone.View
events:
"submit .comment-form" : "onSubmit"
"click .comment .edit-comment" : "onEdit"
"click .comment .destroy-comment": "onDestroy"
"click .comment-form .cancel-comment" : "onCancelEdit"
initialize: ->
_.bindAll(this)
@collection = new Fashionclub.Collections.CommentsCollection
class App.Model.Comment
@list: (owner) ->
App.Model.request('GET', @url(owner))
@create: (owner, comment) ->
App.Model.request('POST', @url(owner), comment)
@update: (owner, id, comment) ->
App.Model.request('PUT', @url(owner, id), comment)
@destroy: (owner, id) ->
App.Model.request('DELETE', @url(owner, id))
@url: (owner, id = null) ->